HypVINN.data_loader.data_utils

HypVINN.data_loader.data_utils.calculate_flip_orientation(iornt, base_ornt)[source]

Compute the flip orientation transform.

ornt[N, 1] is flip of axis N, where 1 means no flip and -1 means flip.

Parameters:
iorntnp.ndarray

Initial orientation.

base_orntnp.ndarray

Base orientation.

Returns:
new_iorntnp.ndarray

New orientation.

HypVINN.data_loader.data_utils.hypo_map_label2subseg(mapped_subseg)[source]

Perform look-up table mapping from label space to subseg space.

This function is used to perform a look-up table mapping from label space to subseg space.

Parameters:
mapped_subsegnpt.NDArray[int]

The input array in label space to be mapped to subseg space.

Returns:
npt.NDArray[int]

The mapped array in subseg space.

HypVINN.data_loader.data_utils.hypo_map_prediction_sagittal2full(prediction_sag)[source]

Remap the prediction on the sagittal network to full label space.

This function is used to remap the prediction on the sagittal network to the full label space used by the coronal and axial networks.

Parameters:
prediction_sagnpt.NDArray[int]

The sagittal prediction in label space to be remapped to full label space.

Returns:
npt.NDArray[int]

The remapped prediction in full label space.

HypVINN.data_loader.data_utils.hypo_map_subseg_2_fsseg(subseg, reverse=False)[source]

Remap HypVINN internal labels to FastSurfer Labels and vice versa.

This function is used to remap HypVINN internal labels to FastSurfer Labels and vice versa. If the reverse parameter is set to False, the function will map HypVINN labels to FastSurfer labels. If it is set to True, the function will map FastSurfer labels to HypVINN labels.

Parameters:
subsegnpt.NDArray[int]

The input array with HypVINN or FastSurfer labels to be remapped.

reversebool, default=False

A flag to determine the direction of the remapping. If False, remap HypVINN labels to FastSurfer labels. If True, remap FastSurfer labels to HypVINN labels.

Returns:
npt.NDArray[int]

The remapped array with FastSurfer or HypVINN labels.

HypVINN.data_loader.data_utils.reorient_img(img, ref_img)[source]

Reorient a Nibabel image based on the orientation of a reference nibabel image.

Parameters:
imgnibabel.Nifti1Image

Nibabel Image to reorient.

ref_imgnibabel.Nifti1Image

Reference orientation nibabel image.

Returns:
imgnibabel.Nifti1Image

Reoriented image.

HypVINN.data_loader.data_utils.rescale_image(img_data)[source]

Rescale the image data to the range [0, 255].

This function rescales the input image data to the range [0, 255].

Parameters:
img_datanp.ndarray

The image data to rescale.

Returns:
np.ndarray

The rescaled image data.

HypVINN.data_loader.data_utils.transform_axial2coronal(vol, axial2coronal=True)[source]

Transforms a volume into the coronal axis and back.

This function is used to transform a volume into the coronal axis and back. The transformation is done by moving the axes of the volume. If the axial2coronal parameter is set to True, the function will transform from axial to coronal. If it is set to False, the function will transform from coronal to axial.

Parameters:
volnp.ndarray

The image volume to transform.

axial2coronalbool, optional

A flag to determine the direction of the transformation. If True, transform from axial to coronal. If False, transform from coronal to axial. (Default: True).

Returns:
np.ndarray

The transformed volume.

HypVINN.data_loader.data_utils.transform_axial2sagittal(vol, axial2sagittal=True)[source]

Transforms a volume into the sagittal axis and back.

This function is used to transform a volume into the sagittal axis and back. The transformation is done by moving the axes of the volume. If the axial2sagittal parameter is set to True, the function will transform from axial to sagittal. If it is set to False, the function will transform from sagittal to axial.

Parameters:
volnp.ndarray

The image volume to transform.

axial2sagittalbool, default=True

A flag to determine the direction of the transformation. If True, transform from axial to sagittal. If False, transform from sagittal to axial. (Default: True).

Returns:
np.ndarray

The transformed volume.