omni.masks#
Functions for image mask creation.
Functions
|
Compute a weight mask for a given brain mask. |
|
Generates a mask identifying noise and signal voxels. |
|
Linear Discriminant Analysis for time series data. |
|
Make regression mask. |
- omni.masks.compute_weight_mask(brain: Nifti1Image, brain_mask: Nifti1Image, eye_mask: Optional[Nifti1Image] = None, dilation_size: int = 15) Nifti1Image [source]#
Compute a weight mask for a given brain mask.
This function computes a weight mask for a given brain mask. The weight mask is computed by dilating the brain mask by dilation_size and then finding the non-brain portions through the use of otsu’s method + thresholding + morphology
The weight mask is weighted by the number of voxels in brain vs. non-brain.
- Parameters:
- brain: nib.Nifti1Image
Brain image.
- brain_mask: nib.Nifti1Image
Brain mask.
- eye_mask: nib.Nifti1Image, optional
Eye mask.
- dilation_size: int
Size to dilate brain mask by.
- Returns:
- nib.Nifti1Image
Weight mask.
- omni.masks.generate_noise_mask(img: Nifti1Image, mask: Nifti1Image, size: int = 2, iterations: int = 20, sigma: float = 3) Tuple[ndarray, ndarray] [source]#
Generates a mask identifying noise and signal voxels.
- Parameters:
- img: nib.Nifti1Image
Image to construct noise mask on.
- mask: nib.Nifti1Image
Mask outlining a prior guess between noise/signal voxels.
- size: int
Size to dilate noise mask by.
- iterations: int
Number of iterations to run LDA.
- sigma: float
Size of smoothing kernel for weight mask.
- Returns:
- np.ndarray
Noise mask.
- np.ndarray
Signal weight mask.
- omni.masks.lda(X: ndarray, labels: ndarray) ndarray [source]#
Linear Discriminant Analysis for time series data.
- Parameters:
- X: np.ndarray
The data in a numpy array. Where rows are samples, cols are features.
- labels: np.ndarray
Labels for data. Corresponds to samples.
- Returns:
- np.ndarray
Projected data.
- omni.masks.make_regression_mask(output_prefix: str, epi: str, anat_bet_mask: str, anat_weight_mask: str, affine: str, iaffine: str, warp: str, iwarp: str, noise_mask_dilation_size: int = 2, noise_mask_iterations: int = 20, noise_mask_sigma: float = 2)[source]#
Make regression mask.
- Parameters:
- output_prefix: str
Set prefix for output files.
- epi: str
EPI file to apply LDA.
- anat_bet_mask: str
Anatomical brain mask.
- anat_weight_mask: str
Anatomical weight mask.
- affine: str
Affine transform (anat to func) (afni).
- iaffine: str
Inverse affine transform (func to anat) (afni).
- warp: str
Forward warp (anat to func).
- iwarp: str
Inverse warp (func to anat).
- noise_mask_dilation_size: int
Size to dilate noise mask by.
- noise_mask_iterations: int
Number of iterations to run LDA.
- noise_mask_sigma: float
Size of smoothing kernel for weight mask.
- Returns:
- str
Regression mask.