FastSurferCNN.reduce_to_aseg¶
- FastSurferCNN.reduce_to_aseg.clean_segmentation(seg, vox_vol)[source]¶
Remove the labels outside the brain mask and flip disconnected white matter islands to their hemisphere.
- Parameters:
- seg
np.ndarray The aparc+aseg (or aseg) segmentation.
- vox_vol
float The volume of a voxel in mm^3.
- seg
- Returns:
- seg
np.ndarray The cleaned segmentation.
- mask
np.ndarray The brain mask, see create_mask.
- seg
- FastSurferCNN.reduce_to_aseg.create_mask(aseg_data, dnum, enum)[source]¶
Create dilated mask (works for all data orientations, LIA/etc).
- Parameters:
- aseg_data
intnp.ndarray The input segmentation data.
- dnum
int The number of iterations for the dilation operation.
- enum
int The number of iterations for the erosion operation.
- aseg_data
- Returns:
boolnp.ndarraysameshapeasaseg_dataReturns mask.
- FastSurferCNN.reduce_to_aseg.create_mask_and_save(seg, seg_affine, seg_header, filename=None)[source]¶
Convenience function for brainmask generation plus saving.
- FastSurferCNN.reduce_to_aseg.flip_wm_islands(aseg_data)[source]¶
Flip labels of disconnected white matter islands to the other hemisphere (works for all data orientations, LIA/etc).
- Parameters:
- aseg_data
numpy.ndarray The input segmentation data, an aseg or an aparc+aseg.
- aseg_data
- Returns:
- flip_data
numpy.ndarray The segmentation data with flipped WM labels.
- flip_data
- FastSurferCNN.reduce_to_aseg.mask_segmentation(seg, mask, vox_vol, keep=())[source]¶
Remove the labels outside the mask, except those in keep, and warn if this removes much.
Labels outside the brain mask are errors of the segmentation, e.g. tissue in the neck. They would end up outside brainmask.mgz, where the surface pipeline finds intensity 0 for them.
- Parameters:
- seg
np.ndarray The segmentation.
- mask
np.ndarray The mask, voxels > 0 are inside.
- vox_vol
float The volume of a voxel in mm^3.
- keep
listofint,tupleofint, default=() Labels to keep outside the mask.
- seg
- Returns:
np.ndarrayThe segmentation without labels outside the mask.
- FastSurferCNN.reduce_to_aseg.options_parse()[source]¶
Command line option parser.
- Returns:
optionsObject holding options.
- FastSurferCNN.reduce_to_aseg.reduce_to_aseg(data_inseg)[source]¶
Reduce the input segmentation to a simpler segmentation (for all data orientations, LIA/etc).
- Parameters:
- data_inseg
np.ndarray,torch.Tensor The input segmentation. This should be a 3D array where the value at each position represents the segmentation label for that position.
- data_inseg
- Returns:
- data_inseg
np.ndarray,torch.Tensor The reduced segmentation.
- data_inseg