-
Notifications
You must be signed in to change notification settings - Fork 16
/
conn_batchexample_qcplot.m
45 lines (38 loc) · 2.89 KB
/
conn_batchexample_qcplot.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
% creates QC-FC plots separately within each site (for a multi-site study)
DOREMOVE = false; % set to false to create QC plots based on all subjects, set to true to create QC plots based on a chosen subset of "valid" subjects
DOCOMBI = false; % computes QC-FC plots combining all sites
DOSITES = true; % computes QC-FC plots separately for each site
if DOREMOVE
foldername = 'validsubjects'; % output QA-report name (only needed if DOREMOVE=true)
groupvariable = 'QC_ValidSubjects'; % 2nd-level covariate name containing "valid subjects" group (only needed if DOREMOVE=true)
else
foldername = 'original'; % output QA-report name (only needed if DOREMOVE=false)
groupvariable = 'AllSubjects'; % 2nd-level covariate name containing "valid subjects" group (e.g. 'AllSubjects') (only needed if DOREMOVE=false)
end
sitevariable = '^SITE_'; %{'site_1','site_2','site_3'}; % 2nd-level covariate names containing SITES subject-groups (only needed if DOSITES=true)
QCvariables = {'QC_InvalidScans','QC_MeanMotion','QC_ProportionValidScans'}; % name of QC variables to use for QC-FC plots (only needed if DOSITES=true)
% conn load /myfolder/myproject.mat; % uncomment this line to load a different conn project (by default it works on the currently-open project)
% ------ END OF USER-DEFINED PARAMETERS --------
% ------ DO NOT MODIFY THE CODE BELOW --------
[filepath,filename,fileext] = fileparts(conn_projectmanager('projectfile')); % project folder
filepath = conn_fullfile(filepath,filename);
[covs,covs_names]=conn_module('get','l2covariates');
idx=find(ismember(covs_names,groupvariable)); valid=covs(:,idx);
if ischar(sitevariable), sitevariable=covs_names(find(cellfun('length',regexp(covs_names,sitevariable))>0)); end
if DOSITES, sites=[]; for k=1:numel(sitevariable), idx=find(ismember(covs_names,sitevariable{k})); sites=[sites, covs(:,idx)]; end; end
if DOCOMBI
conn_batch(...
'QA.plots', {'QA_DENOISE FC-QC'},...
'QA.l2covariates', QCvariables,...
'subjects', find(valid),...
'QA.foldername', fullfile(filepath,'results','qa',sprintf('QA_%s_all',foldername)) );
end
if DOSITES
for k=1:numel(sitevariable),
conn_batch(...
'QA.plots', {'QA_DENOISE FC-QC'},...
'QA.l2covariates', QCvariables,...
'subjects', find(sites(:,k)&valid),...
'QA.foldername', fullfile(filepath,'results','qa',sprintf('QA_%s_site%d',foldername,k)) );
end
end