千图成像python_如何从MRI图像中删除模态-Python Nibabel

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?

解决方案

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值