PartSegCore.analysis.measurement_calculation

class PartSegCore.analysis.measurement_calculation.ColocalizationMeasurement[source]

Bases: MeasurementMethodBase

This algorithm has following parameters:

  • channel_fst (Channel)- Channel 1

  • channel_scd (Channel)- Channel 2

  • colocalization (CorrelationEnum)- Colocalization

  • randomize (bool)- Randomize channel, If randomize orders of pixels in one channel

  • randomize_repeat (int)- Randomize num, Number of repetitions for mean_calculate

classmethod calculate_property(area_array, colocalization, randomize=False, randomize_repeat=10, channel_fst=0, channel_scd=1, **kwargs)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

Return type:

symbols

pydantic model PartSegCore.analysis.measurement_calculation.ColocalizationMeasurementParameters[source]

Bases: BaseModel

Show JSON schema
{
   "title": "ColocalizationMeasurementParameters",
   "type": "object",
   "properties": {
      "channel_fst": {
         "default": 0,
         "properties": {
            "value": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "integer"
                  }
               ],
               "title": "value"
            }
         },
         "title": "Channel 1",
         "type": "object"
      },
      "channel_scd": {
         "default": 1,
         "properties": {
            "value": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "integer"
                  }
               ],
               "title": "value"
            }
         },
         "title": "Channel 2",
         "type": "object"
      },
      "colocalization": {
         "allOf": [
            {
               "$ref": "#/$defs/CorrelationEnum"
            }
         ],
         "default": "Pearson correlation coefficient"
      },
      "randomize": {
         "default": false,
         "description": "If randomize orders of pixels in one channel",
         "title": "Randomize channel",
         "type": "boolean"
      },
      "randomize_repeat": {
         "default": 10,
         "description": "Number of repetitions for mean_calculate",
         "title": "Randomize num",
         "type": "integer"
      }
   },
   "$defs": {
      "CorrelationEnum": {
         "enum": [
            "Pearson correlation coefficient",
            "Mander's overlap coefficient",
            "Intensity correlation quotient",
            "Spearman rank correlation"
         ],
         "title": "CorrelationEnum",
         "type": "string"
      }
   },
   "additionalProperties": false
}

Config:
  • extra: str = forbid

Fields:
field channel_fst: Channel = 0
field channel_scd: Channel = 1
field colocalization: CorrelationEnum = CorrelationEnum.pearson
field randomize: bool = False

If randomize orders of pixels in one channel

field randomize_repeat: int = 10

Number of repetitions for mean_calculate

class PartSegCore.analysis.measurement_calculation.Compactness[source]

Bases: MeasurementMethodBase

static calculate_property(**kwargs)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

class PartSegCore.analysis.measurement_calculation.ComponentBoundingBox[source]

Bases: MeasurementMethodBase

static calculate_property(bounds_info, _component_num, **kwargs)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_starting_leaf()[source]

This leaf is put on default list

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

class PartSegCore.analysis.measurement_calculation.ComponentsInfo(roi_components: ndarray, mask_components: ndarray, components_translation: Dict[int, List[int]])[source]

Bases: NamedTuple

Class for storage information about relation between roi components and mask components

Variables:
  • roi_components (numpy.ndarray) – list of roi components

  • mask_components (numpy.ndarray) – list of mask components

  • components_translation (Dict[int, List[int]]) – mapping from roi components to mask components base on intersections

components_translation: Dict[int, List[int]]

Alias for field number 2

mask_components: ndarray

Alias for field number 1

roi_components: ndarray

Alias for field number 0

class PartSegCore.analysis.measurement_calculation.ComponentsNumber[source]

Bases: MeasurementMethodBase

static calculate_property(area_array, **_)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

class PartSegCore.analysis.measurement_calculation.CorrelationEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: str, Enum

class PartSegCore.analysis.measurement_calculation.Diameter[source]

Bases: MeasurementMethodBase

Class for calculate diameter of ROI in fast way. From Malandain, G., & Boissonnat, J. (2002). Computing the diameter of a point set, 12(6), 489-509. https://doi.org/10.1142/S0218195902001006

static calculate_property(area_array, voxel_size, result_scalar, **_)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

class PartSegCore.analysis.measurement_calculation.DiameterOld[source]

Bases: MeasurementMethodBase

n**2 calculate diameter of ROI

static calculate_property(area_array, voxel_size, result_scalar, **_)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

class PartSegCore.analysis.measurement_calculation.DistanceMaskROI[source]

Bases: MeasurementMethodBase

This algorithm has following parameters:

  • distance_from_mask (DistancePoint)- Distance from mask

  • distance_to_roi (DistancePoint)- Distance to ROI

static area_type(area)[source]

Map chosen area type to proper area type. Allow to correct Area type.

classmethod calculate_property(channel, area_array, mask, voxel_size, result_scalar, distance_from_mask, distance_to_roi, *args, **kwargs)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_starting_leaf()[source]

This leaf is put on default list

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

classmethod need_channel()[source]

if need image data

pydantic model PartSegCore.analysis.measurement_calculation.DistanceMaskROIParameters[source]

Bases: BaseModel

Show JSON schema
{
   "title": "DistanceMaskROIParameters",
   "type": "object",
   "properties": {
      "distance_from_mask": {
         "allOf": [
            {
               "$ref": "#/$defs/DistancePoint"
            }
         ],
         "default": 1
      },
      "distance_to_roi": {
         "allOf": [
            {
               "$ref": "#/$defs/DistancePoint"
            }
         ],
         "default": 1,
         "title": "Distance to ROI"
      }
   },
   "$defs": {
      "DistancePoint": {
         "enum": [
            1,
            2,
            3
         ],
         "title": "DistancePoint",
         "type": "integer"
      }
   },
   "additionalProperties": false
}

Config:
  • extra: str = forbid

Fields:
field distance_from_mask: DistancePoint = DistancePoint.Border
field distance_to_roi: DistancePoint = DistancePoint.Border
class PartSegCore.analysis.measurement_calculation.DistancePoint(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

class PartSegCore.analysis.measurement_calculation.DistanceROIROI[source]

Bases: DistanceMaskROI

This algorithm has following parameters:

  • profile (ROIExtractionProfile)- ROI extraction profile

  • distance_from_new_roi (DistancePoint)- Distance new ROI

  • distance_to_roi (DistancePoint)- Distance to ROI

classmethod calculate_property(channel, image, area_array, profile, mask, voxel_size, result_scalar, distance_from_new_roi, distance_to_roi, **kwargs)[source]

Main function for calculating measurement

Parameters:
  • channel (ndarray) – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array (ndarray) – array representing current area returned by area_type()

  • roi – array representing roi

  • mask (Optional[ndarray]) – array representing mask (upper level roi)

  • voxel_size (Sequence[float]) – size of single voxel in meters

  • result_scalar (float) – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_starting_leaf()[source]

This leaf is put on default list

pydantic model PartSegCore.analysis.measurement_calculation.DistanceROIROIParameters[source]

Bases: BaseModel

Show JSON schema
{
   "title": "DistanceROIROIParameters",
   "type": "object",
   "properties": {
      "profile": {
         "allOf": [
            {
               "$ref": "#/$defs/ROIExtractionProfile"
            }
         ],
         "title": "ROI extraction profile"
      },
      "distance_from_new_roi": {
         "allOf": [
            {
               "$ref": "#/$defs/DistancePoint"
            }
         ],
         "default": 1,
         "title": "Distance new ROI"
      },
      "distance_to_roi": {
         "allOf": [
            {
               "$ref": "#/$defs/DistancePoint"
            }
         ],
         "default": 1,
         "title": "Distance to ROI"
      }
   },
   "$defs": {
      "DistancePoint": {
         "enum": [
            1,
            2,
            3
         ],
         "title": "DistancePoint",
         "type": "integer"
      },
      "ROIExtractionProfile": {
         "additionalProperties": false,
         "description": ":ivar str ~.name: name for segmentation profile\n:ivar str ~.algorithm: Name of algorithm\n:ivar dict ~.values: algorithm parameters",
         "properties": {
            "name": {
               "title": "Name",
               "type": "string"
            },
            "algorithm": {
               "title": "Algorithm",
               "type": "string"
            },
            "values": {
               "title": "Values"
            }
         },
         "required": [
            "name",
            "algorithm",
            "values"
         ],
         "title": "ROIExtractionProfile",
         "type": "object"
      }
   },
   "additionalProperties": false
}

Config:
  • extra: str = forbid

Fields:
field distance_from_new_roi: DistancePoint = DistancePoint.Border
field distance_to_roi: DistancePoint = DistancePoint.Border
field profile: ROIExtractionProfile = ROIExtractionProfile(name='default', algorithm='Lower threshold', values=OneThresholdAlgorithmParameters(channel=<PartSegImage.channel_class.Channel(value=0)>, noise_filtering=NoiseFilterSelection(name='None', values=BaseModel(), class_path='PartSegCore.segmentation.noise_filtering.NoneNoiseFiltering'), minimum_size=8000, side_connection=False, threshold=ThresholdSelection(name='Manual', values=SingleThresholdParams(threshold=8000.0), class_path='PartSegCore.segmentation.threshold.ManualThreshold')))
class PartSegCore.analysis.measurement_calculation.FirstPrincipalAxisLength[source]

Bases: MeasurementMethodBase

static calculate_property(**kwargs)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

classmethod need_channel()[source]

if need image data

class PartSegCore.analysis.measurement_calculation.GetROIAnnotationType[source]

Bases: MeasurementMethodBase

This algorithm has following parameters:

  • name (str)- Name

static calculate_property(roi_annotation, name, _component_num, **kwargs)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_starting_leaf()[source]

This leaf is put on default list

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

pydantic model PartSegCore.analysis.measurement_calculation.GetROIAnnotationTypeParameters[source]

Bases: BaseModel

Show JSON schema
{
   "title": "GetROIAnnotationTypeParameters",
   "type": "object",
   "properties": {
      "name": {
         "default": "",
         "title": "Name",
         "type": "string"
      }
   },
   "additionalProperties": false
}

Config:
  • extra: str = forbid

Fields:
field name: str = ''
class PartSegCore.analysis.measurement_calculation.Haralick[source]

Bases: MeasurementMethodBase

This algorithm has following parameters:

  • feature (HaralickEnum)- Feature

  • distance (int)- Distance

classmethod calculate_property(area_array, channel, distance, feature, _cache=False, **kwargs)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

Return type:

symbols

classmethod need_channel()[source]

if need image data

class PartSegCore.analysis.measurement_calculation.HaralickEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

pydantic model PartSegCore.analysis.measurement_calculation.HaralickParameters[source]

Bases: BaseModel

Show JSON schema
{
   "title": "HaralickParameters",
   "type": "object",
   "properties": {
      "feature": {
         "allOf": [
            {
               "$ref": "#/$defs/HaralickEnum"
            }
         ],
         "default": "AngularSecondMoment"
      },
      "distance": {
         "default": 1,
         "maximum": 10,
         "minimum": 1,
         "title": "Distance",
         "type": "integer"
      }
   },
   "$defs": {
      "HaralickEnum": {
         "enum": [
            "AngularSecondMoment",
            "Contrast",
            "Correlation",
            "Variance",
            "InverseDifferenceMoment",
            "SumAverage",
            "SumVariance",
            "SumEntropy",
            "Entropy",
            "DifferenceVariance",
            "DifferenceEntropy",
            "InfoMeas1",
            "InfoMeas2"
         ],
         "title": "HaralickEnum",
         "type": "string"
      }
   },
   "additionalProperties": false
}

Config:
  • extra: str = forbid

Fields:
field distance: int = 1
Constraints:
  • ge = 1

  • le = 10

field feature: HaralickEnum = HaralickEnum.AngularSecondMoment
PartSegCore.analysis.measurement_calculation.MEASUREMENT_DICT

Register with all measurements algorithms

Need class methods: get_description, is_component, calculate_property, get_starting_leaf, get_units, need_channel

Default content:

class PartSegCore.analysis.measurement_calculation.MaximumPixelBrightness[source]

Bases: MeasurementMethodBase

static calculate_property(area_array, channel, **_)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

classmethod need_channel()[source]

if need image data

class PartSegCore.analysis.measurement_calculation.MeanPixelBrightness[source]

Bases: MeasurementMethodBase

static calculate_property(area_array, channel, **_)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

classmethod need_channel()[source]

if need image data

pydantic model PartSegCore.analysis.measurement_calculation.MeasurementProfile[source]

Bases: BaseModel

Show JSON schema
{
   "title": "MeasurementProfile",
   "type": "object",
   "properties": {
      "name": {
         "title": "Name",
         "type": "string"
      },
      "chosen_fields": {
         "items": {
            "$ref": "#/$defs/MeasurementEntry"
         },
         "title": "Chosen Fields",
         "type": "array"
      },
      "name_prefix": {
         "default": "",
         "title": "Name Prefix",
         "type": "string"
      }
   },
   "$defs": {
      "AreaType": {
         "description": "On which area type measurement should be calculated",
         "enum": [
            1,
            2,
            3
         ],
         "title": "AreaType",
         "type": "integer"
      },
      "Leaf": {
         "additionalProperties": false,
         "description": "Class for describe calculation of basic measurement",
         "properties": {
            "name": {
               "title": "Name",
               "type": "string"
            },
            "parameters": {
               "title": "Parameters"
            },
            "power": {
               "default": 1.0,
               "title": "Power",
               "type": "number"
            },
            "area": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/AreaType"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            },
            "per_component": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/PerComponent"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            },
            "channel": {
               "anyOf": [
                  {
                     "properties": {
                        "value": {
                           "anyOf": [
                              {
                                 "type": "string"
                              },
                              {
                                 "type": "integer"
                              }
                           ],
                           "title": "value"
                        }
                     },
                     "title": "Channel",
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Channel"
            }
         },
         "required": [
            "name"
         ],
         "title": "Leaf",
         "type": "object"
      },
      "MeasurementEntry": {
         "additionalProperties": false,
         "description": "Describe single measurement in measurement set",
         "properties": {
            "name": {
               "title": "Name",
               "type": "string"
            },
            "calculation_tree": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/Node"
                  },
                  {
                     "$ref": "#/$defs/Leaf"
                  }
               ],
               "title": "Calculation Tree"
            }
         },
         "required": [
            "name",
            "calculation_tree"
         ],
         "title": "MeasurementEntry",
         "type": "object"
      },
      "Node": {
         "additionalProperties": false,
         "description": "Class for describe operation between two measurements",
         "properties": {
            "left": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/Node"
                  },
                  {
                     "$ref": "#/$defs/Leaf"
                  }
               ],
               "title": "Left"
            },
            "op": {
               "description": "Operation to perform between left and right child. Currently only division (`/`) supported",
               "title": "Op",
               "type": "string"
            },
            "right": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/Node"
                  },
                  {
                     "$ref": "#/$defs/Leaf"
                  }
               ],
               "title": "Right"
            }
         },
         "required": [
            "left",
            "op",
            "right"
         ],
         "title": "Node",
         "type": "object"
      },
      "PerComponent": {
         "description": "How measurement should be calculated",
         "enum": [
            1,
            2,
            3,
            4
         ],
         "title": "PerComponent",
         "type": "integer"
      }
   },
   "additionalProperties": false,
   "required": [
      "name",
      "chosen_fields"
   ]
}

Config:
  • extra: str = forbid

Fields:
field chosen_fields: List[MeasurementEntry] [Required]
field name: str [Required]
field name_prefix: str = ''
calculate(image, channel_num, roi, result_units, range_changed=<function empty_fun>, step_changed=<function empty_fun>, time=0)[source]

Calculate measurements on given set of parameters

Parameters:
  • image (Image) – image on which measurements should be calculated

  • channel_num (int) – channel number on which measurements should be calculated

  • roi (Union[ndarray, ROIInfo]) – array with segmentation labeled as positive integers

  • result_units (Units) – units which should be used to present results.

  • range_changed (Callable[[int, int], Any]) – callback function to set information about steps range

  • step_changed (Callable[[int], Any]) – callback function for set information about steps done

  • time (int) – which data point should be measured

Return type:

MeasurementResult

Returns:

measurements

calculate_tree(node, segmentation_mask_map, help_dict, kwargs)[source]

Main function for calculation tree of measurements. It is executed recursively

Parameters:
  • node (Union[Node, Leaf]) – measurement to calculate

  • segmentation_mask_map (ComponentsInfo) – map from mask segmentation components to mask components. Needed for division

  • help_dict (dict) – dict to cache calculation result. It reduce recalculations of same measurements.

  • kwargs (dict) – additional info needed by measurements

Return type:

Tuple[Union[float, ndarray], symbols, AreaType]

Returns:

measurement value

calculate_yield(image, channel_num, roi, result_units, segmentation_mask_map, time=0)[source]

Calculate measurements on given set of parameters

Parameters:
  • image (Image) – image on which measurements should be calculated

  • roi (Union[ndarray, ROIInfo]) – array with segmentation labeled as positive integers

  • result_units (Units) – units which should be used to present results.

  • segmentation_mask_map (ComponentsInfo) – information which component of roi belongs to which mask component.

  • time (int) – which data point should be measured

Return type:

Generator[Tuple[Union[float, List[float], str], str, Tuple[PerComponent, AreaType]], None, None]

Returns:

measurements

get_channels_num()[source]
Return type:

Set[Channel]

get_component_and_area_info()[source]

For each measurement check if is per component and in which types

Return type:

List[Tuple[PerComponent, AreaType]]

get_component_info(unit)[source]
Returns:

list[((str, str), bool)]

get_segmentation_mask_map(image, roi, time=0)[source]
Return type:

ComponentsInfo

static get_segmentation_to_mask_component(segmentation, mask)[source]

Calculate map from segmentation component num to mask component num

Parameters:
  • segmentation (ndarray) – numpy array with segmentation labeled as positive integers

  • mask (Optional[ndarray]) – numpy array with mask labeled as positive integer

Return type:

ComponentsInfo

Returns:

map

is_any_mask_measurement()[source]
to_dict()[source]
class PartSegCore.analysis.measurement_calculation.MeasurementResult(components_info)[source]

Bases: MutableMapping[str, Tuple[float | List[float] | str, str]]

Class for storage measurements info.

get_component_info(all_components=False)[source]

Get information which type of components are in storage.

Return type:

Tuple[bool, bool]

Returns:

has_mask_components, has_segmentation_components

get_global_names()[source]

Get names for only parameters which are not ‘PerComponent.Yes’

get_global_parameters()[source]

Get only parameters which are not ‘PerComponent.Yes’

get_labels(expand=True, all_components=False)[source]

If expand is false return list of keys of this storage. Otherwise return labels for measurement. Base are keys of this storage. If has mask components, or has segmentation_components then add this labels

Return type:

List[str]

get_separated(all_components=False)[source]

Get measurements separated for each component

Return type:

List[List[Union[float, List[float], str]]]

set_filename(path_fo_file)[source]

Set name of file to be presented as first position.

class PartSegCore.analysis.measurement_calculation.MedianPixelBrightness[source]

Bases: MeasurementMethodBase

static calculate_property(area_array, channel, **_)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

classmethod need_channel()[source]

if need image data

class PartSegCore.analysis.measurement_calculation.MinimumPixelBrightness[source]

Bases: MeasurementMethodBase

static calculate_property(area_array, channel, **_)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

classmethod need_channel()[source]

if need image data

class PartSegCore.analysis.measurement_calculation.Moment[source]

Bases: MeasurementMethodBase

static calculate_property(area_array, channel, voxel_size, **_)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

classmethod need_channel()[source]

if need image data

class PartSegCore.analysis.measurement_calculation.PixelBrightnessSum[source]

Bases: MeasurementMethodBase

static calculate_property(area_array, channel, **_)[source]
Parameters:
  • area_array (ndarray) – mask for area

  • channel (ndarray) – data. same shape like area_type

Returns:

Pixels brightness sum on given area

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

classmethod need_channel()[source]

if need image data

exception PartSegCore.analysis.measurement_calculation.ProhibitedDivision[source]

Bases: Exception

class PartSegCore.analysis.measurement_calculation.ROINeighbourhoodROI[source]

Bases: DistanceMaskROI

This algorithm has following parameters:

  • profile (ROIExtractionProfile)- ROI extraction profile

  • distance (float)- Distance

  • units (Units)- Units

classmethod calculate_property(image, area_array, profile, mask, voxel_size, distance, units, **kwargs)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array (ndarray) – array representing current area returned by area_type()

  • roi – array representing roi

  • mask (Optional[ndarray]) – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_starting_leaf()[source]

This leaf is put on default list

pydantic model PartSegCore.analysis.measurement_calculation.ROINeighbourhoodROIParameters[source]

Bases: BaseModel

Show JSON schema
{
   "title": "ROINeighbourhoodROIParameters",
   "type": "object",
   "properties": {
      "profile": {
         "allOf": [
            {
               "$ref": "#/$defs/ROIExtractionProfile"
            }
         ],
         "title": "ROI extraction profile"
      },
      "distance": {
         "default": 500,
         "maximum": 10000.0,
         "minimum": 0.0,
         "title": "Distance",
         "type": "number"
      },
      "units": {
         "allOf": [
            {
               "$ref": "#/$defs/Units"
            }
         ],
         "default": 2
      }
   },
   "$defs": {
      "ROIExtractionProfile": {
         "additionalProperties": false,
         "description": ":ivar str ~.name: name for segmentation profile\n:ivar str ~.algorithm: Name of algorithm\n:ivar dict ~.values: algorithm parameters",
         "properties": {
            "name": {
               "title": "Name",
               "type": "string"
            },
            "algorithm": {
               "title": "Algorithm",
               "type": "string"
            },
            "values": {
               "title": "Values"
            }
         },
         "required": [
            "name",
            "algorithm",
            "values"
         ],
         "title": "ROIExtractionProfile",
         "type": "object"
      },
      "Units": {
         "enum": [
            0,
            1,
            2,
            3
         ],
         "title": "Units",
         "type": "integer"
      }
   },
   "additionalProperties": false
}

Config:
  • extra: str = forbid

Fields:
field distance: float = 500
Constraints:
  • ge = 0

  • le = 10000

field profile: ROIExtractionProfile = ROIExtractionProfile(name='default', algorithm='Lower threshold', values=OneThresholdAlgorithmParameters(channel=<PartSegImage.channel_class.Channel(value=0)>, noise_filtering=NoiseFilterSelection(name='None', values=BaseModel(), class_path='PartSegCore.segmentation.noise_filtering.NoneNoiseFiltering'), minimum_size=8000, side_connection=False, threshold=ThresholdSelection(name='Manual', values=SingleThresholdParams(threshold=8000.0), class_path='PartSegCore.segmentation.threshold.ManualThreshold')))
field units: Units = Units.nm
class PartSegCore.analysis.measurement_calculation.RimPixelBrightnessSum[source]

Bases: MeasurementMethodBase

This algorithm has following parameters:

  • distance (float)- Distance

  • units (Units)- Units

static area_type(area)[source]

Map chosen area type to proper area type. Allow to correct Area type.

static calculate_property(channel, area_array, **kwargs)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_starting_leaf()[source]

This leaf is put on default list

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

classmethod need_channel()[source]

if need image data

class PartSegCore.analysis.measurement_calculation.RimVolume[source]

Bases: MeasurementMethodBase

This algorithm has following parameters:

  • distance (float)- Distance

  • units (Units)- Units

static area_type(area)[source]

Map chosen area type to proper area type. Allow to correct Area type.

static calculate_property(area_array, voxel_size, result_scalar, **kwargs)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_starting_leaf()[source]

This leaf is put on default list

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

class PartSegCore.analysis.measurement_calculation.SecondPrincipalAxisLength[source]

Bases: MeasurementMethodBase

static calculate_property(**kwargs)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

classmethod need_channel()[source]

if need image data

class PartSegCore.analysis.measurement_calculation.SettingsValue(function, help_message, arguments, is_component, default_area)[source]

Bases: NamedTuple

arguments: Optional[dict]

Alias for field number 2

default_area: Optional[AreaType]

Alias for field number 4

function: Callable

Alias for field number 0

help_message: str

Alias for field number 1

is_component: bool

Alias for field number 3

class PartSegCore.analysis.measurement_calculation.Sphericity[source]

Bases: MeasurementMethodBase

static calculate_property(**kwargs)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

pydantic model PartSegCore.analysis.measurement_calculation.SplitOnPartParameters[source]

Bases: MaskDistanceSplitParameters

Show JSON schema
{
   "title": "SplitOnPartParameters",
   "type": "object",
   "properties": {
      "num_of_parts": {
         "default": 2,
         "maximum": 1024,
         "minimum": 1,
         "title": "Number of Parts",
         "type": "integer"
      },
      "equal_volume": {
         "default": false,
         "description": "If split should be done in respect of parts volume of parts thickness.",
         "title": "Equal Volume",
         "type": "boolean"
      },
      "part_selection": {
         "default": 2,
         "maximum": 1024,
         "minimum": 1,
         "title": "Which part (from border)",
         "type": "integer"
      }
   },
   "additionalProperties": false
}

Config:
  • extra: str = forbid

Fields:
field part_selection: int = 2
Constraints:
  • ge = 1

  • le = 1024

class PartSegCore.analysis.measurement_calculation.SplitOnPartPixelBrightnessSum[source]

Bases: MeasurementMethodBase

This algorithm has following parameters:

  • num_of_parts (int)- Number of Parts

  • equal_volume (bool)- Equal Volume, If split should be done in respect of parts volume of parts thickness.

  • part_selection (int)- Which part (from border)

static area_type(area)[source]

Map chosen area type to proper area type. Allow to correct Area type.

static calculate_property(part_selection, channel, area_array, **kwargs)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_starting_leaf()[source]

This leaf is put on default list

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

classmethod need_channel()[source]

if need image data

class PartSegCore.analysis.measurement_calculation.SplitOnPartVolume[source]

Bases: MeasurementMethodBase

This algorithm has following parameters:

  • num_of_parts (int)- Number of Parts

  • equal_volume (bool)- Equal Volume, If split should be done in respect of parts volume of parts thickness.

  • part_selection (int)- Which part (from border)

static area_type(area)[source]

Map chosen area type to proper area type. Allow to correct Area type.

static calculate_property(part_selection, area_array, voxel_size, result_scalar, **kwargs)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_starting_leaf()[source]

This leaf is put on default list

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

class PartSegCore.analysis.measurement_calculation.StandardDeviationOfPixelBrightness[source]

Bases: MeasurementMethodBase

static calculate_property(area_array, channel, **_)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

classmethod need_channel()[source]

if need image data

class PartSegCore.analysis.measurement_calculation.Surface[source]

Bases: MeasurementMethodBase

static calculate_property(area_array, voxel_size, result_scalar, **_)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

class PartSegCore.analysis.measurement_calculation.ThirdPrincipalAxisLength[source]

Bases: MeasurementMethodBase

static calculate_property(**kwargs)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

classmethod need_channel()[source]

if need image data

class PartSegCore.analysis.measurement_calculation.Volume[source]

Bases: MeasurementMethodBase

classmethod calculate_property(area_array, voxel_size, result_scalar, **_)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

class PartSegCore.analysis.measurement_calculation.VoxelSize[source]

Bases: MeasurementMethodBase

classmethod calculate_property(voxel_size, result_scalar, **kwargs)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

Return type:

symbols

class PartSegCore.analysis.measurement_calculation.Voxels[source]

Bases: MeasurementMethodBase

classmethod calculate_property(area_array, **_)[source]

Main function for calculating measurement

Parameters:
  • channel – main channel selected for measurement

  • channel_{i} – for channel requested using get_fields() AlgorithmProperty("channel", "Channel", 0, value_type=Channel)

  • area_array – array representing current area returned by area_type()

  • roi – array representing roi

  • mask – array representing mask (upper level roi)

  • voxel_size – size of single voxel in meters

  • result_scalar – scalar to get proper units in result

  • roi_alternative – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

PartSegCore.analysis.measurement_calculation.double_normal(point_index, point_positions, points_array)[source]
Parameters:
  • point_index (int) – index of starting points

  • point_positions (ndarray) – points array of size (points_num, number of dimensions)

  • points_array (ndarray) – bool matrix with information about which points are in set

Returns:

PartSegCore.analysis.measurement_calculation.empty_fun(_a0=None, _a1=None)[source]

This function is being used as dummy reporting function.

PartSegCore.analysis.measurement_calculation.hash_fun_call_name(fun, arguments, area, per_component, channel, components_num)[source]

Calculate string for properly cache measurements result.

Parameters:
Return type:

str

Returns:

unique string for such set of arguments

PartSegCore.analysis.measurement_calculation.iterative_double_normal(points_positions)[source]
Parameters:

points_positions (ndarray) – points array of size (points_num, number of dimensions)

Returns:

square power of diameter, 2-tuple of points index gave information which points ar chosen