Clarification regarding BraTS dataset

[亡魂溺海] 提交于 2020-06-01 05:08:17

问题


I downloaded the BraTS dataset for my summer project.

The dataset consisted of nii.gz files which I was able to open using nibabel library in Python. I used the following code:

import os
import numpy as np
import nibabel as nib
import matplotlib.pyplot as plat
examplefile=os.path.join("mydatapath","BraTS19_2013_5_1_flair.nii.gz")
img=nib.load(examplefile)
print(img)

this gave me the following output:

<class 'nibabel.nifti1.Nifti1Image'>
data shape (240, 240, 155)
affine: 
[[ -1.   0.   0.  -0.]
 [  0.  -1.   0. 239.]
 [  0.   0.   1.   0.]
 [  0.   0.   0.   1.]]
metadata:
<class 'nibabel.nifti1.Nifti1Header'> object, endian='<'
sizeof_hdr      : 348
data_type       : b''
db_name         : b''
extents         : 0
session_error   : 0
regular         : b'r'
dim_info        : 0
dim             : [  3 240 240 155   1   1   1   1]
intent_p1       : 0.0
intent_p2       : 0.0
intent_p3       : 0.0
intent_code     : none
datatype        : int16
bitpix          : 16
slice_start     : 0
pixdim          : [1. 1. 1. 1. 0. 0. 0. 0.]
vox_offset      : 0.0
scl_slope       : nan
scl_inter       : nan
slice_end       : 0
slice_code      : unknown
xyzt_units      : 2
cal_max         : 0.0
cal_min         : 0.0
slice_duration  : 0.0
toffset         : 0.0
glmax           : 0
glmin           : 0
descrip         : b''
aux_file        : b''
qform_code      : aligned
sform_code      : scanner
quatern_b       : 0.0
quatern_c       : 0.0
quatern_d       : 1.0
qoffset_x       : -0.0
qoffset_y       : 239.0
qoffset_z       : 0.0
srow_x          : [-1.  0.  0. -0.]
srow_y          : [  0.  -1.   0. 239.]
srow_z          : [0. 0. 1. 0.]
intent_name     : b''
magic           : b'n+1'

Can someone please walk me through this. I know it's a lot of data if someone could just tell me how to get the image from this data it would be wonderful.

Thank You.


回答1:


Have you looked at nibabel's documentation? It's excellent and has the answer to your question. https://nipy.org/nibabel/gettingstarted.html

In your question, you are looking at the header of the Nifti file. Use the following to get the image data as a numpy array.

import nibabel as nib
img = nib.load("image.nii.gz")
data = img.get_fdata()


来源:https://stackoverflow.com/questions/62100928/clarification-regarding-brats-dataset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!