source: misclib/fmri_global_norm.m @ 94

Last change on this file since 94 was 70, checked in by tjniskan, 11 years ago
  • Added the function performing global normalization that was not

included in the last commit...

A misclib/fmri_global_norm.m
M an2_revision.m

File size: 1.4 KB
Line 
1function data = fmri_global_norm(data)
2% FMRI_GLOBAL_NORM - Globally normalize fMRI data
3%   
4%
5% Synopsis:
6%
7% Description:
8%
9% Examples:
10%
11% See also:
12%     
13
14% This function is a part of Aedes - A graphical tool for analyzing
15% medical images
16%
17% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
18%
19% Department of Physics, Department of Neurobiology
20% University of Kuopio, FINLAND
21%
22% This program may be used under the terms of the GNU General Public
23% License version 2.0 as published by the Free Software Foundation
24% and appearing in the file LICENSE.TXT included in the packaging of
25% this program.
26%
27% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
30if nargin == 0
31  error('Too few input arguments!');
32elseif nargin > 1
33  error('Too many input arguments!');
34end
35
36if isstruct(data) && isfield(data,'FTDATA')
37  data = data.FTDATA;
38elseif ~isnumeric(data)
39  error('Invalid first input argument!')
40end
41
42% Return error if data is not 4D
43if ndims(data)~=4
44  error('fMRI data must be in a 4D matrix!')
45end
46 
47% Make sure that data is in either single or double form...
48if ~any(strcmpi(class(data),{'single','double'}))
49  data = single(data);
50end
51
52% Do global normalization
53for ii=1:size(data,4)
54  vol = data(:,:,:,ii);
55  data(:,:,:,ii) = vol-sum(vol(:))/numel(vol);
56end
57 
Note: See TracBrowser for help on using the repository browser.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008