PartSegCore.analysis.calculation_plan

class PartSegCore.analysis.calculation_plan.BaseCalculation(base_prefix, result_prefix, measurement_file_path, sheet_name, calculation_plan, voxel_size, overwrite_voxel_size=False)[source]

Bases: object

Base description of calculation needed for single file

Variables:
  • ~.base_prefix (str) – path prefix which should be used to calculate relative path of processed files

  • ~.result_prefix (str) – path prefix for saving structure

  • ~.measurement_file_path (str) – path to file in which result of measurement should be saved

  • ~.sheet_name (str) – name of sheet in excel file

  • ~.calculation_plan (CalculationPlan) – plan of calculation

  • uuid (str) – ~.uuid of whole calculation

  • ~.voxel_size – default voxel size (for files which do not contains this information in metadata

class PartSegCore.analysis.calculation_plan.Calculation(file_list, base_prefix, result_prefix, measurement_file_path, sheet_name, calculation_plan, voxel_size, overwrite_voxel_size=False)[source]

Bases: BaseCalculation

Description of whole calculation. Extended with list of all files to proceed

Variables:
  • ~.base_prefix (str) – path prefix which should be used to calculate relative path of processed files

  • ~.result_prefix (str) – path prefix for saving structure

  • ~.measurement_file_path (str) – path to file in which result of measurement should be saved

  • ~.sheet_name (str) – name of sheet in excel file

  • ~.calculation_plan (CalculationPlan) – plan of calculation

  • uuid (str) – ~.uuid of whole calculation

  • ~.voxel_size – default voxel size (for files which do not contains this information in metadata

  • ~.file_list (list[str]) – list of files to be proceed

get_base_calculation()[source]

Extract py:class:BaseCalculation from instance.

Return type:

BaseCalculation

class PartSegCore.analysis.calculation_plan.CalculationPlan(tree=None, name='')[source]

Bases: object

Clean description Calculation plan.

static get_el_name(el)[source]
Parameters:

el – Plan element

Returns:

str

get_list_file_mask()[source]
Returns:

list[MaskMapper]

get_mask_names(node=None)[source]
Parameters:

node (CalculationTree)

Returns:

set[str]

get_measurements(node=None)[source]

Get all measurement Calculation below given node

Parameters:

node (Optional[CalculationTree]) – Node for start, if absent then start from plan root

Return type:

list[MeasurementCalculate]

Returns:

list of measurements

get_node(search_pos=None, parent=False)[source]
Parameters:

search_pos (Optional[list[int]])

Return type:

CalculationTree

Returns:

CalculationTree

class PartSegCore.analysis.calculation_plan.CalculationTree(operation, children)[source]

Bases: object

Structure for describe calculation structure

class PartSegCore.analysis.calculation_plan.FileCalculation(file_path, calculation)[source]

Bases: object

Description of single file calculation

property base_prefix

path prefix which should be used to calculate relative path of processed files

property calculation_plan

plan of calculation

property overwrite_voxel_size

overwrite voxel size

property result_prefix

path prefix for saving structure

property uuid

uuid of whole calculation

property voxel_size

default voxel size (for files which do not contains this information in metadata

class PartSegCore.analysis.calculation_plan.MaskBase(**data)[source]

Bases: BaseModel

Base class for mask in calculation plan.

Variables:

~.name (str) – name of mask

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class PartSegCore.analysis.calculation_plan.MaskCreate(**data)[source]

Bases: MaskBase

Description of mask creation in calculation plan.

Variables:
model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class PartSegCore.analysis.calculation_plan.MaskFile(**data)[source]

Bases: MaskMapper

get_mask_path(file_path)[source]

Calculate mask path based od file_path

Parameters:

file_path (str) – path to proceeded file

Return type:

str

get_parameters()[source]

Parameters for serialize

is_ready()[source]

Check if this mask mapper can be used

Return type:

bool

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class PartSegCore.analysis.calculation_plan.MaskIntersection(**data)[source]

Bases: MaskBase

Description of AND operation on mask

Variables:
  • ~.name (str) – name of mask

  • ~.mask1 (str) – first mask name

  • ~.mask2 (str) – second mask name

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class PartSegCore.analysis.calculation_plan.MaskMapper(**data)[source]

Bases: BaseModel

Base class for obtaining mask from computer disc

Variables:

~.name – mask name

abstractmethod get_mask_path(file_path)[source]

Calculate mask path based od file_path

Parameters:

file_path (str) – path to proceeded file

Return type:

str

abstractmethod get_parameters()[source]

Parameters for serialize

static is_ready()[source]

Check if this mask mapper can be used

Return type:

bool

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class PartSegCore.analysis.calculation_plan.MaskSub(**data)[source]

Bases: MaskMapper

Description of mask form file obtained by substitution

Variables:
  • ~.name (str) – mask name

  • ~.base (str) – string to be searched

  • ~.repr (str) – string to be put instead of base

get_mask_path(file_path)[source]

Calculate mask path based od file_path

Parameters:

file_path (str) – path to proceeded file

Return type:

str

get_parameters()[source]

Parameters for serialize

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class PartSegCore.analysis.calculation_plan.MaskSuffix(**data)[source]

Bases: MaskMapper

Description of mask form file obtained by adding suffix to image file path

Variables:
  • ~.name (str) – mask name

  • ~.suffix (str) – mask file path suffix

get_mask_path(file_path)[source]

Calculate mask path based od file_path

Parameters:

file_path (str) – path to proceeded file

Return type:

str

get_parameters()[source]

Parameters for serialize

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class PartSegCore.analysis.calculation_plan.MaskSum(**data)[source]

Bases: MaskBase

Description of OR operation on mask

Variables:
  • ~.name (str) – name of mask

  • ~.mask1 (str) – first mask name

  • ~.mask2 (str) – second mask name

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class PartSegCore.analysis.calculation_plan.MaskUse(**data)[source]

Bases: MaskBase

Reuse of already defined mask Will be deprecated in short time

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class PartSegCore.analysis.calculation_plan.MeasurementCalculate(**data)[source]

Bases: BaseModel

Measurement calculation description

Variables:
  • ~.channel (int) – on which channel measurements should be calculated

  • ~.units (Units) – Type of units in which results of measurements should be represented

  • ~.statistic_profile (MeasurementProfile) – description of measurements

  • name_prefix (str) – prefix of column names

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property name

name of used MeasurementProfile

class PartSegCore.analysis.calculation_plan.NodeType(*values)[source]

Bases: Enum

Type of node in calculation

file_mask = 7

mask load

mask = 2

mask creation

measurement = 3

measurement calculation

none = 6

other, like description

root = 4

root of calculation

save = 5

save operation

segment = 1

segmentation

class PartSegCore.analysis.calculation_plan.Operations(*values)[source]

Bases: Enum

Global operations

class PartSegCore.analysis.calculation_plan.PlanChanges(*values)[source]

Bases: Enum

History elements

add_node = 1
remove_node = 2
replace_node = 3
class PartSegCore.analysis.calculation_plan.RootType(*values)[source]

Bases: Enum

Defines root type which changes of data available on begin of calculation

Image = 0

raw image

Mask_project = 2

Project from mask segmentation. It contains multiple elements.

Project = 1

PartSeg project with defined segmentation

class PartSegCore.analysis.calculation_plan.Save(**data)[source]

Bases: BaseModel

Save operation description

Variables:
  • ~.suffix (str) – suffix for saved file

  • ~.directory (str) – name of subdirectory to save

  • ~.algorithm (str) – name of save method

  • ~.short_name (str) – short name of save method

  • ~.values (dict) – parameters specific for save method

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

PartSegCore.analysis.calculation_plan.get_save_path(op, calculation)[source]

Calculate save path base on proceeded file path and save operation parameters. It assume that save algorithm is registered in PartSegCore.analysis.save_functions.save_dict

Parameters:
  • op (Save) – operation to do

  • calculation (FileCalculation) – information about calculation

Return type:

str

Returns:

save path