-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdenoisedConcatVista.m
64 lines (56 loc) · 2.4 KB
/
denoisedConcatVista.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
% Get subject numbers for everyone in LMB_Analysis folder
root_dir = '/mnt/diskArray/projects/LMB_Analysis';
sub_list = {'NLR_JB420','NLR_JB423','NLR_HB275','NLR_KB218',...
'NLR_GB310','NLR_197_BK','NLR_GB355','NLR_GB387'};
% Get list of subjects we have fmri data for
fMRI_subs = [];
for ii = 1:length(sub_list)
sub_dir = strcat(root_dir, '/',sub_list{ii});
cd(sub_dir)
if exist(fullfile(root_dir,sub_list{ii},'mrVista_Anat'), 'dir')
if ~exist(fullfile(root_dir,sub_list{ii},'denoisedConcatVista'),'dir') %make folder to put all denoised data into
mkdir 'denoisedConcatVista'
end
if ~exist(fullfile(root_dir,sub_list{ii},'denoisedConcatVista','Stimuli'),'dir') %make folder for parfiles
cd 'denoisedConcatVista'
mkdir 'Stimuli'
end
fMRI_subs = [fMRI_subs {sub_list{ii}}];
end
end
% For each subject (si = subject index)
for si = 1:length(fMRI_subs)
% Get the visit dates
visit_dir = strcat(root_dir,'/',fMRI_subs{si});
visit_dates = HCP_autoDir(visit_dir);
% For each visit (vi = visit index)
for vi = 1:length(visit_dates)
% Check to see if the vist date folder is actually a date
a = visit_dates{vi};
sizeA = size(a);
sizeA = sizeA(2);
if sizeA == 8
sessDir = strcat(root_dir,'/',fMRI_subs{si},'/',visit_dates{vi});
cd(sessDir)
if (exist(fullfile(sessDir,'fmri'),'dir') == 7)
cd fmri
nruns = dir('run*.nii');
nruns = size(nruns);
nruns = nruns(1);
% set paths for old and new data
dataDir = strcat(sessDir, '/fmri');
concatDir = strcat(root_dir,'/',fMRI_subs{si},'/denoisedConcatVista');
% copy data into concatinated folder
for ii = 1:nruns
filename = fullfile(dataDir, sprintf('run%02.0f.nii',ii));
ni = niftiRead(filename);
newfilename = fullfile(concatDir, sprintf('run%02.0f.nii',(vi*10+ii)));
ni.fname = newfilename;
niftiWrite(ni)
end
% copy parfiles over
copyfile(fullfile(dataDir,'Stimuli'),fullfile(concatDir,'Stimuli'))
end
end
end
end