/
conn_master.m
104 lines (83 loc) · 3.57 KB
/
conn_master.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
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
function conn_generated()
% Batch setup file for CONN
% Created 11/14/2016
% Revised 2/5/17, 5/2/17, 5/21/17, 5/16/20
clear all;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Key Script Parameters %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TR=1.25; %Repetition time
[dirlist]=textread('SubjectList.txt','%s'); %text file with subject directories in whitespace-delimited strings
FUNCFILT='.*RSFMRI.*\.nii\.gz'; %Defines format of functional files in regexp, which will be used to select files
STRFILT='co.*\.nii\.gz'; %Defines format of structural files, again in regexp
NSUBJECTS=length(dirlist); %Number of subjects, automatically derived from length of file list
% Prepare batch structure
clear batch;
batch.filename=fullfile(pwd,'conn_generated.mat'); % New conn_*.mat experiment name
% Parallelization
batch.parallel.N=6; %Set number of parallel threads
batch.parallel.profile=5; %Set parallelization to Background process (Unix/Mac)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% CONN Setup Preprocessing %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% BASIC
batch.Setup.isnew=1;
batch.Setup.nsubjects=NSUBJECTS;
batch.Setup.RT=TR;
batch.Setup.acquisitiontype=1; %assumes continuous acquisition of functional volumes
%batch.Setup.analyses=[1,2,3,4]; %default includes all analyses; see conn_batch.m for details
batch.Setup.analysisunits=1; %1=percent signal change (PSC), 2=raw units
batch.Setup.outputfiles=[1,1,1,1,1,1]; %outputs .nii volumes for confound-corrected timeseries, r-maps, z-maps, rex maps
batch.Setup.localcopy=1; %saves func and struct volumes to local .../data/BIDS folder
%% STRUCTURAL AND FUNCTIONAL
% select functional and structural volumes according to prespecified format, in prespecified subjects
for i=1:NSUBJECTS
rootdir=dirlist{i};
batch.Setup.functionals{i}{1}=spm_select('FPListRec',[rootdir '/func'],FUNCFILT);
batch.Setup.structurals{i}=spm_select('FPListRec',[rootdir '/anat'],STRFILT);
end
%% PREPROCESSING
batch.Setup.preprocessing.steps={'functional_realign&unwarp','functional_center','functional_art','functional_segment&normalize_direct','structural_center','strucutral_segment&normalize','functional_smooth'}
batch.Setup.preprocessing.fwhm=8;
%batch.Setup.done=1;
%% CONDITIONS
% specify conditions; for this analysis, the single condition 'rest' is specified for all subjects
batch.Setup.conditions.names={'rest'};
for i=1:NSUBJECTS
batch.Setup.conditions.onsets{1}{i}{1}=[0];
batch.Setup.conditions.durations{1}{i}{1}=[inf];
end
%% FIRST-LEVEL COVARIATES
% Nothing specified here, thus CONN will use default motion covariates from ART
%% SECOND-LEVEL COVARIATES
% Specifies patient and control populations
% RUN!
batch.Setup.done=1;
%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% CONN Denoising %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%
batch.Denoising.filter=[0.008,0.09]; %Specify band-pass filter
batch.Denoising.done=1;
%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% CONN Analysis %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%
% Define ROI-to-ROI and seed-to-voxel analyses
batch.Analysis.type=3;
batch.Analysis.done=1;
% Define voxel-to-voxel analyses (ARCHAICH as of v17d)
% batch.vvAnalysis.measures=['group-PCA','group-ICA','IntrinsicConnectivity'];
% batch.vvAnalysis.done=1;
conn_batch(batch);
%% The following launches the CONN gui and loads the .mat file to explore results
% conn
% conn('load',fullfile(pwd,'conn_zdt.mat));
% conn gui_results
quit;