MRI roi图像合并

发布时间 2023-11-17 14:00:42作者: BuCha

笔记来源:MRI roi的图像合并 dpabi小工具_哔哩哔哩_bilibili

1. 如果几个图像的维度不一致,需要先进行reslice

1)如何看图像的维度

以软件MRIcron为例, window→information,如红框所示,如果几幅图像的维度不一致,则需要进行重采样,length[96 96 72]是图像采集了72层,每一层的分辨率是96*96,即每一层采样的体素数量是96*96,spacing[2 2 2]是指体素大小 (spm 的display也能查看)

 

 

 

 

 2)如何对图像进行重采样,借助工具箱dpabi

dpabi →utilities→image reslicer

 

 

 2. 如何用代码实现 imgCalculator

 1 clc,clear
 2 %% setup the information
 3 wpath = pwd;
 4 filename = ['roi*.nii'];
 5 subjf = dir(fullfile(wpth,filename));
 6 output = zeros(96,96, 72);
 7 
 8 % sum
 9 for i  = 1:length(subjf)
10 hdr_par = spm_vol(fullfile(wpath,subjf(i).name));%read the img
11 vol_par = spm_read_vols(hdr_par);% data for the img
12 output = output+vol_par;
13 end
14 
15 outputfilename = 'SumImg.nii';
16 hdr_par.fname = fullfile(wpath,outputfilename);
17 spm_write_vol(hdr_par,output);
18 
19 output = output/length(subjf);
20 outputfilename = 'MeanImg.nii';
21 hdr_par.fname = fullfile(wpath,outputfilename);
22 spm_write_vol(hdr_par,output);