lyman.utils.matrix_to_image¶
-
lyman.utils.
matrix_to_image
(data, mask_img, template_img=None, use=None)[source]¶ Convert a vector or matrix of data into a nibabel image.
- Parameters
- datan_vox or n_tp, n_vox numpy array
Data matrix; if a time series, time should be on the first axis.
- mask_img3D nifti image
Image defining which voxels in the output should be filled with
data
. Must be 3D.- template_imgnifti image
If present, the affine matrix and Nifti header will be assigned to the output image; otherwise, these are taken from
mask_img
.- useint, list of ints, or None, optional
Value(s) within
mask_img
to use. IfNone
, use all nonzero.
- Returns
- imgnifti image
Image with voxel data from
data
where the mask is nonzero, with affine and header data from either themask_img
or, if present, thetemplate_img
.