Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

GESeries.NiiBase

GESeries.NiiBase(nii, orientation=('L', 'P', 'S'))

Wraps a NIfTI image with orientation-aware loading, display, and I/O helpers.

Attributes

NameDescription
affineThe affine matrix of the NIfTI image.
brain_maskThe brain mask as a NiiBase, loaded if present else created on access.
nii
nii_path
orientation

Methods

NameDescription
apply_maskReturn the image data with voxels outside mask set to NaN.
displayDisplay the image, optionally masked, via plotting.images.display_images.
get_brain_maskFind (or optionally create) the brain mask NIfTI next to this image.
imagesReturn the image data array, oriented per orientation or display_plane.
overlay_on_T1Overlay this image on a T1 image, resampling and masking as needed.
resample_self_toReturn a new NiiBase with this image resampled onto target_nii’s grid.
saveSave the NIfTI image to output_path as a Nifti1Image.
with_new_dataReturn a new NiiBase wrapping new_data, keeping this image’s header/affine.

apply_mask

GESeries.NiiBase.apply_mask(mask)

Return the image data with voxels outside mask set to NaN.

display

GESeries.NiiBase.display(
    orientation=None,
    display_plane=None,
    mask=None,
    **kwargs,
)

Display the image, optionally masked, via plotting.images.display_images.

Displays an interactive image-grid widget and returns nothing.

get_brain_mask

GESeries.NiiBase.get_brain_mask(
    create=False,
    mask_keyword='_bet.nii',
    **extract_kwargs,
)

Find (or optionally create) the brain mask NIfTI next to this image.

Looks for a brain mask NIfTI (matching mask_keyword) in the same folder as self.nii_path. If none is found and create is True, a mask is generated with HD-BET via :func:utils.images.extract_brain and loaded. The mask is returned as its own :class:NiiBase.

Parameters

NameTypeDescriptionDefault
createboolIf True, run HD-BET brain extraction when no mask is found.False
mask_keywordstrSubstring identifying the brain mask NIfTI file.'_bet.nii'
**extract_kwargsForwarded to utils.images.extract_brain.{}

Returns

NameTypeDescription
NiiBaseThe brain mask wrapped as a NiiBase.

Raises

NameTypeDescription
ValueErrorIf this NIfTI was not loaded from a path (no folder to search).
FileNotFoundErrorIf no mask is found and create is False.

images

GESeries.NiiBase.images(
    orientation=None,
    display_plane=None,
    caching=True,
    **kwargs,
)

Return the image data array, oriented per orientation or display_plane.

overlay_on_T1

GESeries.NiiBase.overlay_on_T1(
    t1,
    resample_kwargs=None,
    orientation=None,
    display_plane=None,
    mask=None,
    **kwargs,
)

Overlay this image on a T1 image, resampling and masking as needed.

resample_self_to

GESeries.NiiBase.resample_self_to(target_nii, **kwargs)

Return a new NiiBase with this image resampled onto target_nii’s grid.

save

GESeries.NiiBase.save(output_path)

Save the NIfTI image to output_path as a Nifti1Image.

with_new_data

GESeries.NiiBase.with_new_data(new_data, new_affine=None)

Return a new NiiBase wrapping new_data, keeping this image’s header/affine.