Home > fmri > utils > todd_z.m

todd_z

PURPOSE ^

todd_z.m

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 todd_z.m

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % todd_z.m
0002 
0003 LOAD_DATA = 0;
0004 sub_ids = ...
0005     {'02jun00CW', ...
0006      '03aug00GG', ...
0007      '10aug00EH', ...
0008      '11aug00WS', ...
0009      '14jun00OMG', ...
0010      '15jun00JE', ...
0011      '15jun00SN', ...
0012      '17jul00RC', ...
0013      '18jul00CS'}; 
0014 
0015 series_map.episodic = [ ...
0016     3 6; ...
0017     2 5; ...
0018     2 6; ...
0019     3 6; ...
0020     3 6; ...
0021     2 5; ...
0022     3 6; ...
0023     2 5; ...
0024     3 6];
0025 
0026 series_map.semantic = [ ...
0027     1 4; ...
0028     3 6; ...
0029     3 6; ...
0030     1 4; ...
0031     1 4; ...
0032     3 6; ...
0033     1 4; ...
0034     3 6; ...
0035     1 4];
0036 
0037 task_vols = [16:34 50:68 84:102 118:136];
0038 rest_vols = [1:15 35:49 69:83 103:117];
0039 
0040 nseries = 6;
0041 
0042 if LOAD_DATA 
0043   load('/home02/janata/data/todd/extracted_data.mat')
0044 end
0045 
0046 %
0047 % Create large masks that specify which data to pull from where
0048 %
0049 
0050 nvol = size(y,2);
0051 nvol_per_series = nvol/nseries;
0052 nsub = length(sub_ids);
0053 
0054 episodic_offsets = (series_map.episodic-1)*nvol_per_series;
0055 semantic_offsets = (series_map.semantic-1)*nvol_per_series;
0056   
0057 episodic_task_mask = zeros(nvol, nsub)+NaN;
0058 episodic_rest_mask = zeros(nvol, nsub)+NaN;
0059 semantic_task_mask = zeros(nvol, nsub)+NaN;
0060 semantic_rest_mask = zeros(nvol, nsub)+NaN;
0061 
0062 for isub = 1:nsub
0063   idx = task_vols'*ones(1,2) + ones(length(task_vols),1) * episodic_offsets(isub,:);
0064   episodic_task_mask(idx(:),isub) = 1;
0065 
0066   idx = rest_vols'*ones(1,2) + ones(length(rest_vols),1) * episodic_offsets(isub,:);
0067   episodic_rest_mask(idx(:),isub) = 1;
0068 
0069   idx = task_vols'*ones(1,2) + ones(length(task_vols),1) * semantic_offsets(isub,:);
0070   semantic_task_mask(idx(:),isub) = 1;
0071 
0072   idx = rest_vols'*ones(1,2) + ones(length(rest_vols),1) * semantic_offsets(isub,:);
0073   semantic_rest_mask(idx(:),isub) = 1;
0074 end
0075 
0076 %
0077 % Compute z-scores
0078 %
0079 
0080 nvox = size(y,1);
0081 
0082 for ivox = 1:nvox
0083   tmp = squeeze(y(ivox,:,:));
0084   mean_y(ivox,:) = nanmean(tmp.* (episodic_task_mask ...
0085                   | episodic_rest_mask ...
0086                   | semantic_task_mask ... 
0087                   | semantic_rest_mask));
0088   
0089   std_y(ivox,:) = nanstd(tmp.* (episodic_task_mask ...
0090                 | episodic_rest_mask ...
0091                 | semantic_task_mask ... 
0092                 | semantic_rest_mask));
0093   
0094 end
0095 
0096 z = zeros(size(y));
0097 
0098 for isub = 1:nsub
0099   z(:,:,isub) = z(:,:,isub) + (y(:,:,isub) - (mean_y(:,isub)* ...
0100                           ones(1,nvol))) ./ (std_y(:,isub)*ones(1,nvol));
0101   
0102 end
0103 
0104 voxmean = squeeze(mean(y));
0105 
0106 epi_task_mean_z = nanmean(voxmean .* episodic_task_mask);
0107 epi_task_std_z = nanstd(voxmean .* episodic_task_mask);
0108 
0109 epi_rest_mean_z = nanmean(voxmean .* episodic_rest_mask);
0110 epi_rest_std_z = nanstd(voxmean .* episodic_rest_mask);
0111 
0112 sem_task_mean_z = nanmean(voxmean .* semantic_task_mask);
0113 sem_task_std_z = nanstd(voxmean .* semantic_task_mask);
0114 
0115 sem_rest_mean_z = nanmean(voxmean .* semantic_rest_mask);
0116 sem_rest_std_z = nanstd(voxmean .* semantic_rest_mask);
0117 
0118 
0119 datamat = [epi_task_mean_z' epi_rest_mean_z' sem_task_mean_z' ...
0120        sem_rest_mean_z'];
0121 
0122 task_str = {'epi\_task','epi\_rest','sem\_task','sem\_rest'};

Generated on Wed 20-Mar-2019 04:00:51 by m2html © 2003