mask#

class arte.types.mask.AnnularMask(frameShape, maskRadius=None, maskCenter=None, inRadius=0)#

Bases: CircularMask

Inheritance of CircularMask class to provide an annular mask

Added inRadius parameter, radius of central obstruction. Default inRadius values is 0 with AnnularMask converging to CircularMask

Methods

asTransmissionValue()

Mask as a transmission mask: 1 for non-masked elements, 0 for masked elements.

center()

Y, X coordinates of the mask center

fromMaskedArray(maskedArray)

Creates a CircularMask roughly corresponding to the mask of a masked array

mask()

Boolean mask of the mask

radius()

Radius of the mask

shape()

Array shape

as_masked_array

from_masked_array

inRadius

in_mask_indices

regionOfInterest

static fromMaskedArray(maskedArray)#

Creates a CircularMask roughly corresponding to the mask of a masked array

Returns a CircularMask object having radius and center guessed from the passed mask using ImageMoments centroid and semiAxes as default.

Important note: the created CircularMask object using “ImageMoments” is not guaranteed to have the same set of valid points of the passed mask, but it is included in the passed mask, i.e. all the valid points of the created mask are also valid points of the passed masked array. For the other methods this last property is not guaranteed.

Other valid circle estimation methods are: - “RANSAC” : circle fitting using RANSAC algorithm on Canny edge detection - “COG” : circle fitting using Center of gravity of the mask - “correlation” : circle fitting using correlation of the mask with a disk template

Parameters:
  • maskedArray (MaskedArray) – a masked array with a circular mask

  • method (string) – method for circle estimation. Default is “ImageMoments”

Returns:

circular_mask – a circular mask included in the mask of maskedArray

Return type:

CircularMask

inRadius()#
class arte.types.mask.BaseMask(mask_array)#

Bases: object

Methods

mask()

Boolean mask of the mask

shape()

Array shape

as_masked_array

from_masked_array

as_masked_array()#
static from_masked_array(numpy_masked_array)#
mask()#

Boolean mask of the mask

Returns:

mask – mask of the pupil. Array is True outside the pupil, and False inside the pupil

Return type:

boolean array

shape()#

Array shape

Returns:

shape – shape of the mask array

Return type:

list (2,)

class arte.types.mask.CircularMask(frameShape, maskRadius=None, maskCenter=None)#

Bases: BaseMask

Represent a circular mask

A array representing a circular pupil. Frame shape, pupil radius and center can be specified.

Use mask method to access the mask as boolean mask (e.g. to be used in a masked_array object) with False values where the frame is not masked (i.e. within the pupil) and True values outside

Use asTransmissionValue method to acces the mask as transmission mask, i.e. 1 within the pupil and 0 outside. Fractional transmission for edge pixels is not implemented

If a masked_array having a circular mask is available, the static method fromMaskedArray can be used to create a CircularMask object having the same shape of the masked array and the same pupil center and radius

Parameters:
  • frameShape (tuple (2,)) – shape of the returned array

  • maskRadius (real) – pupil radius in pixel

  • maskCenter (list (2,) or array) – Y-X coordinates of the pupil center in pixel

Methods

asTransmissionValue()

Mask as a transmission mask: 1 for non-masked elements, 0 for masked elements.

center()

Y, X coordinates of the mask center

fromMaskedArray(maskedArray[, method])

Creates a CircularMask roughly corresponding to the mask of a masked array

mask()

Boolean mask of the mask

radius()

Radius of the mask

shape()

Array shape

as_masked_array

from_masked_array

in_mask_indices

regionOfInterest

FITTING_METHOD_CENTER_OF_GRAVITY = 'COG'#
FITTING_METHOD_CORRELATION = 'correlation'#
FITTING_METHOD_IMAGE_MOMENTS = 'ImageMoments'#
FITTING_METHOD_RANSAC = 'RANSAC'#
asTransmissionValue()#

Mask as a transmission mask: 1 for non-masked elements, 0 for masked elements.

Returns:

transmission_value – transmission mask as a numpy array with dtype int

Return type:

ndarray[int]

center()#

Y, X coordinates of the mask center

Returns:

center – Y, X coordinate of the mask center in the array reference system

Return type:

array of shape (2,)

static fromMaskedArray(maskedArray, method='ImageMoments', **keywords)#

Creates a CircularMask roughly corresponding to the mask of a masked array

Returns a CircularMask object having radius and center guessed from the passed mask using ImageMoments centroid and semiAxes as default.

Important note: the created CircularMask object using “ImageMoments” is not guaranteed to have the same set of valid points of the passed mask, but it is included in the passed mask, i.e. all the valid points of the created mask are also valid points of the passed masked array. For the other methods this last property is not guaranteed.

Other valid circle estimation methods are: - “RANSAC” : circle fitting using RANSAC algorithm on Canny edge detection - “COG” : circle fitting using Center of gravity of the mask - “correlation” : circle fitting using correlation of the mask with a disk template

Parameters:
  • maskedArray (MaskedArray) – a masked array with a circular mask

  • method (string) – method for circle estimation. Default is “ImageMoments”

Returns:

circular_mask – a circular mask included in the mask of maskedArray

Return type:

CircularMask

in_mask_indices()#
radius()#

Radius of the mask

Returns:

radius – mask radius in pixel

Return type:

real

regionOfInterest()#