网络编程
位置:首页>> 网络编程>> Python编程>> .img/.hdr格式转.nii格式的操作

.img/.hdr格式转.nii格式的操作

作者:咸鱼酱  发布时间:2023-08-25 04:56:14 

标签:.img,.hdr,.nii

MATLAB转格式,需要使用spm package(https://github.com/neurodebian/spm12).


%%img2nii.m--------------------------------------------
%Script to convert hdr/img files to nii.
%This script uses SPM function, so you need to install SPM5 or later.
%Kiyotaka Nemoto 05-Nov-2014

%select files
f = spm_select(Inf,'img$','Select img files to be converted');

%convert img files to nii
for i=1:size(f,1)
input = deblank(f(i,:));
[pathstr,fname,ext] = fileparts(input);
output = strcat(fname,'.nii');
V=spm_vol(input);
ima=spm_read_vols(V);
V.fname=output;
spm_write_vol(V,ima);
end

附加一下volume data是如何转surface data的吧…

wb_command -volume-to-surface-mapping ArticParcels_Smithetal.nii /home/murphyhuang/tmp/nii/HCP_fMRI/Q1-Q6_R440.L.flat.32k_fs_LR.surf.gii outL.shape.gii -trilinear

补充知识:数据读取——(.img .hdr)

1、定义

该图像格式含有两部分:一个是图像 ‘.img ',另一个是图像头文件 '.hdr',该文件记录了图像的信息,如图像尺寸、波段数、数据类型和大小端等。如果缺少头文件,将无法对图像进行读取,因此头文件十分重要。

2、读取

使用Matlab中NifTi包读取。

eg:

img=load_nii(‘D:\a01_101_bmask.hdr')

.img/.hdr格式转.nii格式的操作

来源:https://blog.csdn.net/Lyrassongs/article/details/88544903

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com