photon_mosaic.segmentation.basesegmentation#
Functions
Return the names of all built-in and registered segmentation methods. |
|
|
Return the |
|
Register a |
Classes
Base class for ROI segmentation backends. |
- photon_mosaic.segmentation.basesegmentation.register_segmentation_class(segmentation_class)[source]#
Register a
BaseSegmentationsubclass under itsmethod_name.Backend modules call this at import time so that
run_segmentation(..., method=...)can find them. Third-party backends can call it too, which is what makes the set of methods extensible.- Parameters:
segmentation_class (
type[BaseSegmentation]) – Subclass definingmethod_name(and usuallysettings_class).- Returns:
The class, unchanged, so this can be used as a decorator.
- Return type:
type[BaseSegmentation]
- photon_mosaic.segmentation.basesegmentation.get_segmentation_class(method)[source]#
Return the
BaseSegmentationsubclass implementingmethod.Built-in backends are imported lazily on first use, so an optional dependency is only required when its method is actually requested.
- Return type:
type[BaseSegmentation]
- photon_mosaic.segmentation.basesegmentation.get_available_segmentation_methods()[source]#
Return the names of all built-in and registered segmentation methods.
- Return type:
list[str]
- class photon_mosaic.segmentation.basesegmentation.BaseSegmentation[source]#
Base class for ROI segmentation backends.
Modelled on SpikeInterface’s
BaseSorter: subclasses are never instantiated, they only provide classmethods thatphoton_mosaic.segmentation.run_segmentation()calls in order:initialize_folder()/set_params_to_folder()(provided here)run()– detect ROIs on one contiguous span of epochs and return them as aBaseRois
Subclasses declare
method_name(the string users pass asmethod) andsettings_class(their pydantic settings model), and register themselves withregister_segmentation_class().- Attributes:
- method_name
- settings_class
Methods
Return the default value of every setting of
settings_class.Return the version of the underlying segmentation library.
initialize_folder(folder[, ...])Create the output
folder, refusing to overwrite unless asked.Return whether the backend's dependencies are importable.
Return the description of every setting of
settings_class.run(imaging, yrange, xrange, badframes, settings)Detect ROIs on the concatenation of all epochs of
imagingand return them.set_params_to_folder(folder, settings, ...)Write the validated settings and the run arguments to
segmentation_params.json.- method_name: str | None = None#
- settings_class: type[BaseSettings] | None = None#
- support_multi_plane = False#
- classmethod is_installed()[source]#
Return whether the backend’s dependencies are importable.
- Return type:
bool
- classmethod get_method_version()[source]#
Return the version of the underlying segmentation library.
- Return type:
str
- classmethod default_params()[source]#
Return the default value of every setting of
settings_class.- Return type:
dict[str,Any]
- classmethod params_description()[source]#
Return the description of every setting of
settings_class.- Return type:
dict[str,str|None]
- classmethod initialize_folder(folder, remove_existing_folder=False)[source]#
Create the output
folder, refusing to overwrite unless asked.- Return type:
Path
- classmethod set_params_to_folder(folder, settings, run_kwargs)[source]#
Write the validated settings and the run arguments to
segmentation_params.json.- Return type:
None
- classmethod run(imaging, yrange, xrange, badframes, settings)[source]#
Detect ROIs on the concatenation of all epochs of
imagingand return them.- Parameters:
imaging (
BaseImaging) – Motion-corrected imaging object.yrange (
Sequence[int]) – Valid pixel range[lo, hi].xrange (
Sequence[int]) – Valid pixel range[lo, hi].badframes (
NDArray[bool] |None) – Frames to exclude, shaped(total_frames_in_epochs,).settings (
Any) – Validatedsettings_classinstance.
- Returns:
rois – Detected ROIs for the concatenated epochs.
- Return type: