编程语言
首页 > 编程语言> > 如何从MRI图像中删除模态 – Python Nibabel

如何从MRI图像中删除模态 – Python Nibabel

作者:互联网

我正在尝试将MRI脑成像数据用于深度学习模型.目前我的图像有4个尺寸,如下所示,但我只想保留MRI图像的T1c模态,因为我的模型输入应该只是1通道3D MRI(T1c).

我确实尝试使用Nibabel包,如下所示

import nibabel as nib 
ff = glob.glob('imagesTr\*')
a = nib.load(ff[0])
a.shape

这将返回以下输出

enter image description here

我也粘贴了’a’的标题信息

enter image description here

由此,哪个尺寸用于识别MRI模态,如(T1,T2,T1c,FLAIR等)?我怎样才能保留T1c?你能帮忙吗?

解决方法:

首先,您需要在第4维中识别图像存储的顺序.

标题可能会有所帮助:

print(a.header)

接下来,为了只保留1种形态,你可以使用它:

data = a.get_fdata()
modality_1 = data[:,:,:,0]

编辑1:

基于挑战的网站:

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.

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)图像,那么它是第二维,所以使用:

data = a.get_fdata()
modality_1 = data[:,:,:,1]

此外,我们可以可视化每个3D卷(数据[:,,:,0],数据[:,,:,1],数据[:,:,…,2],数据[:,:,: ,3])并验证我的陈述.

见:https://gofile.io/?c=fhoZTu

标签:python,python-3-x,image,image-processing,nibabel
来源: https://codeday.me/bug/20190928/1825505.html