-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCONN_demo.m
62 lines (46 loc) · 2.15 KB
/
CONN_demo.m
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
clear all;
base_dir='D:\Reading_FC';
% get subject IDs
sub_ids = {dir([base_dir '/sub-047EPKL*']).name};
global CONN_gui; CONN_gui.usehighres=true;
clear batch;
% initiate batch
NSUBJECTS=length(sub_ids);
batch.filename=fullfile(base_dir,'conn_demo.mat');
batch.Setup.isnew=1;
%batch.parallel.N=height(sub_df);
% batch.parallel.N=5;
% batch.parallel.profile='Slurm computer cluster';
batch.Setup.nsubjects=NSUBJECTS;
batch.Setup.RT=2.34;
batch.Setup.functionals=repmat({{}},[NSUBJECTS,1]);
for nsub = 1:length(sub_ids)
sub_id=sub_ids{nsub};
anat_file=[base_dir '/' sub_id '/ses-1/anat/' sub_id '_ses-1_T1w.nii.gz'];
func_files=dir([base_dir '/' sub_id '/ses-2/func/' sub_id '_ses-2_task-read_run-*.nii.gz']);
timing_files=dir([base_dir '/' sub_id '/ses-2/func/' sub_id '_ses-2_task-read_run-*_events.tsv']);
conditions={'W','PH'};
for nses=1:length(func_files)
batch.Setup.functionals{nsub}{nses}{1}=[func_files(nses).folder '/' func_files(nses).name];
timing_file=[timing_files(nses).folder '/' timing_files(nses).name];
% read timing file in array
timing = readtable(timing_file,"FileType","text",'Delimiter', '\t');
% set up timing files for each run
for ncond=1:length(conditions)
batch.Setup.conditions.names{ncond}=conditions{ncond};
batch.Setup.conditions.onsets{ncond}{nsub}{nses}=table2array(timing(strcmp(timing.trial_type, conditions{ncond}),'onset'));
batch.Setup.conditions.durations{ncond}{nsub}{nses}=table2array(timing(strcmp(timing.trial_type,conditions{ncond}),'duration'));
end
end
batch.Setup.structurals{nsub}=anat_file;
end
% setting up group level covariates
batch.Setup.subjects.effect_names{1}='dysexia';
batch.Setup.subjects.effect_names{2}='spd';
batch.Setup.subjects.effect_names{3}='td';
batch.Setup.subjects.effects{1}=[ones(1,20) zeros(1,38)];
batch.Setup.subjects.effects{2}=[zeros(1,20) ones(1,16) zeros(1,22)];
batch.Setup.subjects.effects{3}=[zeros(1,36) ones(1,22)];
batch.Setup.overwrite=0; % not overwrite
batch.Setup.done=0; % not run Setup
conn_batch(batch)