neuralib.segmentation.stardist.run_2d.StarDist2DOptions

class neuralib.segmentation.stardist.run_2d.StarDist2DOptions[source]

Bases: AbstractSegmentationOption

__init__()

Methods

__init__()

eval(**kwargs)

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

foreach_normalize_image()

Normalize the image in batch mode

foreach_raw_image()

Load image from a directory and convert to grayscale

ij_roi_output(filepath)

Get imageJ/Fiji .roi output save path

launch_napari([with_widget])

Launch napari viewer for stardist results

main([args, exit_on_error])

parsing the commandline input args and set the argument attributes, then call run().

new_parser(**kwargs)

create an argparse.ArgumentParser.

normalize_image()

Normalize the image

post_parsing()

check args is valid

raw_image()

Load image from file and convert to grayscale

run()

called when all argument attributes are set

seg_output(filepath)

Get output save path

Attributes

DESCRIPTION

parser description.

EPILOG

parser epilog.

EX_GROUP_SOURCE

USAGE

parser usage.

batch_mode

Flag batch mode

directory

images directory for batch processing

directory_suffix

suffix in batch mode

file

image file path

file_mode

Flag file mode

force_re_eval

force re-evaluate the result

model

stardist pretrained model

napari_view

view in napari

no_normalize

NOT DO Percentile-based image normalization for eval

prob_thresh

Consider only object candidates from pixels with predicted object probability above this threshold.

save_ij_roi

if save also the imageJ/Fiji compatible .roi file

DESCRIPTION: str = 'Run the Stardist model for segmentation'

parser description.

model: Literal['2D_versatile_fluo', '2D_versatile_he', '2D_paper_dsb2018', '2D_demo']

stardist pretrained model

prob_thresh: float

Consider only object candidates from pixels with predicted object probability above this threshold. Seealso: stardist.models.base._predict_instances_generator: prob_thresh

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

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

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.

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

run()[source]

called when all argument attributes are set

save_ij_roi: bool

if save also the imageJ/Fiji compatible .roi file

seg_output(filepath)[source]

Get output save path

Parameters:

filepath (Path) – filepath for image

Returns:

output save path

Return type:

Path

eval(**kwargs)[source]

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

Return type:

None

launch_napari(with_widget=False)[source]

Launch napari viewer for stardist results

Parameters:

with_widget (bool) – If True, launch also with the starDist widget (required package stardist-napari)