stimupy.utils.masks#
Functions#
Average pixel value in each target region of stimulus |
|
Average values of pixels in image, per target region in integer mask |
|
Isolate all image values/pixels, per target region specified in integer mask |
|
Isolate only image pixels specified by a binary mask |
- avg_target_values(stim, mask_key='target_mask', f_average=<function median>)[source]#
Average pixel value in each target region of stimulus
- Parameters:
- Returns:
each entry in the list is the average value of pixels in target region, index in the list is the integer index in the mask
- Return type:
See also
- avg_img_values(image, mask, f_average=<function median>)[source]#
Average values of pixels in image, per target region in integer mask
Values are calculated as means or medians, depending on the mode.
- Parameters:
image (2D numpy array) – 2D numpy array containing pixel values of the image
mask (2D numpy array) – 2D numpy array of same size as image. Each target patch has an integer value. Each pixel inside this patch has this integer value. Patches do not need to be continuous.
f_average (function, default=numpy.median) – How to average/summarise the pixels in each target region
- Returns:
each entry in the list is the average value of pixels in target region, index in the list is the integer index in the mask
- Return type:
See also
- all_img_values(img, mask)[source]#
Isolate all image values/pixels, per target region specified in integer mask
- Parameters:
img (numpy.ndarray) – Image-array of pixel values to be masked
mask (numpy.ndarray) – Array of same size as img. Each region-of-interest in mask is represented by an integer index. Each pixel inside this patch has this integer value. Patches do not need to be contiguous.
- Returns:
Each image/element of the list is a numpy.ndarray representing an image. There is one image for each target patch in the integer mask. In each image all values are set to NaN except the ones corresponding to the target values of the respective target patch.
- Return type:
list[numpy.arrays]
See also
- img_values(img, mask)[source]#
Isolate only image pixels specified by a binary mask
- Parameters:
img (numpy.ndarray) – Image-array of pixel values to be masked
mask (numpy.ndarray) – Array of same size as img. All non-zero pixels/values are treated as ones in a binary bit mask.
- Returns:
numpy.ndarray of same size as img. All bits corresponding to zero bits in the mask are set to NaN.
- Return type: