GESeries.NiiBase
GESeries.NiiBase(nii, orientation=('L', 'P', 'S'))Wraps a NIfTI image with orientation-aware loading, display, and I/O helpers.
Attributes¶
| Name | Description |
|---|---|
affine | The affine matrix of the NIfTI image. |
brain_mask | The brain mask as a NiiBase, loaded if present else created on access. |
nii | |
nii_path | |
orientation |
Methods¶
| Name | Description |
|---|---|
| apply_mask | Return the image data with voxels outside mask set to NaN. |
| display | Display the image, optionally masked, via plotting.images.display_images. |
| get_brain_mask | Find (or optionally create) the brain mask NIfTI next to this image. |
| images | Return the image data array, oriented per orientation or display_plane. |
| overlay_on_T1 | Overlay this image on a T1 image, resampling and masking as needed. |
| resample_self_to | Return a new NiiBase with this image resampled onto target_nii’s grid. |
| save | Save the NIfTI image to output_path as a Nifti1Image. |
| with_new_data | Return 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¶
| Name | Type | Description | Default |
|---|---|---|---|
| create | bool | If True, run HD-BET brain extraction when no mask is found. | False |
| mask_keyword | str | Substring identifying the brain mask NIfTI file. | '_bet.nii' |
| **extract_kwargs | Forwarded to utils.images.extract_brain. | {} |
Returns¶
| Name | Type | Description |
|---|---|---|
| NiiBase | The brain mask wrapped as a NiiBase. |
Raises¶
| Name | Type | Description |
|---|---|---|
| ValueError | If this NIfTI was not loaded from a path (no folder to search). | |
| FileNotFoundError | If 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.