如何从MRI图像中删除模态-Python Nibabel
我正在尝试将MRI脑成像数据用于深度学习模型.目前,我的图像具有4个维度,如下所示,但我想仅保留MRI图像的T1c模式,因为我的模型输入应仅为1通道3D MRI(T1c).
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).
我确实尝试使用Nibabel软件包,如下所示
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
这将返回以下输出
我还要粘贴'a'的标题信息
I am also pasting the header info of 'a'
由此,使用哪个维度来标识MRI模式(如T1,T2,T1c,FLAIR等)?以及如何仅保留T1c?你能帮忙吗?
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?
首先,您需要确定图像存储在第4维中的顺序.
First you need to identify the order of the images stores in the 4th dimensions.
标题可能会帮助您
print(a.header)
接下来,仅保留1种方式,您可以使用此方式:
Next, to keep only 1 modality you can use this:
data = a.get_fdata()
modality_1 = data[:,:,:,0]
基于挑战的网站:
所有BraTS多模式扫描都可以作为NIfTI文件(.nii.gz)和 描述a)原生(T1)和b)对比后T1加权(T1Gd),c) T2加权(T2)和d)T2流体衰减反演恢复 (FLAIR)卷,并通过不同的临床方案获得 以及来自多个(n = 19)机构的各种扫描仪,称为 数据贡献者在这里.
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.
和
所提供的数据在经过预处理(即 共同注册到相同的解剖模板,并内插到 相同的分辨率(1 mm ^ 3)并被头骨剥开.
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.
因此,标头在这种情况下将无济于事(由于预处理,所有模态的尺寸均相等).
如果您要查找对比度后的T1加权(T1Gd)图像,则它是第二维图像,请使用:
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]
此外,我们可以可视化每个3D体积(data[:,:,:,0], data[:,:,:,1],data[:,:,:,2], data[:,:,:,3])
并验证我的陈述.
Additionally, we can visualize the each 3D volume (data[:,:,:,0], data[:,:,:,1],data[:,:,:,2], data[:,:,:,3])
and verify my statement.