neuralib.segmentation.cellpose.core.AbstractSegmentationOption
- class neuralib.segmentation.cellpose.core.AbstractSegmentationOption[source]
Bases:
AbstractParser- DESCRIPTION: str = 'ABC for cellular segmentation'
parser description.
- EX_GROUP_SOURCE = 'EX_GROUP_SOURCE'
- file: Path
image file path
- directory: Path
images directory for batch processing
- directory_suffix: str
suffix in batch mode
- save_ij_roi: bool
if save also the imageJ/Fiji compatible .roi file
- force_re_eval: bool
force re-evaluate the result
- model: str
which pretrained model
- no_normalize: bool
NOT DO Percentile-based image normalization for eval
- napari_view: bool
view in napari
- property file_mode: bool
Flag file mode
- property batch_mode: bool
Flag batch mode
- raw_image()[source]
Load image from file and convert to grayscale
- Returns:
Array[float, [H, W]]
- Return type:
ndarray
- foreach_raw_image()[source]
Load image from a directory and convert to grayscale
- Returns:
Tuple of filepath and image Array[float, [H, W]]
- Return type:
Iterable[tuple[Path, ndarray]]
- foreach_normalize_image()[source]
Normalize the image in batch mode
- Returns:
Tuple of filepath and image Array[float, [H, W]]
- Return type:
Iterable[tuple[Path, ndarray]]
- abstract seg_output(filepath)[source]
Get segmented output save path
- Parameters:
filepath (Path) – filepath for image
- Returns:
segmented output save path
- Return type:
Path
- ij_roi_output(filepath)[source]
Get imageJ/Fiji
.roioutput save path- Parameters:
filepath (Path) – filepath for image
- Returns:
ij roi output save path
- Return type:
Path
- abstract eval()[source]
eval the model in single file or batch files, and save the results
- Return type:
None
- EPILOG: str = None
parser epilog. Could be override as a method if its content is dynamic-generated.
- USAGE: str = None
parser usage.
- static __new__(cls, *args, **kwargs)
- main(args=None, *, exit_on_error=True)
parsing the commandline input args and set the argument attributes, then call
run().Example
if overwrite with the argument default, use args
>>> AbstractParser().main((['--source=allen_mouse_25um', '--region=VISal,VISam,...'], []))
- Parameters:
args (list[str] | tuple[list[str]] | None) – commandline arguments, or a tuple of (prepend, append) arguments
exit_on_error (bool) – exit when commandline parsed fail. Otherwise, raise a
RuntimeError.
- classmethod new_parser(**kwargs)
create an
argparse.ArgumentParser.class variable:
USAGE,DESCRIPTIONandEPILOGare used when creation.>>> class A(AbstractParser): ... @classmethod ... def new_parser(cls, **kwargs) -> argparse.ArgumentParser: ... return super().new_parser(**kwargs)
- Parameters:
kwargs – keyword parameters to ArgumentParser
- Returns:
an ArgumentParser.
- Return type:
ArgumentParser
- run()
called when all argument attributes are set