mri_registration
ðŸ§
Register MRIs to a new space and create corresponding brain masks.
Authors: Simon M. Hofmann | Hannah S. Heinrichs
Years: 2023-2024
get_mni_template
ðŸ§
get_mni_template(
low_res: bool = True,
reorient: bool = True,
prune_mode: str | None = "max",
norm: tuple[int | float, int | float] = (0, 1),
mask: bool = False,
original_template: bool = True,
as_nii: bool = False,
) -> ndarray | Nifti1Image
Get the MNI template.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
low_res |
bool
|
True: 2 mm; False: 1 mm isotropic resolution. |
True
|
reorient |
bool
|
Whether to reorient the template to the project orientation space. |
True
|
prune_mode |
str | None
|
If not use |
'max'
|
norm |
tuple[int | float, int | float]
|
Whether to normalize image values between 0-1. |
(0, 1)
|
mask |
bool
|
Whether to return a binary mask only. |
False
|
original_template |
bool
|
With |
True
|
as_nii |
bool
|
Whether to return template as NIfTI image, else it will be a numpy array. |
False
|
Returns:
Type | Description |
---|---|
ndarray | Nifti1Image
|
MNI template image |
Source code in src/xai4mri/dataloader/mri_registration.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
is_mni
ðŸ§
is_mni(img: Nifti1Image | ndarray) -> bool
Check if the given image is in any MNI space.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img |
Nifti1Image | ndarray
|
MR image. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the image is in MNI space, else False |
Source code in src/xai4mri/dataloader/mri_registration.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
register_to_mni
ðŸ§
register_to_mni(
moving_mri: Nifti1Image,
resolution: int,
type_of_transform: str,
save_path_mni: str | Path | None = None,
verbose: bool = False,
) -> Nifti1Image
Register a NIfTI image to the MNI template.
Note, if there are issues with file handling,
functions of antspyx
, which is used for registration (ants.registration
),
cannot handle *.mgz
| *.mgh
files,
use xai4mri.dataloader.mri_dataloader.mgz2nifti()
for conversion.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
moving_mri |
Nifti1Image
|
Input image to be registered to MNI space. |
required |
resolution |
int
|
Either 1 or 2 mm isotropic resolution. |
required |
type_of_transform |
str
|
Either linear registration: 'Rigid' OR non-linear warping: 'SyN'. |
required |
save_path_mni |
str | Path | None
|
Path to registered MRI. If provided, save or fetch MRI in MNI space. |
None
|
verbose |
bool
|
Show output of the registration process. |
False
|
Returns:
Type | Description |
---|---|
Nifti1Image
|
MRI in MNI space (NIfTI) |
Source code in src/xai4mri/dataloader/mri_registration.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
|