PartSegCore.mask.io_functions

class PartSegCore.mask.io_functions.LoadROI[source]

Bases: PartSegCore.io_utils.LoadBase

Load ROI segmentation data.

classmethod get_name()[source]

Algorithm name. It will be used during interface generating and in registering to proper PartSeg.PartSegCore.algorithm_describe_base.Register.

Returns

name of algorithm

classmethod load(load_locations, range_changed=None, step_changed=None, metadata=None)[source]

Function for load data

Parameters
  • load_locations (List[Union[str, BytesIO, Path]]) – list of files to load

  • range_changed (Optional[Callable[[int, int], Any]]) – callback function for inform about number of steps to be done

  • step_changed (Optional[Callable[[int], Any]]) – callback function for report that single step has been done

  • metadata (Optional[dict]) – additional information needed by function. Like default spacing for load image

Return type

MaskProjectTuple

Returns

Project info or list of project info

classmethod partial()[source]

Inform that this class load complete data

class PartSegCore.mask.io_functions.LoadROIFromTIFF[source]

Bases: PartSegCore.io_utils.LoadBase

classmethod get_name()[source]

Algorithm name. It will be used during interface generating and in registering to proper PartSeg.PartSegCore.algorithm_describe_base.Register.

Return type

str

Returns

name of algorithm

classmethod load(load_locations, range_changed=None, step_changed=None, metadata=None)[source]

Function for load data

Parameters
  • load_locations (List[Union[str, BytesIO, Path]]) – list of files to load

  • range_changed (Optional[Callable[[int, int], Any]]) – callback function for inform about number of steps to be done

  • step_changed (Optional[Callable[[int], Any]]) – callback function for report that single step has been done

  • metadata (Optional[dict]) – additional information needed by function. Like default spacing for load image

Return type

Union[ProjectInfoBase, List[ProjectInfoBase]]

Returns

Project info or list of project info

class PartSegCore.mask.io_functions.LoadROIImage[source]

Bases: PartSegCore.io_utils.LoadBase

Load ROI segmentation and image which is pointed in.

classmethod get_name()[source]

Algorithm name. It will be used during interface generating and in registering to proper PartSeg.PartSegCore.algorithm_describe_base.Register.

Returns

name of algorithm

classmethod load(load_locations, range_changed=None, step_changed=None, metadata=None)[source]

Function for load data

Parameters
  • load_locations (List[Union[str, BytesIO, Path]]) – list of files to load

  • range_changed (Optional[Callable[[int, int], Any]]) – callback function for inform about number of steps to be done

  • step_changed (Optional[Callable[[int], Any]]) – callback function for report that single step has been done

  • metadata (Optional[dict]) – additional information needed by function. Like default spacing for load image

Return type

MaskProjectTuple

Returns

Project info or list of project info

class PartSegCore.mask.io_functions.LoadROIParameters[source]

Bases: PartSegCore.io_utils.LoadBase

Load parameters of ROI segmentation. From segmentation file or from json

classmethod get_name()[source]

Algorithm name. It will be used during interface generating and in registering to proper PartSeg.PartSegCore.algorithm_describe_base.Register.

Returns

name of algorithm

classmethod load(load_locations, range_changed=None, step_changed=None, metadata=None)[source]

Function for load data

Parameters
  • load_locations (List[Union[str, BytesIO, Path]]) – list of files to load

  • range_changed (Optional[Callable[[int, int], Any]]) – callback function for inform about number of steps to be done

  • step_changed (Optional[Callable[[int], Any]]) – callback function for report that single step has been done

  • metadata (Optional[dict]) – additional information needed by function. Like default spacing for load image

Return type

MaskProjectTuple

Returns

Project info or list of project info

class PartSegCore.mask.io_functions.LoadStackImage[source]

Bases: PartSegCore.io_utils.LoadBase

Load image from standard microscopy images

classmethod get_name()[source]

Algorithm name. It will be used during interface generating and in registering to proper PartSeg.PartSegCore.algorithm_describe_base.Register.

Returns

name of algorithm

classmethod load(load_locations, range_changed=None, step_changed=None, metadata=None)[source]

Function for load data

Parameters
  • load_locations (List[Union[str, BytesIO, Path]]) – list of files to load

  • range_changed (Optional[Callable[[int, int], Any]]) – callback function for inform about number of steps to be done

  • step_changed (Optional[Callable[[int], Any]]) – callback function for report that single step has been done

  • metadata (Optional[dict]) – additional information needed by function. Like default spacing for load image

Return type

MaskProjectTuple

Returns

Project info or list of project info

class PartSegCore.mask.io_functions.LoadStackImageWithMask[source]

Bases: PartSegCore.io_utils.LoadBase

Load image, then mask from secondary file

classmethod get_name()[source]

Algorithm name. It will be used during interface generating and in registering to proper PartSeg.PartSegCore.algorithm_describe_base.Register.

Return type

str

Returns

name of algorithm

classmethod load(load_locations, range_changed=None, step_changed=None, metadata=None)[source]

Function for load data

Parameters
  • load_locations (List[Union[str, BytesIO, Path]]) – list of files to load

  • range_changed (Optional[Callable[[int, int], Any]]) – callback function for inform about number of steps to be done

  • step_changed (Optional[Callable[[int], Any]]) – callback function for report that single step has been done

  • metadata (Optional[dict]) – additional information needed by function. Like default spacing for load image

Return type

Union[ProjectInfoBase, List[ProjectInfoBase]]

Returns

Project info or list of project info

classmethod number_of_files()[source]

Number of files required for load method

class PartSegCore.mask.io_functions.MaskProjectTuple(file_path, image, mask=None, roi_info=<factory>, additional_layers=<factory>, selected_components=<factory>, roi_extraction_parameters=<factory>, history=<factory>, errors='', spacing=None, points=None, frame_thickness=2)[source]

Bases: PartSegCore.project_info.ProjectInfoBase

Dataclass instance to describe segmentation state

Variables
  • file_path (str) – path to current processed file

  • ~.image (Union[Image,str,None]) – image which is proceeded in given segmentation. If str then it is path to image on drive

  • ~.mask (Optional[np.ndarray]) – Mask limiting segmentation area.

  • ~.roi_info (SegmentationInfo) – ROI information.

  • ~.roi_info – ROI description

  • ~.selected_components (List[int]) – list of selected components

  • ~.segmentation_parameters (Dict[int,Optional[SegmentationProfile]]) – For each component description set of parameters used for segmentation

  • history (List[HistoryElement]) – list of operations needed to create mask

  • ~.errors (str) – information about problems meet during calculation

  • ~.spacing (Optional[List[float]]) – information about spacing when image is missed. For napari read plugin

get_raw_copy()[source]

Create copy with only image

class PartSegCore.mask.io_functions.SaveComponents[source]

Bases: PartSegCore.io_utils.SaveBase

Save selected components in separated files.

This algorithm has following parameters:

  • frame (int)- Frame, How many pixels around bounding box of ROI should be saved

  • mask_data (bool)- Keep data outside ROI, If not checked then data outside ROI will be replaced with zeros.

classmethod get_name()[source]

Algorithm name. It will be used during interface generating and in registering to proper PartSeg.PartSegCore.algorithm_describe_base.Register.

Return type

str

Returns

name of algorithm

classmethod save(cls, save_location, project_info, parameters, range_changed=None, step_changed=None)[source]
Parameters
  • save_location (Union[str, BytesIO, Path]) – location to save, can be buffer

  • project_info (MaskProjectTuple) – all project data

  • parameters (SaveComponentsOptions) – additional parameters for saving method

  • range_changed – report function for inform about steps num

  • step_changed – report function for progress

class PartSegCore.mask.io_functions.SaveComponentsImagej[source]

Bases: PartSegCore.io_utils.SaveBase

This algorithm has following parameters:

  • frame (int)- Frame, How many pixels around bounding box of ROI should be saved

  • mask_data (bool)- Keep data outside ROI, If not checked then data outside ROI will be replaced with zeros.

classmethod get_name()[source]

Algorithm name. It will be used during interface generating and in registering to proper PartSeg.PartSegCore.algorithm_describe_base.Register.

Return type

str

Returns

name of algorithm

classmethod save(cls, save_location, project_info, parameters, range_changed=None, step_changed=None)[source]
Parameters
  • save_location (Union[str, BytesIO, Path]) – location to save, can be buffer

  • project_info (MaskProjectTuple) – all project data

  • parameters (SaveComponentsOptions) – additional parameters for saving method

  • range_changed – report function for inform about steps num

  • step_changed – report function for progress

class PartSegCore.mask.io_functions.SaveParametersJSON[source]

Bases: PartSegCore.io_utils.SaveBase

Save parameters of roi mask segmentation

classmethod get_fields()[source]

This function return list of parameters needed by algorithm. It is used for generate form in User Interface

Return type

List[Union[AlgorithmProperty, str]]

Returns

list of algorithm parameters and comments

classmethod get_name()[source]

Algorithm name. It will be used during interface generating and in registering to proper PartSeg.PartSegCore.algorithm_describe_base.Register.

Return type

str

Returns

name of algorithm

classmethod save(save_location, project_info, parameters=None, range_changed=None, step_changed=None)[source]
Parameters
  • save_location (Union[str, BytesIO, Path]) – path to save

  • project_info (Union[ROIExtractionProfile, MaskProjectTuple]) – data to save in json file

  • parameters (Optional[dict]) – Not used, keep for satisfy interface

  • range_changed – Not used, keep for satisfy interface

  • step_changed – Not used, keep for satisfy interface

Returns

class PartSegCore.mask.io_functions.SaveROI[source]

Bases: PartSegCore.io_utils.SaveBase

Save current ROI as a project

This algorithm has following parameters:

  • relative_path (bool)- Relative Path in segmentation, Use relative path to image in segmentation file

  • mask_data (bool)- Keep data outside ROI, When loading data in ROI analysis, if not checked then data outside ROI will be replaced with zeros.

  • frame_thickness (int)- Frame thickness, Thickness of frame around ROI

classmethod get_name()[source]

Algorithm name. It will be used during interface generating and in registering to proper PartSeg.PartSegCore.algorithm_describe_base.Register.

Returns

name of algorithm

classmethod save(cls, save_location, project_info, parameters, range_changed=None, step_changed=None)[source]
Parameters
  • save_location (Union[str, BytesIO, Path]) – location to save, can be buffer

  • project_info (MaskProjectTuple) – all project data

  • parameters (SaveROIOptions) – additional parameters for saving method

  • range_changed – report function for inform about steps num

  • step_changed – report function for progress

PartSegCore.mask.io_functions.empty_fun(_a0=None, _a1=None)[source]

This is empty fun to pass as callback to for report.

PartSegCore.mask.io_functions.load_metadata(data)[source]

Load metadata saved in json format for segmentation mask :type data: Union[str, Path, TextIO] :param data: path to json file, string with json, or opened file :return: restored structures