請移步修改版本:matlab,python讀取nii格式的醫(yī)學影像CT數(shù)據(jù) - 簡書
最近想用LiTS- Liver Tumor Segmentation Challenge的數(shù)據(jù)集做些事情,下載數(shù)據(jù)后發(fā)現(xiàn)是nii格式的,使用imageJ可以直接讀取并且顯示還可以進行3D渲染,但是要做處理的話還是需要用matlab或者python進行讀取。
matlab讀取方法:
使用Tools for NIfTI and ANALYZE image工具包,下載地址如下:
https://cn.mathworks.com/matlabcentral/fileexchange/8797-tools-for-nifti-and-analyze-image?s_tid=srchtitle
將工具包解壓到MATLAB的路徑下,解壓后的文件名字為NIfTI_20140122,其實可以是任意路徑,然后如如下語句即可讀取
addpath('D:\MATLAB\NIfTI_20140122')
info? = load_nii ('test-volume-68.nii');
image = info.img;
python讀取方法:
使用PyNIfTI包,官網地址如下:http://niftilib.sourceforge.net/pynifti/examples.html#loading-and-saving-nifti-files
使用命令即可安裝:
apt-get install python-nifti
使用代碼:
from nifti import*
nim=NiftiImage('example4d.nii')
print nim.filename