-
Notifications
You must be signed in to change notification settings - Fork 0
/
TMSPro_Main.m
711 lines (536 loc) · 24 KB
/
TMSPro_Main.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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
function varargout = TMSPro_Main(varargin)
% TMSPRO MATLAB code for TMSPro.fig
% TMSPRO, by itself, creates a new TMSPRO or raises the existing
% singleton*.
%
% H = TMSPRO returns the handle to a new TMSPRO or the handle to
% the existing singleton*.
%
% TMSPRO('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TMSPRO.M with the given input arguments.
%
% TMSPRO('Property','Value',...) creates a new TMSPRO or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before TMSPro_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to TMSPro_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help TMSPro
% Last Modified by GUIDE v2.5 18-Apr-2019 08:36:28
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @TMSPro_OpeningFcn, ...
'gui_OutputFcn', @TMSPro_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
% End initialization code - DO NOT EDIT
% --- Executes just before TMSPro is made visible.
function TMSPro_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to TMSPro (see VARARGIN)
% Add folder and subfolders to path
addpath(genpath(fileparts(which('TMSPro.m'))));
% Init logo
[img, map, alpha] = imread('logo_transparent.png');
axes(handles.axes2);
imshow(img, map);
handles.axes2.Children.AlphaData = alpha;
% Extract inputs
input = varargin{1};
data = input{1,1};
% Init
[handles.settings, handles.TMS, handles.tms] = TMSPro_init(data);
% Turn off extra buttons
ToggleButtonDisplay(handles,0);
% Init filters
handles.TMS_temp = [];
handles = UpdateFilters(handles);
% Create a matrix that represents the current scrolling TMS matrix
handles.TMS_current = handles.TMS;
% Init export matrix
handles.export = handles.TMS;
% Show current working frame
ShowFrameOnAxis(handles);
% Choose default command line output for TMSPro
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = TMSPro_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if isfield(handles, 'output')
% Get default command line output from handles structure
varargout{1} = handles.output;
end
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles = frameBackwards(handles);
ShowFrameOnAxis(handles);
% Update handles structure
guidata(hObject, handles);
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles = frameForwards(handles);
ShowFrameOnAxis(handles);
% Update handles structure
guidata(hObject, handles);
% --- Executes on key press with focus on figure1 or any of its controls.
% Handles Keyboard Shortcuts
function figure1_WindowKeyPressFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.FIGURE)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
% Handles keyboard shortcuts
switch eventdata.Key
case 'rightarrow'
pushbutton3_Callback(handles.pushbutton3, eventdata, handles);
case 'leftarrow'
pushbutton2_Callback(handles.pushbutton2, eventdata, handles);
case 's'
pushbutton4_Callback(handles.pushbutton4, eventdata, handles);
disp('Saved!');
case 'q'
figure1_CloseRequestFcn(handles.figure1, eventdata, handles);
case 'g'
pushbutton5_Callback(handles.pushbutton5, eventdata, handles);
case 'r'
pushbutton7_Callback(handles.pushbutton7, eventdata, handles);
case 'a'
if ToggleButtonDisplay(handles)
pushbutton10_Callback(handles.pushbutton10, eventdata, handles);
end
case 'c'
if ToggleButtonDisplay(handles)
pushbutton8_Callback(handles.pushbutton8, eventdata, handles);
end
case 'v'
if ToggleButtonDisplay(handles)
pushbutton12_Callback(handles.pushbutton12, eventdata, handles);
end
case 'x'
pushbutton13_Callback(handles.pushbutton13, eventdata, handles);
case 'k'
keyboard
end
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Deconstruct saveables from handles
settings = handles.settings;
TMS = handles.TMS;
tms = handles.tms;
save(settings.files.outfile, 'settings', 'TMS', 'tms');
disp('Saved!');
% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Save dialogue
answer = SaveDialogue;
if strcmp(answer, 'Yes')
pushbutton4_Callback(handles.figure1, eventdata, handles);
disp('Saved!');
end
% Hint: delete(hObject) closes the figure
delete(hObject);
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
frame = str2double(get(hObject,'String'));
if frame >= 1 && frame <= handles.settings.cframes
% Update currentframe and countindex
handles.settings.currentframe = frame;
row = handles.TMS_current(handles.settings.currentframe,:);
handles.settings.countindex = find(all(handles.TMS_current(:,handles.settings.id.Tnum:handles.settings.id.Trej_other)==row,2));
ShowFrameOnAxis(handles);
% Update handles structure
guidata(hObject, handles);
% Reset string inside edit box
handles.edit1.String = 'Go to Frame...';
set(hObject, 'Enable', 'off');
drawnow;
set(hObject, 'Enable', 'on');
else warning('Not a valid frame.');
end
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Only do something if it is an accepted trial & has an onset/offset
if all(handles.TMS(handles.settings.currentframe,handles.settings.id.Trej_nopulse:handles.settings.id.Trej_other) == 0) && ...
handles.TMS(handles.settings.currentframe,handles.settings.id.Taonset) ~= 0 && ...
handles.TMS(handles.settings.currentframe,handles.settings.id.Tmoffset) ~= 0
% Zoom in and find peaks
FindAndPlotPeaks(handles);
end
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
figure1_CloseRequestFcn(handles.figure1, eventdata, handles);
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Toggle buttons back off
ToggleButtonDisplay(handles,0);
% Show current frame on axis
ShowFrameOnAxis(handles);
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
[peaksIndex, valleysIndex] = GetSelectedPeaksIndex(handles);
[currentPeaks, currentValleys] = PlotSelectedPeaks(handles, peaksIndex, valleysIndex);
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
[peaksIndex, valleysIndex] = GetSelectedPeaksIndex(handles);
[currentPeaks, currentValleys] = PlotSelectedPeaks(handles, peaksIndex, valleysIndex);
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
PlotCurrentRecordedAmplitude(handles);
% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.popupmenu1,'Value',1);
set(handles.popupmenu2,'Value',1);
popupmenu1_Callback(handles.popupmenu1, eventdata, handles);
popupmenu2_Callback(handles.popupmenu2, eventdata, handles);
% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get current selected peak/valley
cPeaks = cellstr(get(handles.popupmenu1,'String'));
cValleys = cellstr(get(handles.popupmenu2,'String'));
peak = str2double(cPeaks{get(handles.popupmenu1,'Value')});
valley = str2double(cValleys{get(handles.popupmenu2,'Value')});
% Check inputs for correct format
if ~isnan(peak) && ~isnan(valley)
% Make sure they want to make changes
answer = SetNewAmpDialogue(peak,valley);
if strcmp(answer, 'Yes')
% Adjust new peak/valley to TMS matrix
handles.TMS(handles.settings.currentframe,handles.settings.id.Tmax) = peak;
handles.TMS(handles.settings.currentframe,handles.settings.id.Tmin) = valley;
% Adjust new amplitude to TMS matrix
handles.TMS(handles.settings.currentframe,handles.settings.id.Tmep) = abs(peak) + abs(valley);
% Update filters
handles = UpdateFilters(handles);
% Update handles structure
guidata(hObject, handles);
% Hide buttons again
ToggleButtonDisplay(handles,0);
% Save
pushbutton4_Callback(handles.pushbutton4, eventdata, handles);
% Go back and show frame
ShowFrameOnAxis(handles);
end
end
% --- Executes on button press in pushbutton13.
function pushbutton13_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
currentTrial = handles.settings.currentframe;
if handles.pushbutton13.UserData
str = RejectionConfirmationDialogue(currentTrial);
[bool, index] = ismember(str, handles.settings.rejreasons);
if bool; handles.TMS(currentTrial, index + 9) = 1; end
else
% Reset TMS matrix to 0
handles.TMS(currentTrial, handles.settings.id.Trej_nopulse:handles.settings.id.Trej_other) = 0;
end
% Update Filters
handles = UpdateFilters(handles);
% Set buttons off again
ToggleButtonDisplay(handles,0);
% Update handles structure
guidata(hObject, handles);
% Save
pushbutton4_Callback(handles.pushbutton4, eventdata, handles);
% Go back and show frame
ShowFrameOnAxis(handles);
% --- Executes on button press in pushbutton14.
function pushbutton14_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
rej = handles.settings.filter_by(handles.TMS, handles.settings.id.Trej_other);
disp(rej);
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
var = get(hObject, 'String');
split = strfind(var,':');
min = str2double(var(1:split-1));
max = str2double(var(split+1:end));
if CheckRange(min, max)
% Set new MEP window in TMS matrix
handles.TMS(handles.settings.currentframe, handles.settings.id.Taonset) = min;
handles.TMS(handles.settings.currentframe, handles.settings.id.Tmoffset) = max;
% Update handles structure
guidata(hObject, handles);
% Save
pushbutton4_Callback(handles.pushbutton4, eventdata, handles);
% Reset string on edit2
handles.edit2.String = 'Min:Max';
set(hObject, 'Enable', 'off');
drawnow;
set(hObject, 'Enable', 'on');
else
warn = sprintf('Invalid inputs. Setting must be two integers separated by a colon. \nExamples: 1:500, 5:100, 60:90');
warning(warn);
end
% Re-display the current frame with new MEP offset
ShowFrameOnAxis(handles);
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu3 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu3
contents = cellstr(get(hObject,'String'));
val = contents{get(hObject,'Value')};
switch val
case 'No MEP (< 0.01)'
handles.TMS_current = handles.TMS_temp.nomep;
case 'Baseline too noisy (>0.01)'
handles.TMS_current = handles.TMS_temp.absbase;
case 'No Pulse'
handles.TMS_current = handles.TMS_temp.nopulse;
case 'MEP maxed out (negatively)'
handles.TMS_current = handles.TMS_temp.minex;
case 'MEP maxed out (postively)'
handles.TMS_current = handles.TMS_temp.maxex;
case 'Other'
handles.TMS_current = handles.TMS_temp.other;
case 'Accepted'
handles.TMS_current = handles.TMS_temp.accepted;
case 'All'
handles.TMS_current = handles.TMS_temp.all;
case 'Rejected'
handles.TMS_current = handles.TMS_temp.rejected;
end
% Reset the countindex and get current frame
handles = resetCountIndex(handles);
% Unset focus
set(hObject, 'Enable', 'off');
drawnow;
set(hObject, 'Enable', 'on');
% Update handles structure
guidata(hObject, handles);
% Show frame
ShowFrameOnAxis(handles);
% --- Executes during object creation, after setting all properties.
function popupmenu3_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% Update handles structure
guidata(hObject, handles);
% --- Executes on button press in pushbutton16.
function pushbutton16_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton16 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get export file
[filen, filep] = uiputfile;
if all(filen ~= 0) || all(filep ~= 0)
[~,~,ext] = fileparts(filen); % get chosen filename's extension
if strcmp(ext,'.mldatx'); filen = strrep(filen, '.mldatx', '.mat'); end
ffile = fullfile(filep, filen);
% Unwrap data to save in export file
settings = handles.settings;
TMS = handles.export;
tms = handles.tms;
% Save
save(ffile, 'settings', 'TMS', 'tms');
end
% --- Executes on selection change in popupmenu4.
function popupmenu4_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu4 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu4
contents = cellstr(get(hObject,'String'));
val = contents{get(hObject,'Value')};
switch val
case 'No MEP (< 0.01)'
handles.export = handles.TMS_temp.nomep;
case 'Baseline too noisy (>0.01)'
handles.export = handles.TMS_temp.absbase;
case 'No Pulse'
handles.export = handles.TMS_temp.nopulse;
case 'MEP maxed out (negatively)'
handles.export = handles.TMS_temp.minex;
case 'MEP maxed out (postively)'
handles.export = handles.TMS_temp.maxex;
case 'Other'
handles.export = handles.TMS_temp.other;
case 'Accepted'
handles.export = handles.TMS_temp.accepted;
case 'All'
handles.export = handles.TMS_temp.all;
case 'Rejected'
handles.export = handles.TMS_temp.rejected;
end
% Unset focus
set(hObject, 'Enable', 'off');
drawnow;
set(hObject, 'Enable', 'on');
% Update handles structure
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function popupmenu4_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
var = get(hObject, 'String');
split = strfind(var,':');
min = str2double(var(1:split-1));
max = str2double(var(split+1:end));
if CheckRange(min, max)
answer = GlobalMEPConfirmation;
if strcmpi(answer, 'Yes')
% Set new MEP window in all frames of TMS matrix
handles.TMS(:, handles.settings.id.Taonset) = min;
handles.TMS(:, handles.settings.id.Tmoffset) = max;
% Show new frame
ShowFrameOnAxis(handles)
end
else
warn = sprintf('Invalid inputs. Setting must be two integers separated by a colon. \nExamples: 1:500, 5:100, 60:90');
warning(warn);
end
% Unset focus
set(hObject, 'Enable', 'off');
drawnow;
set(hObject, 'Enable', 'on');
% Update handles structure
guidata(hObject, handles);
% Reset string on edit3
handles.edit3.String = 'Min:Max';
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end