-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathE200_load_data.m
More file actions
executable file
·160 lines (150 loc) · 6.77 KB
/
Copy pathE200_load_data.m
File metadata and controls
executable file
·160 lines (150 loc) · 6.77 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
function data = E200_load_data(pathstr, varargin)
% E200_LOAD_DATA Convert original, binary data into a new file format and load
% into memory
% DATA = E200_LOAD_DATA(FILENAME) converts FILENAME
% into the new file format and loads it into memory.
%
% Inputs:
% FILENAME: Relative or absolute location of
% a directory, scan, or filenames.mat file
%
% Outputs:
% DATA: E200 data structure
% Get valid parts of filename to use
if nargin > 1
expstr = varargin{1};
else
expstr = 'E200';
end
[dir_beg, dir_mid, filename, data_source_type] = ...
get_valid_filename(pathstr, expstr);
% Full path to file to load
loadpath = fullfile(dir_beg, dir_mid, filename);
% Split filename into root, extension
[~, filename_rt, filename_ext] = fileparts(filename);
filename_final = [filename_rt '_processed' filename_ext];
% Processed file info
% NOTE: looks like filesep could be used here to eliminate some code
processed_file_dir = fullfile(dir_beg, dir_mid);
if isunix
processed_file_dir = regexprep(processed_file_dir, ...
'nas/nas-li20-pm0.', 'processed_data');
elseif ispc
processed_file_dir = regexprep(processed_file_dir, ...
'nas\\nas-li20-pm0.', 'processed_data');
else
error('Some new computer; good luck.');
end
processed_file_path = fullfile(processed_file_dir, filename_final);
% Get the hostname of the computer.
isfs20_bool = isfs20();
% Run certain things depending on which machine you're on.
% facet-srv20 gets special treatment: no files saved!
exist_type = exist(processed_file_path);
already_exists = (exist_type == 2 || exist_type == 7);
switch data_source_type
case '2015'
if isfs20_bool
% data = E200_gather_data(loadpath);
load(loadpath)
else
% if the file doesn't exist, create it.
if already_exists
load(processed_file_path);
fullpath = regexprep(dir_mid, 'nas.nas-li20-pm0.', ...
'processed_data');
[~, file_id] = strtok(fullpath, expstr);
data.VersionInfo.originalpath = ['processed_data/' file_id];
return;
else
load(loadpath);
% Path to save final mat files
savepath = fullfile(processed_file_dir, [filename_rt ...
'_processed_files']);
data = E200_convert_images(data, savepath);
end
% info that this comes from a HDD
data.VersionInfo.remotefiles.dat = true;
data.VersionInfo.remotefiles.comment = ['Indicates whether ' ...
'files are stored on a remote disk ' ...
'(and getpref(''FACET_data'',''prefix'') should be used.'];
data.VersionInfo.originalfilename = filename_final;
fullpath = regexprep(dir_mid, 'nas.nas-li20-pm0.', ...
'processed_data');
[~, file_id] = strtok(fullpath, expstr);
data.VersionInfo.originalpath = ['processed_data/' file_id];
data.VersionInfo.loadrequest = pathstr;
data = save_data(data,processed_file_path, false);
end
case '2014'
if isfs20_bool
% data = E200_gather_data(loadpath);
load(loadpath)
else
% if the file doesn't exist, create it.
if already_exists
load(processed_file_path);
fullpath = regexprep(dir_mid, 'nas.nas-li20-pm0.', ...
'processed_data');
[~, file_id] = strtok(fullpath, expstr);
data.VersionInfo.originalpath = ['processed_data/' file_id];
return;
else
load(loadpath);
% path to save final mat files
savepath = fullfile(processed_file_dir, [filename_rt ...
'_processed_files']);
data = E200_convert_images(data, savepath);
% info that this comes from a HDD
data.VersionInfo.remotefiles.dat = true;
data.VersionInfo.remotefiles.comment = ...
['Indicates whether files are stored on a remote ' ...
'disk (and getpref(''FACET_data'',''prefix'')) ' ...
'should be used.'];
data.VersionInfo.originalfilename = filename_final;
fullpath = regexprep(dir_mid, 'nas.nas-li20-pm0.', ...
'processed_data');
[~, file_id] = strtok(fullpath, expstr);
data.VersionInfo.originalpath = ['processed_data/' file_id];
data.VersionInfo.loadrequest = pathstr;
% REMOVED: (temporary) data = save_data_2014(data, processed_file_path, false);
end
end
case '2013'
if isfs20_bool
data = E200_gather_data_2013(loadpath);
else
% if the file doesn't exist, create it.
if already_exists
load(processed_file_path);
fullpath = regexprep(dir_mid, 'nas.nas-li20-pm0.', ...
'processed_data');
[~, file_id] = strtok(fullpath, expstr);
data.VersionInfo.originalpath = ['processed_data/' file_id];
return;
else
% path to save final mat files
savepath = fullfile(processed_file_dir, [filename_rt ...
'_processed_files']);
data = E200_gather_data_2013(loadpath);
data = E200_convert_images(data, savepath);
end
end
% info that this comes from a HDD
data.VersionInfo.remotefiles.dat = true;
data.VersionInfo.remotefiles.comment = ['Indicates whether ' ...
'files are stored on a remote disk ' ...
'(and getpref(''FACET_data'',''prefix'') should be used.'];
data.VersionInfo.originalfilename = filename_final;
fullpath = regexprep(dir_mid, 'nas.nas-li20-pm0.', ...
'processed_data');
[~, file_id] = strtok(fullpath, expstr);
data.VersionInfo.originalpath = ['processed_data/' file_id];
data.VersionInfo.loadrequest = pathstr;
if ~isfs20_bool && ~already_exists
data = save_data(data,processed_file_path,false);
end
otherwise
error('Shouldn''t get here!!!');
end
end