CerebNet.data_loader.data_utils¶
- CerebNet.data_loader.data_utils.create_weight_mask2d(label_map, class_wise_weights, max_edge_weight=5)[source]¶
Function to create weighted mask - with median frequency balancing and edge-weighting.
- Parameters:
- label_map
np.ndarray
A 2D array representing the label map.
- class_wise_weights
np.ndarray
A 1D array where each element is the weight corresponding to a class in the label map.
- max_edge_weight
float
, default=5 The maximum weight to be applied at the edges in the label map to emphasize boundaries.
- label_map
- CerebNet.data_loader.data_utils.filter_blank_slices_thick(data_dict, img_key='img', lbl_key='label', threshold=10)[source]¶
Function to filter blank slices from the volume using the label volume.
- Parameters:
- CerebNet.data_loader.data_utils.get_aseg_cereb_mask(aseg_map)[source]¶
Get a boolean mask of the cerebellum from a segmentation image.
- Parameters:
- aseg_map
np.ndarray
A segmentation image.
- aseg_map
- Returns:
np.ndarray
A boolean mask of the cerebellum.
- CerebNet.data_loader.data_utils.map_prediction_sagittal2full(prediction_sag, lbl_type)[source]¶
Function to remap the prediction on the sagittal network to full label space used by coronal and axial networks.
- Parameters:
- prediction_sag
np.ndarray
Sagittal prediction (labels).
- lbl_type
str
Type of label.
- prediction_sag
- Returns:
np.ndarray
Remapped prediction.
- CerebNet.data_loader.data_utils.map_sag2label(lbl_data, label_type='cereb_subseg')[source]¶
Mapping right ids to left and relabeling.
- Parameters:
- lbl_data
np.ndarray
An array of label data.
- label_type
str
, default=”cereb_subseg” A string identifier for the type of labels to map to.
- lbl_data
- Returns:
np.ndarray
The remapped label array with continuous labels.
- CerebNet.data_loader.data_utils.slice_lia2ras(plane, data, /, thick_slices=False)[source]¶
Maps the data from LIA to RAS orientation.
- Parameters:
- plane
Plane
The slicing direction (usually moved into batch dimension).
- data
np.ndarray
The data array of shape [plane, Channels, H, W].
- thick_slices
bool
,default
=False
Whether the channels are thick slices and should also be flipped.
- plane
- Returns:
np.ndarray
Data reoriented from LIA to RAS of [plane, Channels, H, W] (plane: ‘sagittal’ or ‘coronal’) or [plane, Channels, W, H] (plane: ‘axial’).
- CerebNet.data_loader.data_utils.slice_ras2lia(plane, data, /, thick_slices=False)[source]¶
Maps the data from RAS to LIA orientation.
- Parameters:
- plane
Plane
The slicing direction (usually moved into batch dimension).
- data
np.ndarray
The data array of shape [plane, Channels, H, W].
- thick_slices
bool
, default=False Whether the channels are thick slices and should also be flipped.
- plane
- Returns:
np.ndarray
Data reoriented from RAS to LIA of [plane, Channels, H, W] (plane: ‘sagittal’ or ‘coronal’) or [plane, Channels, W, H] (plane: ‘axial’). The dtype of the array is the same as data.
- CerebNet.data_loader.data_utils.transform_axial(vol, coronal2axial=True)[source]¶
Function to transform volume into Axial axis and back.
- Parameters:
- vol
np.ndarray
Image volume to transform.
- coronal2axial
bool
,default
=True
If True (default), transforms from coronal to axial. If False, transforms from axial to coronal.
- vol
- Returns:
np.ndarray
Transformed image volume.
- CerebNet.data_loader.data_utils.transform_axial2sagittal(vol, axial2sagittal=True)[source]¶
Transform a volume into the Sagittal axis and back.
- Parameters:
- vol
np.ndarray
The image volume to transform.
- axial2sagittal
bool
, default=True If True (default), transforms from axial to sagittal. If False, transforms from sagittal to axial.
- vol
- Returns:
np.ndarray
The transformed image volume.
- CerebNet.data_loader.data_utils.transform_coronal(vol, axial2coronal=True)[source]¶
Transform a volume into the coronal axis and back.
- Parameters:
- vol
np.ndarray
The image volume to transform.
- axial2coronal
bool
, default=True If True (default), transforms from axial to coronal. If False, transforms from coronal to axial.
- vol
- Returns:
np.ndarray
The transformed image volume.
- CerebNet.data_loader.data_utils.transform_sagittal(vol, coronal2sagittal=True)[source]¶
Transform a volume into the Sagittal axis and back.
- Parameters:
- vol
np.ndarray
The image volume to transform.
- coronal2sagittal
bool
,default
=True
If True (default), transforms from coronal to sagittal. If False, transforms from sagittal to coronal.
- vol
- Returns:
np.ndarray
The transformed image volume.