怎么把Nifti文件转换成Numpy数组? [英] How to convert Nifti file to Numpy array?
本文介绍了怎么把Nifti文件转换成Numpy数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Nifti文件(.ii.gz)中有3D数组,我想将其保存为3D numpy数组.我使用Nibabel将Numpy转换为Nifti1.我可以相反吗?
I have 3D array in Nifti file (.ii.gz) and I want to save it as a 3D numpy array. I used Nibabel to convert Numpy to Nifti1. Can I do the opposite?
推荐答案
来自 nipy
import numpy as np
import nibabel as nib
img = nib.load(example_filename)
a = np.array(img.dataobj)
这篇关于怎么把Nifti文件转换成Numpy数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文