I public a mail concerning about how to resample a mask when defining a ROI.
The script is attached at the end of this topic and should save as "rest_reSample3D.m".
It is just used to do with mask, and no warranty I could give, although Bui verified the script and it worked.
The way of using this resample script is to put it in REST's directory and
Result Mask=rest_reSample3D(Original Mask, You Desired Dimension);
Examples could be reviewed in the following mail.
Bui Ngoc Dung sent to Xiao-Wei: Many thanks to you, this toolbox is powerful tool and it helps me alot. Best regards, Bui On Tue, Aug 5, 2008 at 11:34 AM, Xiao-Wei Song wrote: Dear Dr. Bui, REST could do what you want and REST would give you a coefficient matrix result. All you need to do is to define all your ROIs in the ROI list. Another function of ROI list is that it could be used to extract the mean time course of the ROI and this may help you extract the covariables such as the mean time course of the white matter or the mean time course of the cerebrospinal fluid(CSF) and so on. Best regards, Xiaowei 2008/8/5 Bui Ngoc Dung Dear Dr. Song, I would like to analysis functional connectivity, especially calculate the correlation coefficient matrix between some regions in the brain. As the manual, if I choose ROI wise (fc between two or more ROIs), REST will calculate the correlation coefficient matrix Does REST support this function now? If yes, please help me to do it. Thank you for your kindly help. Best regards, Bui On Fri, Aug 1, 2008 at 3:15 PM, Bui Ngoc Dung wrote: Thank you very much, I have already tested on my data and this has done perfectly Best regards, Bui On Fri, Aug 1, 2008 at 12:10 PM, Xiao-Wei Song wrote: Dear Bui, mask=rest_readfile('YOUR MASK FILE PATH'); mask=mask>0; mask_DownSampled=rest_reSample3D(mask, [53,63,46]); rest_writefile(mask_DownSampled, 'FULL PATH WHERE YOU WANT TO SAVE YOUR RESAMPLED MASK', [53,63,46],[YOUR VOXEL SIZE], [YOUR ORIGIN], 'double'); Sorry for losing one line code. The line colored should work with mask because mask only have 0 or 1. I have not tested this code. Maybe you could help. Xiaowei 2008/8/1 Xiao-Wei Song Dear Bui, "mask_DownSampled=mask(1:3:181, 1:3:217, 1:3:181);" means get one value every three values. This is down sampled very simply because it happened to be the 1/3 size of the original size. In your case, you should not only change the write function because the key is the resample code not the save code. I just wrote a resample script (should be placed in the REST dir) to do the job. So the work maybe as: mask=rest_readfile('YOUR MASK FILE PATH'); mask_DownSampled=rest_reSample3D(mask, [53,63,46]); rest_writefile(mask_DownSampled, 'FULL PATH WHERE YOU WANT TO SAVE YOUR RESAMPLED MASK', [53,63,46],[YOUR VOXEL SIZE], [YOUR ORIGIN], 'double'); Hope it work! Xiaowei 2008/7/31 Bui Ngoc Dung Thank you very much, this has done pefectly as your help. But I have preprocessed image with dimension [53, 63, 46], voxel size is (3,3,3). Does this affected by the mask dimension [61,73,61]? I modify this code as rest_writefile(mask_ DownSampled, 'FULL PATH WHERE YOU WANT TO SAVE YOUR RESAMPLED MASK', [53, 63, 46], [3,3,3], [27,32,23], 'double'); But the ROI mask image is not correct. Can I keep the mask with dimension [61, 73, 61] or I must change to [53, 63, 46]? Best regards, D. Bui On Thu, Jul 31, 2008 at 4:46 PM, Xiao-Wei Song wrote: Dear Dr. Bui, After SliceViewer showed the Brodmann map, choose your interesting BA area and then click "Save2Mask" on the bottom of the SliceViewer, then it would save your selected area to a mask file whose format is ANALYZE 7.5. Since the saved mask is 181*217*181, you may need manually resample the mask file to your EPI images. This step has not been implemented yet. This operation could be very simple when the following codes would work in MATLAB: mask=rest_readfile('YOUR MASK FILE PATH'); mask_DownSampled=mask(1:3:181, 1:3:217, 1:3:181); rest_writefile(mask_DownSampled, 'FULL PATH WHERE YOU WANT TO SAVE YOUR RESAMPLED MASK', [61, 73, 61], [3,3,3], [31,43,25], 'double'); The codes above would resample the Bordmann map from 181*217*181 to 61*73*61. When save the mask, you have to set its dimension as [61,73,61] and its Voxel Size as 3*3*3, and its origin is (31,43,25). "double" means the the data format would use double precision. There would be other means to resample, the codes above maybe the easiest I ever used. Best regards, Xiaowei 2008/7/31 Bui Ngoc Dung Dear Dr. Song, Please help me in functional connectivity analysis! When I click to 'Voxel wise' button, it appear ROI popup as a manual. In Add ROI, I choose ROI mask -> (3) Extracted a brain area from Brodmann template and click Next, it appear slice viewer I choose Brodmann template, How I can set the ROI??? Thank you very much, Best regards, D. Buid
function Result=rest_reSample3D(A3DBrain, ANewDimension)
%Resample 3D matrix, such as in REST mask resampling operation
% Copyright(c) 2007~2010
% State Key Laboratory of Cognitive Neuroscience and Learning in Beijing Normal University
% Written by Xiao-Wei Song
% Mail to Author: Xiaowei Song
% Version=1.0 % Release=20080801
theFactor = ANewDimension./size(A3DBrain);
theResampleStruct = makeresampler(theInterpolant, thePadMethod);
theTransFormStruct= maketform('affine', [theFactor(1) 0 0 ; 0 theFactor(2) 0; 0 0 theFactor(3);0 0 0]);
Result = tformarray(A3DBrain,theTransFormStruct,theResampleStruct,[1 2 3],[1 2 3],ANewDimension,,);