问题
I am trying to use MRI brain imaging data for deep learning model. Currently my image has 4 dimensions as shown below but I would like to retain only the T1c modality of the MRI image because my model input should only be 1 channel 3D MRIs (T1c).
I did try to make use of the Nibabel package as shown below
import nibabel as nib
ff = glob.glob('imagesTr\*')
a = nib.load(ff[0])
a.shape
This returns the below output
I am also pasting the header info of 'a'
From this, which of the dimension is used to identify the MRI modality like (T1,T2, T1c, FLAIR etc)? and How can I retain only T1c?. Can you please help?
回答1:
First you need to identify the order of the images stores in the 4th dimensions.
Probably the header will help:
print(a.header)
Next, to keep only 1 modality you can use this:
data = a.get_fdata()
modality_1 = data[:,:,:,0]
EDIT 1:
Based on the website of the challenge:
All BraTS multimodal scans are available as NIfTI files (.nii.gz) and describe a) native (T1) and b) post-contrast T1-weighted (T1Gd), c) T2-weighted (T2), and d) T2 Fluid Attenuated Inversion Recovery (FLAIR) volumes, and were acquired with different clinical protocols and various scanners from multiple (n=19) institutions, mentioned as data contributors here.
and
The provided data are distributed after their pre-processing, i.e. co-registered to the same anatomical template, interpolated to the same resolution (1 mm^3) and skull-stripped.
So the header will not help in this case (equal dimensions for all modalities due to preprocessing).
If you are looking for the post-contrast T1-weighted (T1Gd) images then it's the 2nd dimension so use:
data = a.get_fdata()
modality_1 = data[:,:,:,1]
Additionally, we can visualize the each 3D volume (data[:,:,:,0], data[:,:,:,1],data[:,:,:,2], data[:,:,:,3])
and verify my statement.
See here: https://gofile.io/?c=fhoZTu
回答2:
It's not possible to identify the type of MRI from the Nifti header. You would need the original DICOM images to derive this type of information.
You can, however, visually check your images and compare the contrast/colour of the white matter, grey matter and ventricles to figure out if your image is T1, T2, FLAIR, etc. For instance in a T1-image you would expect darker grey matter, lighter white matter and black CSF. In a T2 image you would expect lighter grey matter, darker white matter and white CSF. A FLAIR is the same as T2 but with 'inverted' CSF. See some example brain images here: https://casemed.case.edu/clerkships/neurology/Web%20Neurorad/t1t2flairbrain.jpg
That being said, you seem to have a 4-dimensional image, which suggests some sort of time series, so I would assume your data is DTI or fMRI or something like it.
It's also not possible to transform one type of MRI into another, so if your data set is not already T1, then there is no way to use it in a model that expects clean T1 data.
I would strongly encourage you to learn more about MRI and the type of data you are working with. Otherwise it will be impossible to interpret your results.
来源:https://stackoverflow.com/questions/56698087/how-to-remove-a-modality-from-mri-image-python-nibabel