-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstep_16_roi_analysis_marsbar_native.m
More file actions
108 lines (72 loc) · 3.21 KB
/
step_16_roi_analysis_marsbar_native.m
File metadata and controls
108 lines (72 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
clear all
close all
clc
cf = pwd;
sub = {'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR'};
load('n_vox_native.mat');
con = 16;
marsbar('on');
for i = 1:numel(sub)
fprintf('-- Subject %d of %d, Sub: %s --\n',i,numel(sub),sub{i})
% Native space
results_dir_c = [cf '/POF_nifti/' sub{i}, filesep, 'Results_native'];
spm_file = fullfile(results_dir_c, 'spm.mat');
roi_folder = [cf '/POF_nifti/' sub{i}, filesep, 'ROIs_native'];
rois = dir(fullfile(roi_folder, 'TPJ_*.mat'));
rois = {rois(:).name}';
rois_c_vox = n_vox(i,:);
rois_c_vox = [rois_c_vox(1), rois_c_vox(3), rois_c_vox(2), rois_c_vox(4)];
for j = 1:numel(rois)
if rois_c_vox(j) == 0
data = NaN(1,con);
else
roi_c = rois{j};
roi_c = fullfile(roi_folder, roi_c);
% Load design
D = mardo(spm_file);
%D = autocorr(D, 'fmristat', 2); % to avoid the ReML error
% Load ROI into analysis
R = maroi(roi_c);
% Marsbar data object
Y = get_marsy(R, D, 'mean');
% Estimate design on data object
E = estimate(D, Y);
% e_specs = 1. row: session, 2. row: number of event; e_names = name of events
[e_specs, e_names] = event_specs(E);
% Extraction of event types/names
ets = event_types_named(E);
n_event_types = length(ets);
n_events = size(e_specs, 2);
dur = 0;
% extract % signal change, creates % per event
data = []; % empty data vector at start of each roi assessed
for e_s = 1:n_events
pct_ev(e_s) = event_signal(E, e_specs(:,e_s), dur);
data(e_s) = pct_ev(e_s);
end
end
%data_tot(j,1:con) = data;
roi_name_c = erase(rois{j}, '_roi.mat');
psc_rois.(roi_name_c)(i,:) = data;
end
end
save('psc_rois_native.mat', 'psc_rois');
%% Summary
%load('psc_rois_native.mat')
clearvars -except psc_rois sub
rois = fieldnames(psc_rois);
var_names = {'Global_Run1', 'Global_Run2', 'Scrambled_Run1', 'Scrambled_Run2', 'Places_Run1', 'Faces_Run1', 'Objects_Run1', 'Places_Run2', 'Faces_Run2', 'Objects_Run2', 'Places_Run3', 'Faces_Run3', 'Objects_Run3', 'Places_Run4', 'Faces_Run4', 'Objects_Run4'};
roi_results = 'ROI_Results_native';
mkdir(roi_results)
for i = 1:numel(rois)
data_c = psc_rois.(rois{i});
data_ct = data_c(:,[1,3, 2,4, 5,8,11,14, 6,9,12,15, 7,10,13,16]); % Global, Scrambled, Places, Faces, Objects
data_ct = array2table(data_ct, 'VariableNames', var_names);
psc_rois.(rois{i}) = data_ct;
writetable(data_ct, fullfile(roi_results, [rois{i} '.txt']));
end
roi_type = 'Baseline';
rois_baseline = rmfield(psc_rois, rois(find(cellfun(@isempty, strfind(rois, roi_type)))));
roi_type = 'Intact_Scrambled';
rois_intact_scrambled = rmfield(psc_rois, rois(find(cellfun(@isempty, strfind(rois, roi_type)))));
clearvars -except sub