Resample the mask

我们所用功能像和mask的size不同时,我们首先要对mask进行resample,令其和功能像的size相同才可以。

根据严超赣老师的回复,有三种方法:http://restfmri.net/forum/node/88,尝试过后决定使用第一种,即:http://restfmri.net/node/78,整理如下。

 

在第二个网址下载好代码之后,加入matlab路径,resample过程只需要用到如下四行代码(从两位师兄邮件通信中摘出来的,修改了一下注释):

 

mask=rest_readfile('mask file path'); mask=mask>0; mask_DownSampled=rest_reSample3D(original mask, [desired dimension]); rest_writefile(mask_DownSampled, 'output path', [disered dimention], [voxel size], [origin coordinate], 'data type');

 

其中original mask输入带有完整路径的mask文件名(我用的hdr),当然当下目录就不需要了;

voxel size和origin coordinate以及data type都可以用micro打开功能像看到,data type一般是'double';

另外origin coordinate要用结构体header.Origin给出,输入的时候在那里直接输入header即可。

 

后来补充:第三种也很好用,而且很快。第一种方法是自己写的代码,使用的应该是插值方法,但是在Resample某些模版(比如Craddock),的时候,使用第一种方法会造成添加不必要的边界,画出来的图会带很多边框。由于没找到在script的哪里改Resample方法,还是老老实实用工具SPM吧...虽然这里写的是SPM5,但是SPM12和5的这部分是一样一样的,完全可以照搬。

(3) use SPM5: a. Click "Coregister"
                     b. Click "New "Coreg: Reslice""
                     c. "Image Defining Space": choose one of your functional image. e.g. your normalized functional image or image after Detrend and Filter.
                     d. "Images to Reslice": choose the mask file or ROI definition file. e.g. BrainMask_05_61x73x61.img
                     e. "Reslice Options" -> "Interpolation": choose "Nearest neighbour"
                     f. Just click "Run". Then you will get the resmapled mask or ROI file with a surfix of "r".

原文地址:https://www.cnblogs.com/minks/p/4715357.html