Home > rest_20090422 > rest_DivideMeanWithinMask.m

rest_DivideMeanWithinMask

PURPOSE ^

Compute the mean within the mask and divide ReHo brain by the mean

SYNOPSIS ^

function rest_DivideMeanWithinMask(ASrcReHo, ADstReHo, AMaskFilename)

DESCRIPTION ^

 Compute the mean within the mask and divide ReHo brain by the mean
format: rest_DivideMeanWithinMask(ASrcReHo, ADstReHo, AMaskFilename)
 Input:
 ASrcReHo, string, a ReHo brain file (i.e RehoMap or RehoMap.{hdr/img})
 AMaskFile, string, a mask file (i.e mask.{hdr/img} or mask.mat)
 Output:
 ADstReHo, string, a ReHo brain file (i.e mRehoMap, no {hdr/img})
------------------------------------------------------------------------------------------------------------------------------
    Copyright(c) 2007~2010
    State Key Laboratory of Cognitive Neuroscience and Learning in Beijing Normal University
    Written by Xiao-Wei Song 
    http://resting-fmri.sourceforge.net
------------------------------------------------------------------------------------------------------------------------------
 Dawnwei.Song@gmail.com
 20070504
     Mail to Authors:  <a href="Dawnwei.Song@gmail.com">Xiaowei Song</a>; <a href="ycg.yan@gmail.com">Chaogan Yan</a> 
    Version=1.3;
    Release=20090321;
   Revised by YAN Chao-Gan, 080610. NIFTI compatible
   Last Revised by YAN Chao-Gan, 090321. Result data will be saved in the format 'single'.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

rest_DivideMeanWithinMask.m

SOURCE CODE ^

0001 function rest_DivideMeanWithinMask(ASrcReHo, ADstReHo, AMaskFilename)
0002 % Compute the mean within the mask and divide ReHo brain by the mean
0003 %format: rest_DivideMeanWithinMask(ASrcReHo, ADstReHo, AMaskFilename)
0004 % Input:
0005 % ASrcReHo, string, a ReHo brain file (i.e RehoMap or RehoMap.{hdr/img})
0006 % AMaskFile, string, a mask file (i.e mask.{hdr/img} or mask.mat)
0007 % Output:
0008 % ADstReHo, string, a ReHo brain file (i.e mRehoMap, no {hdr/img})
0009 %------------------------------------------------------------------------------------------------------------------------------
0010 %    Copyright(c) 2007~2010
0011 %    State Key Laboratory of Cognitive Neuroscience and Learning in Beijing Normal University
0012 %    Written by Xiao-Wei Song
0013 %    http://resting-fmri.sourceforge.net
0014 %------------------------------------------------------------------------------------------------------------------------------
0015 % Dawnwei.Song@gmail.com
0016 % 20070504
0017 %     Mail to Authors:  <a href="Dawnwei.Song@gmail.com">Xiaowei Song</a>; <a href="ycg.yan@gmail.com">Chaogan Yan</a>
0018 %    Version=1.3;
0019 %    Release=20090321;
0020 %   Revised by YAN Chao-Gan, 080610. NIFTI compatible
0021 %   Last Revised by YAN Chao-Gan, 090321. Result data will be saved in the format 'single'.
0022 
0023     if ~(nargin==3) error(' Error using ==> DivideMaskMean. 3 arguments wanted.'); end
0024 
0025     %Load the original ReHo map file
0026     [brainMap,vsize, Header]=rest_readfile(ASrcReHo);
0027     M = size(brainMap,1); N = size(brainMap,2); O = size(brainMap,3);
0028     isize = [M N O]; vsize =vsize';
0029     mask=rest_loadmask(M, N, O, AMaskFilename);
0030 
0031     %Calcute the mean and divide ReHo map by the mean
0032     pos=find(mask);
0033     masked_brainMap=zeros(size(brainMap,1),size(brainMap,2),size(brainMap,3));
0034     masked_brainMap(pos)=brainMap(pos);
0035     mean_value=reshape(masked_brainMap, size(masked_brainMap,1)*size(masked_brainMap,2)*size(masked_brainMap,3), 1);
0036     mean_value=double(sum(mean_value)) / double(length(pos));
0037     ResultReHoMap=brainMap./mean_value;
0038     rest_writefile(single(ResultReHoMap),ADstReHo,isize,vsize,Header, 'single'); %Revised by YAN Chao-Gan, 090321. Result data will be stored in 'single' format. %'double');
0039 
0040

Generated on Wed 29-Apr-2009 01:06:38 by m2html © 2005