This repository has been archived by the owner on Aug 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
TDTExtract_GUI.m
306 lines (261 loc) · 11.3 KB
/
TDTExtract_GUI.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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
function varargout = TDTExtract_GUI(varargin)
% Begin initialization code, probably don't want to edit this part.
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @TDTExtract_GUI_OpeningFcn, ...
'gui_OutputFcn', @TDTExtract_GUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% --- Executes just before TDTExtract_GUI is made visible.
function TDTExtract_GUI_OpeningFcn(hObject, eventdata, handles, varargin)
global tankTDT;
global blockTDT;
global eventTDT;
global event2TDT;
global event3TDT;
global event4TDT;
global event5TDT;
handles.output = hObject; % Choose default command line output for TDTExtract_GUI
guidata(hObject, handles); % Update handles structure
tankTDT = actxcontrol('TANKSELECT.TankSelectActiveXCtrl.1','position',[20 680 375 150],'parent',hObject,'callback','tankChange');
tankTDT.SingleClickSelect = 1;
blockTDT = actxcontrol('BlockSelect.BlockSelectActiveXCtrl.1','position',[20 390 375 240],'parent',hObject,'callback',{'BlockChanged' 'blockChange'});
blockTDT.HideDetails = 0;
blockTDT.ShowOwner = 0;
blockTDT.ShowMemo = 0;
blockTDT.ShowStart = 1;
blockTDT.ShowStop = 0;
blockTDT.SingleClickSelect = 1;
eventTDT = actxcontrol('EVENTSELECT.EventSelectActiveXCtrl.1','position',[20 225 375 115],'parent',hObject,'callback',{'ActEventChanged' 'eventChange'});
eventTDT.HideDetails = 0;
eventTDT.SingleClickSelect = 1;
event2TDT = actxcontrol('EVENTSELECT.EventSelectActiveXCtrl.1','position',[450 630 375 115],'parent',hObject,'callback',{'ActEventChanged' 'event2Change'});
event2TDT.HideDetails = 0;
event2TDT.SingleClickSelect = 1;
event3TDT = actxcontrol('EVENTSELECT.EventSelectActiveXCtrl.1','position',[450 495 375 115],'parent',hObject,'callback',{'ActEventChanged' 'event3Change'});
event3TDT.HideDetails = 0;
event3TDT.SingleClickSelect = 1;
event4TDT = actxcontrol('EVENTSELECT.EventSelectActiveXCtrl.1','position',[450 360 375 115],'parent',hObject,'callback',{'ActEventChanged' 'event4Change'});
event4TDT.HideDetails = 0;
event4TDT.SingleClickSelect = 1;
event5TDT = actxcontrol('EVENTSELECT.EventSelectActiveXCtrl.1','position',[450 225 375 115],'parent',hObject,'callback',{'ActEventChanged' 'event5Change'});
event5TDT.HideDetails = 0;
event5TDT.SingleClickSelect = 1;
% --- Outputs from this function are returned to the command line.
function varargout = TDTExtract_GUI_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
% --- Executes on button press in clearEvents.
function clearEvents_Callback(hObject, eventdata, handles)
global tankTDT;
global blockTDT;
global eventTDT;
global event2TDT;
global event3TDT;
global event4TDT;
global event5TDT;
global currentEvent;
global currentEvent2;
global currentEvent3;
global currentEvent4;
global currentEvent5;
eventTDT.UseTank = tankTDT.ActiveTank;
eventTDT.UseBlock = blockTDT.ActiveBlock;
eventTDT.Refresh;
event2TDT.UseTank = tankTDT.ActiveTank;
event2TDT.UseBlock = blockTDT.ActiveBlock;
event2TDT.Refresh;
event3TDT.UseTank = tankTDT.ActiveTank;
event3TDT.UseBlock = blockTDT.ActiveBlock;
event3TDT.Refresh;
event4TDT.UseTank = tankTDT.ActiveTank;
event4TDT.UseBlock = blockTDT.ActiveBlock;
event4TDT.Refresh;
event5TDT.UseTank = tankTDT.ActiveTank;
event5TDT.UseBlock = blockTDT.ActiveBlock;
event5TDT.Refresh;
currentEvent = '';
currentEvent2 = '';
currentEvent3 = '';
currentEvent4 = '';
currentEvent5 = '';
%%%%%%%%%%%%% List of Channels
function channelList_Callback(hObject, eventdata, handles)
function channelList_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
userChannelList = str2num(get(hObject,'String'));
if isempty(userChannelList)
set(hObject,'String','1:16');
end
guidata(hObject,handles);
%%%%%%%%%%%%% Chunk Size
function chunkSize_Callback(hObject, eventdata, handles)
function chunkSize_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
userChunkSize = str2num(get(hObject,'String'));
if isempty(userChunkSize)
set(hObject,'String','100');
end
guidata(hObject,handles);
%%%%%%%%%%%%% Start Time via User
function startTime_Callback(hObject, eventdata, handles)
function startTime_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
userT1 = str2num(get(hObject,'String'));
if isempty(userT1)
set(hObject,'String','0.0');
end
guidata(hObject,handles);
%%%%%%%%%%%%% End Time via User
function endTime_Callback(hObject, eventdata, handles)
function endTime_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
userT2 = str2num(get(hObject,'String'));
if isempty(userT2)
set(hObject,'String','0.0');
end
guidata(hObject,handles);
function epochSamplingRef_Callback(hObject, eventdata, handles)
function epochSamplingRef_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
epochSamplingRef = get(hObject,'String');
if isempty(epochSamplingRef)
set(hObject,'String','n/a');
epochSamplingRef = 'n/a';
end
guidata(hObject,handles);
%%%%%%%%%%%%% Filename Prefix via User
function filenameSave_Callback(hObject, eventdata, handles)
function filenameSave_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
filenameSave = get(hObject,'String');
if isempty(filenameSave)
set(hObject,'String','Extracted_TDT_Data');
filenameSave = 'Extracted_TDT_Data';
end
guidata(hObject,handles);
function directorySave_Callback(hObject, eventdata, handles)
function directorySave_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
directorySave = get(hObject,'String');
if isempty(directorySave)
set(hObject,'String','C:\ExtractedTDTData');
directorySave = 'C:\ExtractedTDTData';
end
guidata(hObject,handles);
function method2Go_Callback(hObject, eventdata, handles)
function method2Go_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
if (get(hObject,'Value') == get(hObject,'Max'));
disp('Method 2 checked.');
else
disp('Method 2 unchecked');
end
guidata(hObject,handles);
% --- Executes on button press in changesavedir.
function changesavedir_Callback(hObject, eventdata, handles)
newDirectory = uigetdir('','Please select a folder to save to:');
set(handles.directorySave,'String',newDirectory);
guidata(hObject,handles);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Data extraction is a go! Start extracting data! %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function extractDataGo_Callback(hObject, eventdata, handles)
global currentTank;
global currentBlock;
global eventType;
userChannelList = get(handles.channelList,'String');
userChunkSize = str2num(get(handles.chunkSize,'String'));
userT1 = str2num(get(handles.startTime,'String'));
userT2 = str2num(get(handles.endTime,'String'));
epochSamplingRef = get(handles.epochSamplingRef,'String');
filenameSave = get(handles.filenameSave,'String');
directorySave = get(handles.directorySave,'String');
method2Go = get(handles.method2Go,'Value');
guidata(hObject,handles);
checkTypes;
%if chan list = 0, 1-16
%if chan list has :, n:m
%if chan list has , -- []
commaChannels = strfind(userChannelList,',');
coloChannels = strfind(userChannelList,':');
if userChannelList == '0'
inputChannels = 1:16;
elseif not(isempty(commaChannels))
inputChannels = (strread(userChannelList,'%u','delimiter',','))';
elseif not(isempty(coloChannels))
pullChan = (strread(userChannelList,'%u','delimiter',':'))';
inputChannels = pullChan(1):pullChan(2);
else
inputChannels = str2num(userChannelList);
end
for i=1:length(eventType)
if isempty(eventType{1,i})
eventType{1,i}{1,1} = 'unused';
end
switch eventType{1,i}{1,1}
case '257' %257 = Strobe+ (e.g. "Tick")
if (strcmp(epochSamplingRef,'n/a') || strcmp(epochSamplingRef,''))
disp('WARNING: NO SAMPLING REFERENCE WAS GIVEN -- EXTRACTING BASE EPOCH VALUES.');
extractEpochNoRef(currentTank,currentBlock,eventType{2,i},directorySave,filenameSave,userT1,userT2);
else
disp('Extracting epoch data with given sampling reference');
extractEpochWithRef(currentTank,currentBlock,eventType{2,i},directorySave,filenameSave,userT1,userT2,epochSamplingRef);
end
case '33025' %33025 = stream
if method2Go == 1
disp('Extracting stream data using method 2 (allows zero-padding).')
for definedChannel = inputChannels
extractTuckerDavisRaw2(currentTank,currentBlock,eventType{2,i},definedChannel,directorySave,filenameSave);
end
else
disp('Extracting stream data (no zero padding).')
for definedChannel = inputChannels
extractTuckerDavisRaw(currentTank,currentBlock,eventType{2,i},definedChannel,directorySave,filenameSave,userChunkSize,userT1,userT2);
end
end
case '33281' %33281 = snippet
if (strcmp(epochSamplingRef,'n/a') || strcmp(epochSamplingRef,''))
disp('No sampling reference given; extracting snippets without sample references.')
extractSnippetsNoRef(currentTank,currentBlock,eventType{2,i},inputChannels,directorySave,filenameSave,userT1,userT2);
else
disp('Extracting snippet data with sample references');
extractSnippetsWithRef(currentTank,currentBlock,eventType{2,i},inputChannels,directorySave,filenameSave,userT1,userT2,epochSamplingRef);
end
case '258' %258 = strobe- ]
error('Error: This version of TDT GUI Extract does not support the STROBE- data type.');
case '513' %513 = scalar?
error('Error: This version of TDT GUI Extract does not support the SCALAR data type.');
case '34817' %34817 = mark?
error('Error: This version of TDT GUI Extract does not support the MARK data type.');
case '32768' %32768 = hasdata?
error('Error: This version of TDT GUI Extract does not support the HASDATA data type.');
case 'unused' % unused
otherwise %0 = unknown
error('Error: Data type unknown.');
end
end