neuralib.segmentation.cellpose.run_api.CellPoseAPIOption

class neuralib.segmentation.cellpose.run_api.CellPoseAPIOption[source]

Bases: AbstractCellPoseOption

DESCRIPTION: str = 'run cell pose for directly call the api'

parser description.

RESTORE_TYPE: ClassVar[str] = 'denoise_cyto3'
RESTORE_RATIO: ClassVar[float] = 1.0
run()[source]

called when all argument attributes are set

eval()[source]

eval the model in single file or batch files, and save the results

EPILOG: str = None

parser epilog. Could be override as a method if its content is dynamic-generated.

EX_GROUP_SOURCE = 'EX_GROUP_SOURCE'
USAGE: str = None

parser usage.

static __new__(cls, *args, **kwargs)
property batch_mode: bool

Flag batch mode

cellpose_view: bool

launch cellpose gui for the analyzed result

chan_nuclear: int

nuclear channel

chan_seg: int

channel for segmentation default:{‘none’: -1, ‘gray’: 0, ‘red’: 1, ‘green’: 2, ‘blue’: 3}

diameter: int

diameter for each neuron (number of each pixel)

directory: Path

images directory for batch processing

directory_suffix: str

suffix in batch mode

file: Path

image file path

property file_mode: bool

Flag file mode

force_re_eval: bool

force re-evaluate the result

foreach_normalize_image()

Normalize the image in batch mode

Returns:

Tuple of filepath and image Array[float, [H, W]]

Return type:

Iterable[tuple[Path, ndarray]]

foreach_raw_image()

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]]

ij_roi_output(filepath)

Get imageJ/Fiji .roi output save path

Parameters:

filepath (Path) – filepath for image

Returns:

ij roi output save path

Return type:

Path

launch_cellpose_gui()

AttributeError: ‘MainW’ object has no attribute ‘load_3D’. Cellpose version 3.0.10.

TODO open issue in cellpose -> move load_3D instance attribute to line above io._load_image() in MainW.__init__()

launch_napari()

napari viewer

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.

model: CPOSE_MODEL

which pretrained model

napari_view: bool

view in napari

classmethod new_parser(**kwargs)

create an argparse.ArgumentParser.

class variable: USAGE, DESCRIPTION and EPILOG are 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

no_normalize: bool

NOT DO Percentile-based image normalization for eval

normalize_image()

Normalize the image

Returns:

Array[float, [H, W]]

Return type:

ndarray

post_parsing()

check args is valid

raw_image()

Load image from file and convert to grayscale

Returns:

Array[float, [H, W]]

Return type:

ndarray

save_ij_roi: bool

if save also the imageJ/Fiji compatible .roi file

seg_output(filepath)

Get segmented output save path

Parameters:

filepath (Path) – filepath for image

Returns:

segmented output save path

Return type:

Path