source: misclib/fmri_corr.m @ 69

Last change on this file since 69 was 69, checked in by tjniskan, 11 years ago
  • Added possibility to add the fMRI paradigm into the "View voxel

time-series" figure

  • Added global normalization routines for fMRI analysis
  • Minor fixes here and there

M misclib/fmri_analysis.m
M misclib/fmri_corr.m
M an2_revision.m
M an2_data_read.m
M aedes.m
M plugins/basic_fmri_analysis.m
M plugins/resting_state_fc.m

File size: 1.8 KB
RevLine 
[50]1function corrmap = fmri_corr(data,seed)
2
3corrmap = [];
4
5if ischar(data)
6  data=an2_data_read(data);
7  data = data.FTDATA;
8end
9
[69]10% Get mean time-series from seed ROIs
[50]11seed_struct = l_Roi2seed(data,seed);
12
13
14% Calculate Pearson correlation coefficients -------------
15data_sz = ones(1,4);
16data_sz(1:ndims(data)) = size(data);
17
18for kk = 1:length(seed_struct)
19 
20  % Allocate space for ccc
21  ccc = zeros(data_sz(1:3));
22 
23  T = length(seed_struct(kk).data);
24  std_seed = std(seed_struct(kk).data,1);
25  norm_seed = seed_struct(kk).data-mean(seed_struct(kk).data);
26  seed_plane = reshape(reshape(repmat(norm_seed,...
27        [data_sz(1),data_sz(2)]),data_sz(1)*T,[]).',...
28        data_sz(1),data_sz(2),[]);
29 
30  % Loop over in-plane slices
31  for ii=1:data_sz(3)
32        tmp_data = double(squeeze(data(:,:,ii,:)));
33       
34        std_data = std(tmp_data,1,3);
35       
36        ccc(:,:,ii) = ((1/T)*sum(seed_plane.*tmp_data,3))./(std_data.*std_seed);
37  end
38 
39  % Make sure that there are no Infs or nans ...
40  ccc(find(isnan(ccc))) = 0;
41  ccc(find(isinf(ccc))) = 0;
42 
43  % Fisher's z-transform to make values normally distributed
44  zf = ccc;
45  zf = 0.5*log((1+ccc)./(1-ccc));
46 
47  % Calculate Z-scores
48  zscore = zf./(1/sqrt(T-3));
49 
50  % Construct output structure
51  corrmap(kk).ccc = ccc;
52  corrmap(kk).zf = zf;
53  corrmap(kk).zscore = zscore;
54  corrmap(kk).label = seed_struct(kk).label;
55end
56
57% Subfunctions -----------------------------------
58function seed_struct = l_Roi2seed(data,ROI)
[69]59% Thus subfunction extracts mean seed time-series from ROI voxels
60%
[50]61
62seed_struct = [];
63
64if isstruct(ROI)
65  for ii=1:length(ROI)
66        ind = repmat(ROI(ii).voxels{1}(:,:,:,1),[1 1 1 size(data,4)]);
67        seed_struct(ii).data = mean(reshape(double(data(ind)),[],size(data,4)));
68        seed_struct(ii).label = ROI(ii).label;
69  end
70else
71  tmp = ROI(:).';
72  seed_struct(1).data = double(tmp);
[53]73  seed_struct(1).label = 'custom seed';
[50]74end
75
76
77
Note: See TracBrowser for help on using the repository browser.

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