-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchild_initialize_vista.m
114 lines (88 loc) · 3.25 KB
/
child_initialize_vista.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
105
106
107
108
109
110
111
112
113
function child_initialize_vista(sub_num, data_dir)
% This script was taken from Winawer lab wiki, and is being modified to use
% with child fMRI data.
% Set session and anatomy paths
% Modify: sess_path, subj_id
%% Step 4: Build t1_class file to build a 3d surface (mesh)
anat_dir = strcat('/mnt/diskArray/projects/LMB_Analysis/',sub_num, '/mrVista_Anat');
cd(anat_dir)
ribbonfile = strcat('/mnt/diskArray/projects/LMB_Analysis/', sub_num, '/mrVista_Anat/ribbon.mgz');
outfile = strcat('/mnt/diskArray/projects/LMB_Analysis/',sub_num, '/mrVista_Anat/t1_class.nii.gz');
if exist(fullfile(anat_dir,'t1_acpc.nii.gz'),'file') == 2
alignTo = strcat('/mnt/diskArray/projects/LMB_Analysis/',sub_num, '/mrVista_Anat/t1_acpc.nii.gz');
avg = 0;
else
alignTo = strcat('/mnt/diskArray/projects/LMB_Analysis/',sub_num, '/mrVista_Anat/t1_acpc_avg.nii.gz');
avg = 1;
end
fillWithCSF = true;
fs_ribbon2itk(ribbonfile, outfile, fillWithCSF, alignTo)
%% Since we don't have an inplane, we will use the mean functional as an inplane
cd(data_dir)
data=[];
% parentdir = '/home/ekubota/Desktop/raw';
% datadir = '/home/ekubota/Desktop/raw/';
%functionals = dir('run01.nii.gz');
% for ii = 1:length(functionals)
% im = readFileNifti(fullfile(data_dir,sprintf(functionals(ii).name,ii)));
% data = cat(4,data,im.data);
% movefile(fullfile(datadir,sprintf('run%02d.nii',ii)),fullfile(datadir,'RAW',sprintf('run%02d.nii',ii)));
% end
temp = dir('*.nii');
nruns = size(temp);
nruns = nruns(1);
im = readFileNifti(fullfile(data_dir,temp(1).name));
data = cat(4,data,im.data);
datam = nanmean(data,4); %data(:,:,:,1);
im.data = datam;
im.pixdim = im.pixdim; %(1:3);
im.dim = im.dim(1:3);
im.ndim = 3;
im.descrip = 'firstfMRI';
im.fname = fullfile(data_dir,'Inplane.nii');
writeFileNifti(im)
%% To initialize the vista session
% Set session path
cd(data_dir)
% Created path to anatomy to identify T1W file (not the most elegant, but
% functional for how the data is arranged)
% Set paths to scan files
%Specify functionals
for ii = 1:nruns
epi_file{ii} = fullfile(temp(ii).name);
assert(exist(epi_file{ii},'file')>0)
end
% epi_file{2} = fullfile(temp(2).name);
% assert(exist(epi_file{2},'file')>0)
% Specify INPLANE file
inplane_file = fullfile('Inplane.nii');
assert(exist(inplane_file, 'file')>0)
% Specify 3DAnatomy file -EK need to change path
%cd(anat_path)
if avg == 1
anat_file = fullfile(anat_dir,'t1_acpc_avg.nii.gz');
assert(exist(anat_file, 'file')>0)
else
anat_file = fullfile(anat_dir,'t1_acpc.nii.gz');
assert(exist(anat_file, 'file')>0)
end
%cd(sess_path)
% Create params structure
% Generate the expected generic params structure
params = mrInitDefaultParams;
% And insert the required parameters:
params.inplane = inplane_file;
params.functionals = epi_file;
params.sessionDir = data_dir;
hold = {};
for n = 1:nruns
hold = [hold, strcat('run0',int2str(n))];
end
% Set optional parameters (specific to experiment)
% Modify: params.subject, params.annotations (e.g. 'FacesHouses' 'Words' 'Bars' 'Bars' 'OnOff'), params.coParams.nCycles (for each scan, can be determined from par files)
params.subject = sub_num;
params.annotations = hold;
% Specify some optional parameters
params.vAnatomy = anat_file;
% Go!
ok = mrInit(params);