m3resp.PixelMask#
- class m3resp.PixelMask(name, values, modality='eit', method=None, metadata=<factory>, *, keep_zeros=False, suppress_value_range_error=False, suppress_zero_conversion_warning=False, suppress_all_nan_warning=False)[source]#
Which pixels of an EIT image belong to a region.
Each pixel holds NaN when it is outside the region, 1 when it is included, or a weight from 0 to 1 when it counts partly. Applying the mask multiplies each pixel by this number, so a NaN pixel drops out and a pixel with weight 0 adds nothing to a sum.
The checks follow eitprocessing’s
PixelMask:A 0 becomes NaN, with a warning. Pass
keep_zeros=Trueto keep it as weight 0, orsuppress_zero_conversion_warning=Trueto skip the warning.A grid of true/false values is accepted: true becomes 1 and false becomes 0, which then becomes NaN without a warning (or stays 0 with
keep_zeros=True).A number below 0 or above 1 raises
ValueError, unlesssuppress_value_range_error=True.A grid that is NaN everywhere gives a warning, unless
suppress_all_nan_warning=True.
- Variables:
name (str) – What the mask is, e.g.
'tiv_lungspace_mask'.values (numpy.ndarray) – The mask as a 2D grid of shape (row, column), stored as floats.
modality (str) – The device the mask belongs to.
method (str | None) – Name of the method that made the mask.
- Raises:
ValueError – If
valuesis not a 2D grid, or holds a number below 0 or above 1 whilesuppress_value_range_erroris False.TypeError – If
valuescannot be stored as floats without changing them.
- Parameters:
name (str)
values (ndarray)
modality (str)
method (str | None)
keep_zeros (dataclasses.InitVar[bool])
suppress_value_range_error (dataclasses.InitVar[bool])
suppress_zero_conversion_warning (dataclasses.InitVar[bool])
suppress_all_nan_warning (dataclasses.InitVar[bool])
Methods
Return the mask and its descriptive fields as a dictionary.
Attributes
Return the count of pixels that are not NaN, weight 0 included.
Return the number of rows and columns, in that order.
- keep_zeros: dataclasses.InitVar[bool] = False#
- suppress_all_nan_warning: dataclasses.InitVar[bool] = False#
- suppress_value_range_error: dataclasses.InitVar[bool] = False#
- suppress_zero_conversion_warning: dataclasses.InitVar[bool] = False#