-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths_ophNIFTI.m
58 lines (40 loc) · 1.25 KB
/
s_ophNIFTI.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
%% s_ophNIFTI
%
% Illustrates pulling down a MAT file, converting it to NIfTI, and
% uploading it back to the acquisition.
%
% VISTA-TEACH, ophthalmology
%
% Wandell, 2021
%% Get the project information
st = scitran('stanfordlabs');
project = st.lookup('scitran/VBR-CF');
%% Find one of the acquisitions for a subject
subjects = project.subjects();
thisSubject = stSelect(subjects,'label','patient_02','nocell',true);
thisSession = thisSubject.sessions.findFirst();
thisAcquisition = thisSession.acquisitions.findOne('label=OCT');
thisAcquisition.label
%% Download the data from Flywheel
basedir = fullfile(ophRootPath,'local','data');
chdir(basedir);
thisFile = stSelect(thisAcquisition.files,'name','OCT2.mat','nocell',true);
thisFile.download('OCT2.mat');
%% Load the data and create a NIFTI file
load('OCT2','d5');
ni = niftiCreate;
% A subset of the data for speed
ni.data = d5(:,:,(45:75));
ni.ndim = ndims(ni.data);
ni.dim = size(ni.data);
% These are the dimensions in microns.
ni.pixdim = [3.125 3.125 7];
% Write the file
ni.descrip = sprintf('OCT2 data');
ni.xyz_units = 'um';
ni.time_units = '';
fname = 'OCT2-VBR.nii';
niftiWrite(ni,fname);
%% Upload the NIfTI to the acquisition
thisAcquisition.uploadFile(fname);
%% END