PartSegCore.analysis.measurement_base

class PartSegCore.analysis.measurement_base.AreaType(value)[source]

Bases: enum.Enum

On which area type measurement should be calculated

pydantic model PartSegCore.analysis.measurement_base.Leaf[source]

Bases: PartSegCore.utils.BaseModel

Class for describe calculation of basic measurement

Show JSON schema
{
   "title": "Leaf",
   "description": "Class for describe calculation of basic measurement",
   "type": "object",
   "properties": {
      "name": {
         "title": "Name",
         "type": "string"
      },
      "parameters": {
         "title": "Parameters"
      },
      "power": {
         "title": "Power",
         "default": 1.0,
         "type": "number"
      },
      "area": {
         "$ref": "#/definitions/AreaType"
      },
      "per_component": {
         "$ref": "#/definitions/PerComponent"
      },
      "channel": {
         "title": "Channel",
         "type": "object",
         "properties": {
            "value": {
               "title": "value",
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "integer"
                  }
               ]
            }
         }
      }
   },
   "required": [
      "name"
   ],
   "additionalProperties": false,
   "definitions": {
      "AreaType": {
         "title": "AreaType",
         "description": "On which area type measurement should be calculated",
         "enum": [
            1,
            2,
            3
         ]
      },
      "PerComponent": {
         "title": "PerComponent",
         "description": "How measurement should be calculated",
         "enum": [
            1,
            2,
            3,
            4
         ]
      }
   }
}

Config
  • extra: str = forbid

Fields
Validators
field area: Optional[PartSegCore.analysis.measurement_base.AreaType] = None
field channel: Optional[PartSegImage.channel_class.Channel] = None
Constraints
  • title = Channel

  • type = object

  • properties = {‘value’: {‘title’: ‘value’, ‘anyOf’: [{‘type’: ‘string’}, {‘type’: ‘integer’}]}}

field name: str [Required]
field parameters: Any [Optional]
Validated by
  • _validate_parameters

field per_component: Optional[PartSegCore.analysis.measurement_base.PerComponent] = None
Validated by
  • _validate_per_component

field power: float = 1.0
get_channel_num(measurement_dict)[source]

Get set with number of channels needed for calculate this measurement

Parameters

measurement_dict (Dict[str, MeasurementMethodBase]) – dict with all measurementh method.

Return type

Set[Channel]

Returns

set of channels num

get_unit(ndim)[source]

Return unit of selected measurement reflecting dimensionality.

Parameters

ndim (int) – data dimensionality

Return type

Symbol

is_per_component()[source]

If measurement return list of result or single value.

Return type

bool

need_mask()[source]

If this measurement need mast for proper calculation.

Return type

bool

pretty_print(measurement_dict)[source]

Pretty print for presentation in user interface.

Parameters

measurement_dict (Dict[str, MeasurementMethodBase]) – dict with additional information used for more detailed description

Return type

str

Returns

string with indentation

replace_(**kwargs)
Return type

Leaf

pydantic model PartSegCore.analysis.measurement_base.MeasurementEntry[source]

Bases: PartSegCore.utils.BaseModel

Describe single measurement in measurement set

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

Config
  • extra: str = forbid

Fields
field calculation_tree: Union[PartSegCore.analysis.measurement_base.Node, PartSegCore.analysis.measurement_base.Leaf] [Required]
field name: str [Required]
get_channel_num(measurement_dict)[source]
Return type

Set[Channel]

get_unit(unit, ndim)[source]
Return type

str

class PartSegCore.analysis.measurement_base.MeasurementMethodBase[source]

Bases: PartSegCore.algorithm_describe_base.AlgorithmDescribeBase, abc.ABC

This is base class For all measurement calculation classes based on text_info[0] the measurement name wil be generated, based_on text_info[1] the description is generated

static area_type(area)[source]

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

static calculate_property(channel, roi, mask, voxel_size, result_scalar, roi_alternative, roi_annotation, **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 – array representing current area returned by area_type()

  • roi (ndarray) – array representing roi

  • mask (ndarray) – array representing mask (upper level roi)

  • voxel_size (Tuple[Union[float, int], ...]) – size of single voxel in meters

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

  • roi_alternative (Dict[str, ndarray]) – dict with alternative roi representation (for plugin specific mapping)

  • roi_annotation (Dict[int, Any]) – dict with roi annotations (for plugin specific mapping)

List incomplete.

classmethod get_description()[source]

Measurement long description

Return type

str

classmethod get_name()[source]

Name of measurement

Return type

str

classmethod get_starting_leaf()[source]

This leaf is put on default list

Return type

Leaf

classmethod get_units(ndim)[source]

Return units for measurement. They are shown to user

Return type

symbols

classmethod is_component()[source]

Return information if Need information about components

Return type

bool

classmethod need_channel()[source]

if need image data

pydantic model PartSegCore.analysis.measurement_base.Node[source]

Bases: PartSegCore.utils.BaseModel

Class for describe operation between two measurements

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

Config
  • extra: str = forbid

Fields
field left: Union[PartSegCore.analysis.measurement_base.Node, PartSegCore.analysis.measurement_base.Leaf] [Required]
field op: str [Required]

Operation to perform between left and right child. Currently only division (/) supported

field right: Union[PartSegCore.analysis.measurement_base.Node, PartSegCore.analysis.measurement_base.Leaf] [Required]
get_channel_num(measurement_dict)[source]
Return type

Set[Channel]

get_unit(ndim)[source]
Return type

Symbol

is_per_component()[source]
Return type

bool

need_mask()[source]
pretty_print(measurement_dict)[source]
Return type

str

class PartSegCore.analysis.measurement_base.PerComponent(value)[source]

Bases: enum.Enum

How measurement should be calculated

PartSegCore.analysis.measurement_base.has_mask_components(component_and_mask_info)[source]

Check if any measurement will return value per mask component

Return type

bool

PartSegCore.analysis.measurement_base.has_roi_components(component_and_mask_info)[source]

Check if any measurement will return value per ROI component

Return type

bool