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:
segnp.ndarray

The aparc+aseg (or aseg) segmentation.

vox_volfloat

The volume of a voxel in mm^3.

Returns:
segnp.ndarray

The cleaned segmentation.

masknp.ndarray

The brain mask, see create_mask.

FastSurferCNN.reduce_to_aseg.create_mask(aseg_data, dnum, enum)[source]

Create dilated mask (works for all data orientations, LIA/etc).

Parameters:
aseg_dataint np.ndarray

The input segmentation data.

dnumint

The number of iterations for the dilation operation.

enumint

The number of iterations for the erosion operation.

Returns:
bool np.ndarray same shape as aseg_data

Returns 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_datanumpy.ndarray

The input segmentation data, an aseg or an aparc+aseg.

Returns:
flip_datanumpy.ndarray

The segmentation data with flipped WM labels.

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:
segnp.ndarray

The segmentation.

masknp.ndarray

The mask, voxels > 0 are inside.

vox_volfloat

The volume of a voxel in mm^3.

keeplist of int, tuple of int, default=()

Labels to keep outside the mask.

Returns:
np.ndarray

The segmentation without labels outside the mask.

FastSurferCNN.reduce_to_aseg.options_parse()[source]

Command line option parser.

Returns:
options

Object 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_insegnp.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.

Returns:
data_insegnp.ndarray, torch.Tensor

The reduced segmentation.

FastSurferCNN.reduce_to_aseg.reduce_to_aseg_and_save(seg, seg_affine, seg_header, filename=None)[source]

Convenience function for reduce_to_aseg plus saving.