lyman.utils.image_to_matrix¶
-
lyman.utils.
image_to_matrix
(img, mask_img, use=None)[source]¶ Extract image data from voxels using segmentation mask.
- Parameters
- imgnifti image
3D or 4D nifti image with data to extract.
- mask_img3D nifti image
Image defining the voxels where data will be extracted. Must be 3D.
- useint, list of ints, or None, optional
Value(s) within
mask_img
to use. IfNone
, use all nonzero.
- Returns
- datan_vox or n_tp, n_vox numpy array
Array with voxel data from
img
matching the mask. Note that when the input image is a time series, the time dimension is the first axis of the matrix (corresponding to the structure of a GLM).