-
Notifications
You must be signed in to change notification settings - Fork 9
/
best_application.m
11795 lines (10589 loc) · 892 KB
/
best_application.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
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
classdef best_application < handle
properties
par
bst
info
data
save_buffer
pr
pi
hw
end
properties (Hidden)
Version
pmd %panel_measurement_designer
% pi %panel_inputs
% pr %panel_results
% hw
var
grid % bottom most 3 panels
panel
pulse
fig
menu
icons
Date
% bst
% save_buffer
end
methods
%% BEST
function obj=best_application()
obj.Version=15112021;
obj.close_previous;
obj.create_gui;
function CreateHardwareConfigurationDefaults
obj.par.hardware_settings.neurone1.device_type=1;
obj.par.hardware_settings.neurone1.slct_device=1;
obj.par.hardware_settings.neurone1.device_name='neurone1';
end
end
function close_previous(obj)
close all;
ClassExist=exist('best_application','class');
if ClassExist==8
baseVariables = evalin('base' , 'whos');
for i = 1:length(baseVariables)
if (strcmpi(baseVariables(i).class , 'best_application'))
evalin( 'base', ['clear(''' baseVariables(i).name ''')'] )
end
end
end
end
function create_gui(obj)
obj.create_best_obj;
obj.create_figure;
obj.create_menu;
obj.create_main_panel;
obj.create_inputs_panel;
obj.create_results_panel;
obj.create_hwcfg_panel;
obj.create_settings;
obj.protect_experiment;
% obj.pi_ioc
% obj.results_panel;
% obj.pr.axesno=6;
% obj.resultsPanel
end
function create_best_obj(obj)
obj.bst= best_toolbox (obj);
% obj.bst= best_toolbox_gui_version_inprogress_testinlab_2910_sim (obj);
end
function create_figure(obj)
version=num2str(obj.Version);
Title=['BEST Toolbox - Release ' version];
obj.fig.handle = figure('Tag','BESTToolboxApplication','ToolBar','none','MenuBar','none','Name',Title,'NumberTitle','off','CloseRequestFcn',@obj.close_figure_ioio);
obj.info.session_no=0;
obj.info.measurement_no=0;
obj.info.event.current_session={};
obj.info.event.current_measure={};
obj.info.session_matrix={};
% set(obj.fig.handle, 'Position', get(0, 'Screensize'));
set(obj.fig.handle,'Units','normalized', 'Position', [0 0 1 0.97]);
obj.info.pause=0;
obj.info.session_copy_id=0;
obj.info.measurement_paste_marker=0;
obj.info.copy_index=0;
obj.pi.mm.stim.no=0;
% save icons graphical data into dedicated object here
obj.icons.stimulator=imread('best_icon_stimulator.png');
obj.icons.single_pulse=imread('best_icon_single_pulse.png');
obj.icons.paired_pulse=imread('best_icon_paired_pulse.png');
obj.icons.train=imread('best_icon_train_pulse.png');
end
function close_figure_ioio(obj,~,~)
obj.cb_menu_save;
answer = questdlg('Do you want to Close BEST Toolbox Application current Session?','BEST Toolbox','No','Yes Close','No');
switch answer
case 'Yes Close'
delete (findobj('Tag','BESTToolboxApplication'));
case 'No'
return
end
end
function create_menu(obj)
obj.fig.vbox=uix.VBox( 'Parent', obj.fig.handle, 'Spacing', 5, 'Padding', 5 );
obj.fig.menu=uix.Panel( 'Parent',obj.fig.vbox, 'Padding', 1);
menu_hbox=uix.HBox('Parent',obj.fig.menu,'Spacing', 5 );
obj.menu.load.btn=uicontrol( 'Parent', menu_hbox ,'Style','PushButton','String','Load','FontWeight','Bold','Callback',@(~,~)obj.cb_menu_load );
obj.menu.save.btn=uicontrol( 'Parent', menu_hbox ,'Style','PushButton','String','Save','FontWeight','Bold','Callback',@(~,~)obj.cb_menu_save);
% obj.menu.subjdata.btn=uicontrol( 'Parent', menu_hbox ,'Style','PushButton','String','Subject Data','FontWeight','Bold' );
obj.menu.md.btn=uicontrol( 'Parent', menu_hbox ,'Style','PushButton','String','Close Controller','FontWeight','Bold' ,'Callback', @(~,~)obj.cb_menu_md);
obj.menu.ip.btn=uicontrol( 'Parent', menu_hbox ,'Style','PushButton','String','Close Designer','FontWeight','Bold','Callback', @(~,~)obj.cb_menu_ip );
obj.menu.rp.btn=uicontrol( 'Parent', menu_hbox ,'Style','PushButton','String','Close Results','FontWeight','Bold','Callback', @(~,~)obj.cb_menu_rp );
obj.menu.hwcfg.btn=uicontrol( 'Parent', menu_hbox ,'Style','PushButton','String','Hardware Configuration','FontWeight','Bold','Callback', @(~,~)obj.cb_menu_hwcfg ); %TODO1
obj.menu.settings.btn=uicontrol( 'Parent', menu_hbox ,'Style','PushButton','String','General Settings','FontWeight','Bold','Callback', @(~,~)obj.cb_menu_settings ); %TODO1
obj.menu.notes.btn=uicontrol( 'Parent', menu_hbox ,'Style','PushButton','String','Lab Book','FontWeight','Bold','Callback', @(~,~)obj.cb_notes );
uiextras.HBox( 'Parent', menu_hbox,'Spacing', 5, 'Padding', 5 );
set(menu_hbox,'Widths',[-0.6 -0.6 -1.5 -1.5 -1.5 -1.8 -1.8 -1.5 -12]);
obj.info.menu.md=0;
obj.info.menu.ip=0;
obj.info.menu.rp=0;
obj.info.menu.hwcfg=0;
end
function create_main_panel(obj)
obj.fig.main = uix.GridFlex( 'Parent', obj.fig.vbox, 'Spacing', 5 );
set(obj.fig.vbox,'Heights',[-1 -25]);
p_measurement_designer = uix.Panel( 'Parent', obj.fig.main, 'Padding', 5, 'Units','normalized','BorderType','none');
obj.pmd.panel = uix.Panel( 'Parent', p_measurement_designer, 'Title', 'Experiment Control Module', 'Padding', 5,'FontSize',14 ,'Units','normalized','FontWeight','bold','TitlePosition','centertop');
pmd_vbox = uix.VBox( 'Parent', obj.pmd.panel, 'Spacing', 5, 'Padding', 5 );
% experiment title: first horizontal row in measurement designer panel
pmd_hbox_exp_title = uix.HBox( 'Parent', pmd_vbox, 'Spacing', 5, 'Padding', 5 );
uicontrol( 'Style','text','Parent', pmd_hbox_exp_title,'String','Experiment Title:','FontSize',11,'HorizontalAlignment','left','Units','normalized' );
obj.pmd.exp_title.editfield=uicontrol( 'Style','edit','Parent', pmd_hbox_exp_title ,'String','Experiment1','FontSize',11,'Callback',@(~,~)obj.cb_pmd_exp_title_editfield);
obj.pmd.exp_title.btn=uicontrol( 'Parent', pmd_hbox_exp_title ,'Style','PushButton','String','...','FontWeight','Bold','Callback',@obj.opendir );
set( pmd_hbox_exp_title, 'Widths', [120 -0.7 -0.09]);
% subject code: second horizontal row on first panel
pmd_hbox_sub_code = uix.HBox( 'Parent', pmd_vbox, 'Spacing', 5, 'Padding', 5 );
uicontrol( 'Style','text','Parent', pmd_hbox_sub_code,'String','Subject Code:','FontSize',11,'HorizontalAlignment','left','Units','normalized');
obj.pmd.sub_code.editfield=uicontrol( 'Style','edit','Parent', pmd_hbox_sub_code ,'String','Subject1','FontSize',11,'Callback',@(~,~)obj.cb_pmd_sub_code_editfield);
obj.pmd.sub_code.btn=uicontrol( 'Parent', pmd_hbox_sub_code ,'Style','PushButton','String','...','FontWeight','Bold','Callback',@obj.opendir );
set( pmd_hbox_sub_code, 'Widths', [120 -0.7 -0.09]);
% session title edit box: third horizontal row on first panel
pmd_hbox_session_title = uix.HBox( 'Parent', pmd_vbox, 'Spacing', 5, 'Padding', 5 );
uicontrol( 'Style','text','Parent', pmd_hbox_session_title,'String','Session Title:','FontSize',11,'HorizontalAlignment','left' ,'Units','normalized');
obj.pmd.sess_title.editfield=uicontrol( 'Style','edit','Parent', pmd_hbox_session_title ,'FontSize',11);
obj.pmd.sess_title.btn=uicontrol( 'Parent', pmd_hbox_session_title ,'Style','PushButton','String','+','FontWeight','Bold','Callback',@(~,~)obj.cb_session_add);
set( pmd_hbox_session_title, 'Widths', [120 -0.7 -0.09]);
% drop-down select measure: fourth horizontal row on first panel
pmd_hbox_slct_mes = uix.HBox( 'Parent', pmd_vbox, 'Spacing', 5, 'Padding', 5 );
uicontrol( 'Style','text','Parent', pmd_hbox_slct_mes,'String','Select Protocol:','FontSize',11,'HorizontalAlignment','left' ,'Units','normalized');
obj.pmd.select_measure.string={'MEP Hotspot Search','MEP Motor Threshold Hunting','MEP Dose Response Curve','MEP Measurement','rsEEG Measurement','Sensory Threshold Hunting','TEP Measurement','ERP Measurement','TMS fMRI','rTMS Intervention','TUS Intervention','Auditory Threshold Hunting','Custom Protocol'};
obj.pmd.select_measure.popupmenu=uicontrol( 'Style','popupmenu','Parent', pmd_hbox_slct_mes ,'FontSize',11,'String',obj.pmd.select_measure.string);
obj.pmd.select_measure.btn=uicontrol( 'Parent', pmd_hbox_slct_mes ,'Style','PushButton','String','+','FontWeight','Bold','Callback',@(~,~)obj.cb_measure_add);
set( pmd_hbox_slct_mes, 'Widths', [120 -0.7 -0.09]);
% empty fifth horizontal row on first panel
fifth_row = uix.HBox( 'Parent', pmd_vbox, 'Spacing', 5, 'Padding', 5 );
uicontrol( 'Style','text','Parent', fifth_row,'String','','FontSize',11,'HorizontalAlignment','left' ,'Units','normalized');
uicontrol( 'Style','text','Parent', fifth_row ,'FontSize',11,'String','');
uicontrol( 'Parent', fifth_row ,'Style','text','String','','FontWeight','Bold')
set( fifth_row, 'Widths', [120 -0.7 -0.05]);
% text session: sixth horizontal row on first panel
uicontrol( 'Style','text','Parent', pmd_vbox,'String','Sessions','FontSize',12,'HorizontalAlignment','center' ,'Units','normalized','FontWeight','bold');
% sessions listbox: seventh horizontal row on first panel
obj.pmd.lb_sessions.string={};
m_sessions=uicontextmenu(obj.fig.handle);
obj.pmd.copysession = uimenu(m_sessions,'label','Copy','Callback',@(~,~)obj.cb_pmd_lb_sessions_copy);
% mus2 = uimenu(m_sessions,'label','Paste Above','Callback',@(~,~)obj.cb_pmd_lb_sessions_pasteup);
obj.pmd.pastesession = uimenu(m_sessions,'label','Paste','Callback',@(~,~)obj.cb_pmd_lb_sessions_pastedown);
obj.pmd.deletesession = uimenu(m_sessions,'label','Delete','Callback',@(~,~)obj.cb_pmd_lb_sessions_del);
mus1 = uimenu(m_sessions,'label','Move Up','Callback',@(~,~)obj.cb_pmd_lb_sessions_moveup);
mus2 = uimenu(m_sessions,'label','Move Down','Callback',@(~,~)obj.cb_pmd_lb_sessions_movedown);
obj.pmd.renamesession = uimenu(m_sessions,'label','Rename Sesion','Callback',@(~,~)obj.cb_session_rename);
obj.pmd.lb_sessions.listbox=uicontrol( 'Style','listbox','Parent', pmd_vbox ,'KeyPressFcn',@(~,~)obj.cb_pmd_lb_session_keypressfcn,'FontSize',11,'String',obj.pmd.lb_sessions.string,'uicontextmenu',m_sessions,'Callback',@(~,~)obj.cb_session_listbox);
%empty 8th horizontal row on first panel
uicontrol( 'Style','text','Parent', pmd_vbox,'String','Protocols','FontSize',12,'HorizontalAlignment','center' ,'Units','normalized','FontWeight','bold');
%measurement listbox: 9th horizontal row on first panel
ProtocolListBox = uix.HBox( 'Parent', pmd_vbox, 'Spacing', 0, 'Padding', 0 );
ProtocolListBox = uiextras.GridFlex( 'Parent', ProtocolListBox, 'Spacing', 5, 'Padding', 5 );
% measure_lb2={'MEP Measurement','MEP Hotspot Search','MEP Motor Threshold Hunting','Dose-Response Curve (MEP-sp)','Dose-Response Curve (MEP-pp)','EEG triggered TMS','MR triggered TMS','TEP Measurement'};
obj.pmd.lb_measures.string={};
m=uicontextmenu(obj.fig.handle);
obj.pmd.copyprotocol = uimenu(m,'label','Copy','Callback',@(~,~)obj.cb_pmd_lb_measures_copy);
% mu2 = uimenu(m,'label','Paste Above','Callback',@(~,~)obj.cb_pmd_lb_measures_pasteup);
obj.pmd.pasteprotocol = uimenu(m,'label','Paste','Callback',@(~,~)obj.cb_pmd_lb_measures_pastedown);
obj.pmd.deleteprotocol = uimenu(m,'label','Delete','Callback',@(~,~)obj.cb_pmd_lb_measures_del);
obj.pmd.suffixprotocol = uimenu(m,'label','Add Suffix','Callback',@(~,~)obj.cb_measure_suffix);
mu5 = uimenu(m,'label','Move Up','Callback',@(~,~)obj.cb_pmd_lb_measures_moveup);
mu6 = uimenu(m,'label','Move Down','Callback',@(~,~)obj.cb_pmd_lb_measures_movedown);
obj.pmd.lb_measure_menu_loadresults=uimenu(m,'label','Load Results','Callback',@(~,~)obj.LoadResults);
obj.pmd.renameprotocol = uimenu(m,'label','Rename Protocol','Callback',@(~,~)obj.cb_measure_rename);
uimenu(m,'label','Edit Custom Function','Callback',@(~,~)obj.cb_custom_function);
obj.pmd.lb_measures.listbox=uicontrol( 'Style','listbox','Parent', ProtocolListBox ,'KeyPressFcn',@(~,~)obj.cb_pmd_lb_measure_keypressfcn,'FontSize',11,'String',obj.pmd.lb_measures.string,'uicontextmenu',m,'Callback',@(~,~)obj.cb_measure_listbox);
obj.pmd.ProtocolStatus.listbox=uicontrol( 'Style','listbox','Parent', ProtocolListBox ,'FontAngle','italic','KeyPressFcn',@(~,~)obj.cb_pmd_lb_measure_keypressfcn,'FontSize',11,'String',obj.pmd.lb_measures.string,'uicontextmenu',m,'Callback',@(~,~)obj.cb_measure_listbox);
ProtocolListBox.ColumnSizes=[-2 -1];
m=uicontextmenu(obj.fig.handle);
LastRow = uix.HBox( 'Parent', pmd_vbox, 'Spacing', 5, 'Padding', 5 );
obj.pmd.CompileButton=uicontrol( 'Parent', LastRow ,'Style','PushButton','String','Compile','Enable','off','FontWeight','Bold','Callback',@obj.CompileButton);
obj.pmd.RunStopButton=uicontrol( 'Parent', LastRow ,'Style','PushButton','String','Run','Enable','off','FontWeight','Bold','Callback',@obj.RunStopButton);
obj.pmd.PauseUnpauseButton=uicontrol( 'Parent', LastRow ,'Style','PushButton','String','Pause','Enable','off','FontWeight','Bold','Callback',@obj.PauseUnpauseButton);
set( pmd_vbox, 'Heights', [35 35 35 35 0 -0.04 -0.11 -0.04 -0.63 45]);
end
%% Run Stop Controllers
function CompileButton(obj,~,~)
try
obj.bst.best_compile;
obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).ProtocolStatus={'compiled'};
obj.cb_measure_listbox;
catch e
errordlg('This Protcol has been stopped due to an error. Check your input parameters and MATLAB command line.','BEST Toolbox');
fprintf(1,'The identifier was:\n%s',e.identifier);
fprintf(1,'\nThere was an error! The message was:\n%s',e.message);
obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).ProtocolStatus={'Error'};
obj.pmd.ProtocolStatus.listbox.String(obj.pmd.ProtocolStatus.listbox.Value)={'Error'};
obj.enable_listboxes;
end
end
function RunStopButton(obj,~,~)
try
if strcmp(obj.pmd.RunStopButton.String,'Stop')
uiresume;
try obj.bst.bossbox.bb.stop; catch, end
obj.bst.inputs.stop_event=1;
obj.pmd.RunStopButton.Enable='off';
obj.pmd.PauseUnpauseButton.Enable='off';
obj.pmd.RunStopButton.String='Run';
obj.pmd.PauseUnpauseButton.String='Pause';
obj.enable_listboxes;
if ~isempty(obj.bst.bossbox), obj.bst.bossbox.stop; end
obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).ProtocolStatus={'Stopped'};
obj.pmd.ProtocolStatus.listbox.String(obj.pmd.ProtocolStatus.listbox.Value)={'Stopped'};
elseif strcmp(obj.pmd.RunStopButton.String,'Run') % && strcmp(obj.pmd.RunStopButton.Enable,'On')
obj.fig.main.Widths(1)=-1.15;
obj.fig.main.Widths(2)=0;
obj.fig.main.Widths(3)=-3.35;
obj.pmd.RunStopButton.String='Stop';
obj.pmd.PauseUnpauseButton.Enable='on';
obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).ProtocolStatus={'Executing'};
obj.pmd.ProtocolStatus.listbox.String(obj.pmd.ProtocolStatus.listbox.Value)={'Executing'};
% obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).Enable{1,1}='off';
obj.disable_listboxes;
%search for all the handles and make their enable off uicontrols, table and the interactive axes %https://www.mathworks.com/help/matlab/ref/disabledefaultinteractivity.html
%make enable off in the listboxes and all pmd fields
pause(0.02); %Test it by replacing it with drawnow
switch obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).Protocol{1,1}
case 'MEP Hotspot Search Protocol'
switch obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).ProtocolMode
case 1 %Automated
ParametersFieldNames=fieldnames(obj.pi.hotspot);
for iLoadingParameters=1:numel(ParametersFieldNames)
obj.pi.hotspot.(ParametersFieldNames{iLoadingParameters}).Enable=obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).Enable{1,1};
end
obj.bst.best_hotspot
case 2 %Manual
obj.bst.best_hotspot_manual
end
case 'MEP Measurement Protocol'
obj.bst.best_mep;
case 'MEP Dose Response Curve Protocol'
obj.bst.best_drc;
case 'Motor Threshold Hunting Protocol'
obj.bst.best_mth;
case 'Psychometric Threshold Hunting Protocol'
obj.bst.best_psychmth;
case 'rTMS Intervention Protocol'
iPulses=3;IPI=0.02;iBursts=10;IBI=0.2;iTrains=10;ITI=2;
burst=0;
for i=2:iPulses
burst(i)=burst(i-1)+IPI;
end
%creating train
train=burst;
for i=2:iBursts
train(numel(train)+1)=train(end)+IBI;
for j=2:iPulses
train(numel(train)+1)=train(end)+IPI;
end
end
% creating protocol
protocol=train;
for i=2:iTrains
protocol(numel(protocol)+1)=protocol(end)+ITI;
for j=2:iPulses
protocol(numel(protocol)+1)=protocol(end)+IPI;
end
for k=2:iBursts
protocol(numel(protocol)+1)=protocol(end)+IBI;
for l=2:iPulses
protocol(numel(protocol)+1)=protocol(end)+IPI;
end
end
end
X=protocol;
temp=ones(300,3);
temp(:,1)=X';
b=bossdevice;
b.configure_time_port_marker(temp);
b.manualTrigger
case 'rs EEG Measurement Protocol'
obj.bst.best_rseeg;
case 'TEP Hotspot Search Protocol'
switch obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).ProtocolMode
case 1 %Automated
ParametersFieldNames=fieldnames(obj.pi.tephs);
for iLoadingParameters=1:numel(ParametersFieldNames)
obj.pi.tephs.(ParametersFieldNames{iLoadingParameters}).Enable=obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).Enable{1,1};
end
obj.bst.best_tephs
case 2 %Manual
obj.bst.best_tephs_manual
end
case 'ERP Measurement Protocol'
obj.bst.best_erp;
case 'TMS fMRI Protocol'
obj.tmsfmri_run
case 'TEP Measurement Protocol'
obj.bst.best_tep;
case 'Custom Protocol'
obj.customprotocol_run;
case 'rtus Intervention Protocol'
obj.rtus_intervention;
end
obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).ProtocolStatus={'Successful'};
obj.pmd.ProtocolStatus.listbox.String(obj.pmd.ProtocolStatus.listbox.Value)={'Successful'};
end
catch e
% if isempty(obj.info.ErrorMessage), obj.info.ErrorMessage='This Protcol has been stopped due to an error. Check your input parameters and MATLAB command line.'; end
% errordlg(obj.info.ErrorMessage,'BEST Toolbox');
fprintf(1,'The identifier was:\n%s',e.identifier);
fprintf(1,'\nThere was an error! The message was:\n%s',e.message);
obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).ProtocolStatus={'Error'};
obj.pmd.ProtocolStatus.listbox.String(obj.pmd.ProtocolStatus.listbox.Value)={'Error'};
obj.enable_listboxes;
rethrow(e)
end
end
function PauseUnpauseButton(obj,~,~)
obj.pmd.RunStopButton.String='Stop';
obj.pmd.PauseUnpauseButton.Enable='on';
if strcmp(obj.pmd.PauseUnpauseButton.String,'Pause') && ~strcmp(obj.info.event.current_measure,'rsEEG Measurement')
obj.pmd.PauseUnpauseButton.String='Unpause';
uiwait;
elseif strcmp(obj.pmd.PauseUnpauseButton.String,'Unpause')
obj.pmd.PauseUnpauseButton.String='Pause';
uiresume;
end
end
function DisableInteractivity(obj)
ParametersFieldNames=fieldnames(obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr));
for iLoadingParameters=1:numel(ParametersFieldNames)
if (isa(obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).(ParametersFieldNames{iLoadingParameters}),'char'))
obj.pi.hotspot.(ParametersFieldNames{iLoadingParameters}).String=obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).(ParametersFieldNames{iLoadingParameters});
elseif(isa(obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).(ParametersFieldNames{iLoadingParameters}),'double'))
obj.pi.hotspot.(ParametersFieldNames{iLoadingParameters}).Value=obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).(ParametersFieldNames{iLoadingParameters});
end
end
switch obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).Protocol{1,1}
case 'MEP Hotspot Search Protocol'
case 'MEP Measurement Protocol'
end
end
function disable_listboxes(obj)
obj.pmd.lb_measures.listbox.Enable='off';
obj.pmd.lb_sessions.listbox.Enable='off';
obj.pmd.ProtocolStatus.listbox.Enable='off';
end
function enable_listboxes(obj)
obj.pmd.lb_measures.listbox.Enable='on';
obj.pmd.lb_sessions.listbox.Enable='on';
obj.pmd.ProtocolStatus.listbox.Enable='on';
end
function cb_pmd_lb_session_keypressfcn(obj)
if (numel(obj.pmd.lb_sessions.listbox.String)==0 || obj.pmd.lb_sessions.listbox.Value==0)
return
else
value = double(get(gcf,'CurrentCharacter'));
if(value==117)
obj.cb_pmd_lb_sessions_moveup
elseif(value==100)
obj.cb_pmd_lb_sessions_movedown
end
end
end
function cb_pmd_lb_measure_keypressfcn(obj)
if (numel(obj.pmd.lb_measures.listbox.String)==0 || obj.pmd.lb_measures.listbox.Value==0)
return
else
value = double(get(gcf,'CurrentCharacter'));
if(value==117)
obj.cb_pmd_lb_measures_moveup
elseif(value==100)
obj.cb_pmd_lb_measures_movedown
end
end
end
function cb_pmd_exp_title_editfield(obj)
if(isvarname(obj.pmd.exp_title.editfield.String)==0)
errordlg('Experiment Title is an invalid string. Characters found in your string are not allowed by your operating system as filename. Please use a meaningful string that is not starting with a numeric character or space charachet and do not contain any special characters to proceed.','BEST Toolbox');
obj.pmd.exp_title.editfield.String=[];
return
end
end
function cb_pmd_lb_sessions_del(obj)
if (numel(obj.pmd.lb_sessions.listbox.String)==0 || obj.pmd.lb_sessions.listbox.Value==0)
return
else
answer = questdlg('If you want to delete this session, the data saved associated with this session will also be deleted, press DELETE to continue.','BEST Toolbox','Return','DELETE','Return');
switch answer
case 'DELETE'
selected_session=obj.pmd.lb_sessions.listbox.String(obj.pmd.lb_sessions.listbox.Value);
selected_session=selected_session{1};
obj.par.(selected_session)=[];
obj.bst.sessions.(selected_session)=[];
obj.info.session_matrix(obj.pmd.lb_sessions.listbox.Value)=[];
obj.pmd.lb_sessions.string(obj.pmd.lb_sessions.listbox.Value)=[];
obj.data.(selected_session)=[];
obj.info.session_no=obj.info.session_no-1;
obj.pmd.lb_sessions.listbox.String=obj.info.session_matrix;
if(obj.info.session_no~=0)
obj.pmd.lb_sessions.listbox.Value=1;
else
return;
end
obj.cb_session_listbox
case 'Return'
return
end
end
% summary of above steps
% find the value of listbox
% get the session name from the session listbox
% delete that from the par
% delete that from the bst
% delete that from anywhere in the listavailable
% minue one the session number
% update the session to be first one
% update the current session to be first one
end
function cb_pmd_lb_sessions_copy(obj)
if (numel(obj.pmd.lb_sessions.listbox.String)==0 || obj.pmd.lb_sessions.listbox.Value==0)
return
else
obj.info.session_copy_id=obj.info.session_copy_id+1;
obj.info.session_copied=obj.pmd.lb_sessions.listbox.String(obj.pmd.lb_sessions.listbox.Value);
end
end
function cb_pmd_lb_sessions_pasteup(obj)
if (obj.info.session_copy_id==0 || isempty(obj.info.session_copied)==1)
errordlg('No Session is copied, if you are trying to paste already pasted session, please copy it again.','BEST Toolbox');
return
else
if(obj.pmd.lb_sessions.listbox.Value-1~=0)
paste_value=obj.pmd.lb_sessions.listbox.Value-1;
else
return;
end
obj.info.session_matrix_copybuffer(1,obj.info.session_copy_id)=obj.info.session_copied;
obj.info.session_copied=obj.info.session_copied{1};
if any(strcmp(obj.info.session_matrix_copybuffer,obj.info.session_copied))
idx_exist=find(strcmp(obj.info.session_matrix_copybuffer, obj.info.session_copied));
idx_exist=num2str(numel(idx_exist));
new_session=obj.info.session_copied;
new_session=[new_session '_' 'copy' '_' idx_exist];
idx_exist=[];
else
new_session=obj.info.session_copied;
new_session=[new_session '_' 'copy'];
end
try
obj.par.(new_session)=obj.par.(obj.info.session_copied);
catch
end
index=obj.pmd.lb_sessions.listbox.Value;
str_a=obj.info.session_matrix(1:index-1);
str_b=new_session;
str_c=obj.info.session_matrix(index:numel(obj.info.session_matrix));
obj.info.session_matrix=[str_a str_b str_c];
obj.pmd.lb_sessions.string=obj.info.session_matrix;
obj.pmd.lb_sessions.listbox.String=obj.info.session_matrix;
obj.pmd.lb_sessions.listbox.Value=paste_value;
obj.info.sessoin_no=obj.info.session_no+1;
obj.data.(new_session)=obj.data.(obj.info.session_copied);
for i=1:numel(obj.data.(obj.info.session_copied).info.measurement_str_to_listbox)
obj.info.event.current_session=new_session;
obj.info.event.current_measure_fullstr=obj.data.(new_session).info.measurement_str_to_listbox(i);
obj.info.event.current_measure_fullstr=obj.info.event.current_measure_fullstr{1};
obj.info.event.current_measure_fullstr(obj.info.event.current_measure_fullstr == ' ') = '_';
obj.info.event.current_measure=obj.data.(new_session).info.measurement_str(i);
obj.info.event.current_measure=obj.info.event.current_measure{1};
obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).Enable{1,1}='on';
end
obj.info.session_copied=[];
obj.info.session_no=obj.info.session_no+1;
obj.cb_session_listbox;
end
end
function cb_pmd_lb_sessions_pastedown(obj)
if (obj.info.session_copy_id==0|| isempty(obj.info.session_copied)==1)
errordlg('No Session is copied, if you are trying to paste already pasted session, please copy it again.','BEST Toolbox');
return
else
paste_value=obj.pmd.lb_sessions.listbox.Value+1;
obj.info.session_matrix_copybuffer(1,obj.info.session_copy_id)=obj.info.session_copied;
obj.info.session_copied=obj.info.session_copied{1};
if any(strcmp(obj.info.session_matrix_copybuffer,obj.info.session_copied))
idx_exist=find(strcmp(obj.info.session_matrix_copybuffer, obj.info.session_copied));
idx_exist=num2str(numel(idx_exist));
new_session=obj.info.session_copied;
new_session=[new_session '_' 'copy' '_' idx_exist];
idx_exist=[];
else
new_session=obj.info.session_copied;
new_session=[new_session '_' 'copy'];
end
try
obj.par.(new_session)=obj.par.(obj.info.session_copied);
catch
end
index=obj.pmd.lb_sessions.listbox.Value;
str_a=obj.info.session_matrix(1:index);
str_b=new_session;
str_c=obj.info.session_matrix(index+1:numel(obj.info.session_matrix));
obj.info.session_matrix=[str_a str_b str_c];
obj.pmd.lb_sessions.string=obj.info.session_matrix;
obj.pmd.lb_sessions.listbox.String=obj.info.session_matrix;
obj.pmd.lb_sessions.listbox.Value=paste_value;
obj.info.sessoin_no=obj.info.session_no+1;
obj.data.(new_session)=obj.data.(obj.info.session_copied);
for i=1:numel(obj.data.(obj.info.session_copied).info.measurement_str_to_listbox)
obj.info.event.current_session=new_session;
obj.info.event.current_measure_fullstr=obj.data.(new_session).info.measurement_str_to_listbox(i);
obj.info.event.current_measure_fullstr=obj.info.event.current_measure_fullstr{1};
obj.info.event.current_measure_fullstr(obj.info.event.current_measure_fullstr == ' ') = '_';
obj.info.event.current_measure=obj.data.(new_session).info.measurement_str(i);
obj.info.event.current_measure=obj.info.event.current_measure{1};
obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).Enable{1,1}='on';
end
obj.info.session_copied=[];
obj.info.session_no=obj.info.session_no+1;
obj.cb_session_listbox;
end
end
function cb_pmd_lb_sessions_moveup(obj)
if (numel(obj.pmd.lb_sessions.listbox.String)==0 || obj.pmd.lb_sessions.listbox.Value==0)
return
else
if(numel(obj.pmd.lb_sessions.listbox.String)>1 && obj.pmd.lb_sessions.listbox.Value~=1)
moveup_session=obj.info.session_matrix(obj.pmd.lb_sessions.listbox.Value);
movedown_session=obj.info.session_matrix(obj.pmd.lb_sessions.listbox.Value-1);
obj.info.session_matrix(obj.pmd.lb_sessions.listbox.Value-1)=moveup_session;
obj.info.session_matrix(obj.pmd.lb_sessions.listbox.Value)=movedown_session;
obj.pmd.lb_sessions.string=obj.info.session_matrix;
obj.pmd.lb_sessions.listbox.String=obj.info.session_matrix;
obj.pmd.lb_sessions.listbox.Value=obj.pmd.lb_sessions.listbox.Value-1;
moveup_session=[];
movedown_session=[];
obj.cb_session_listbox
else
return
end
end
end
function cb_pmd_lb_sessions_movedown(obj)
if (numel(obj.pmd.lb_sessions.listbox.String)==0 || obj.pmd.lb_sessions.listbox.Value==0)
return
else
if(numel(obj.pmd.lb_sessions.listbox.String)>1 && obj.pmd.lb_sessions.listbox.Value<obj.info.session_no)
moveup_session=obj.info.session_matrix(obj.pmd.lb_sessions.listbox.Value+1);
movedown_session=obj.info.session_matrix(obj.pmd.lb_sessions.listbox.Value);
obj.info.session_matrix(obj.pmd.lb_sessions.listbox.Value)=moveup_session;
obj.info.session_matrix(obj.pmd.lb_sessions.listbox.Value+1)=movedown_session;
obj.pmd.lb_sessions.string=obj.info.session_matrix;
obj.pmd.lb_sessions.listbox.String=obj.info.session_matrix;
obj.pmd.lb_sessions.listbox.Value=obj.pmd.lb_sessions.listbox.Value+1;
moveup_session=[];
movedown_session=[];
obj.cb_session_listbox
else
return
end
end
end
function cb_pmd_lb_measures_del(obj)
if(numel(obj.pmd.lb_measures.listbox.String)==0 || obj.pmd.lb_measures.listbox.Value==0)
return
else
answer = questdlg('If you want to delete this measurement, the data saved associated with this measurement will also be deleted, press DELETE to continue.','BEST Toolbox','Return','DELETE','Return');
switch answer
case 'DELETE'
obj.info.event.current_session
obj.info.event.current_measure_fullstr
obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr)=[];
obj.bst.sessions.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr)=[];
obj.data.(obj.info.event.current_session).info.measurement_str(obj.pmd.lb_measures.listbox.Value)=[];
obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox(obj.pmd.lb_measures.listbox.Value)=[];
obj.data.(obj.info.event.current_session).info.measurement_str_original(obj.pmd.lb_measures.listbox.Value)=[];
obj.data.(obj.info.event.current_session).info.measurement_no=obj.data.(obj.info.event.current_session).info.measurement_no-1;
obj.pmd.lb_measures.listbox.String=obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox;
if(obj.data.(obj.info.event.current_session).info.measurement_no~=0)
obj.pmd.lb_measures.listbox.Value=1;
else
return;
end
obj.cb_measure_listbox
case 'Return'
return
end
end
end
function cb_pmd_lb_measures_copy(obj)
if(numel(obj.pmd.lb_measures.listbox.String)==0 || obj.pmd.lb_measures.listbox.Value==0)
return
else
obj.data.meas_copied=obj.pmd.lb_measures.listbox.String(obj.pmd.lb_measures.listbox.Value);
obj.data.meas_copied_orignial=obj.data.(obj.info.event.current_session).info.measurement_str_original(obj.pmd.lb_measures.listbox.Value);
obj.data.copied_frm_session=obj.info.event.current_session;
obj.info.copy_index=obj.info.copy_index+1;
end
end
function cb_pmd_lb_measures_pasteup(obj)
if(obj.info.copy_index<1 || isempty(obj.data.meas_copied)==1)
errordlg('No Measurement is copied, if you are trying to paste already pasted measurement, please copy it again.','BEST Toolbox');
return
else
if(obj.pmd.lb_measures.listbox.Value-1>=0)
if(obj.pmd.lb_measures.listbox.Value-1==0)
paste_value=obj.pmd.lb_measures.listbox.Value;
else
paste_value=obj.pmd.lb_measures.listbox.Value-1;
end
else
return;
end
obj.data.(obj.info.event.current_session).info.meas_copy_id=obj.data.(obj.info.event.current_session).info.meas_copy_id+1;
obj.data.(obj.info.event.current_session).info.meas_matrix_copybuffer(1,obj.data.(obj.info.event.current_session).info.meas_copy_id)=obj.data.meas_copied;
any(strcmp(obj.data.(obj.info.event.current_session).info.meas_matrix_copybuffer,obj.data.meas_copied))
if any(strcmp(obj.data.(obj.info.event.current_session).info.meas_matrix_copybuffer,obj.data.meas_copied))
idx_exist=find(strcmp(obj.data.(obj.info.event.current_session).info.meas_matrix_copybuffer,obj.data.meas_copied));
idx_exist=num2str(numel(idx_exist));
new_session=obj.data.meas_copied{1};
new_session=[new_session '_' 'copy' '_' idx_exist];
idx_exist=[];
else
new_session=obj.data.meas_copied;
new_session=[new_session '_' 'copy'];
end
try
new_session_forpar=new_session;
new_session_forpar(new_session_forpar == ' ') = '_';
meas_copied=obj.data.meas_copied{1};
meas_copied(meas_copied == ' ') = '_';
obj.par.(obj.info.event.current_session).(new_session_forpar)=obj.par.(obj.data.copied_frm_session).(meas_copied);
catch
disp('error at cb_pmd_lb_measures_pasteup')
end
index=obj.pmd.lb_measures.listbox.Value;
switch numel(obj.pmd.lb_measures.listbox.String)
case 0
obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox={new_session};
obj.data.meas_copied_orignial
obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox
obj.data.(obj.info.event.current_session).info.measurement_str=obj.data.meas_copied_orignial;
obj.data.(obj.info.event.current_session).info.measurement_str_original=obj.data.meas_copied_orignial;
obj.pmd.lb_measures.listbox.Value=1;
case 1
str_b=obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox(1);
str_a=new_session;
obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox=[str_a str_b];
str_b=obj.data.(obj.info.event.current_session).info.measurement_str_original(1);
str_a=obj.data.meas_copied_orignial;
obj.data.(obj.info.event.current_session).info.measurement_str=[str_a str_b];
obj.data.(obj.info.event.current_session).info.measurement_str_original=[str_a str_b];
obj.pmd.lb_measures.listbox.Value=1;
otherwise
if(obj.pmd.lb_sessions.listbox.Value>1)
str_a=obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox(1:index-1);
str_b=new_session;
str_c=obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox(index:numel(obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox));
obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox=[str_a str_b str_c];
str_a=obj.data.(obj.info.event.current_session).info.measurement_str_original(1:index-1);
str_b=obj.data.meas_copied_orignial;
str_c=obj.data.(obj.info.event.current_session).info.measurement_str_original(index:numel(obj.data.(obj.info.event.current_session).info.measurement_str_original));
obj.data.(obj.info.event.current_session).info.measurement_str=[str_a str_b str_c];
obj.data.(obj.info.event.current_session).info.measurement_str_original=[str_a str_b str_c];
obj.pmd.lb_measures.listbox.Value=paste_value;
else
str_b=obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox(1:index);
str_a=new_session;
obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox=[str_a str_b];
str_b=obj.data.(obj.info.event.current_session).info.measurement_str_original(1:index);
str_a=obj.data.meas_copied_orignial;
obj.data.(obj.info.event.current_session).info.measurement_str=[str_a str_b];
obj.data.(obj.info.event.current_session).info.measurement_str_original=[str_a str_b];
obj.pmd.lb_measures.listbox.Value=paste_value;
end
end
obj.pmd.lb_measures.listbox.String=obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox;
obj.data.(obj.info.event.current_session).info.measurement_no=obj.data.(obj.info.event.current_session).info.measurement_no+1;
obj.data.meas_copied=[];
obj.info.event.current_measure_fullstr=new_session_forpar;
obj.info.event.current_measure=obj.data.meas_copied_orignial;
obj.info.event.current_measure=obj.info.event.current_measure{1};
obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).Enable{1,1}='on';
obj.cb_measure_listbox;
end
end
function cb_pmd_lb_measures_pastedown(obj)
if(obj.info.copy_index<1|| isempty(obj.data.meas_copied)==1)
errordlg('No Measurement is copied, if you are trying to paste already pasted measurement, please copy it again.','BEST Toolbox');
return
else
obj.data.(obj.info.event.current_session).info.meas_copy_id=obj.data.(obj.info.event.current_session).info.meas_copy_id+1;
paste_value=obj.pmd.lb_measures.listbox.Value+1;
obj.data.(obj.info.event.current_session).info.meas_matrix_copybuffer(1,obj.data.(obj.info.event.current_session).info.meas_copy_id)=obj.data.meas_copied;
if any(strcmp(obj.data.(obj.info.event.current_session).info.meas_matrix_copybuffer,obj.data.meas_copied))
idx_exist=find(strcmp(obj.data.(obj.info.event.current_session).info.meas_matrix_copybuffer,obj.data.meas_copied));
idx_exist=num2str(numel(idx_exist));
new_session=obj.data.meas_copied{1};
new_session=[new_session '_' 'copy' '_' idx_exist];
idx_exist=[];
else
new_session=obj.data.meas_copied;
new_session=[new_session '_' 'copy'];
end
try
new_session_forpar=new_session;
new_session_forpar(new_session_forpar == ' ') = '_';
meas_copied=obj.data.meas_copied{1};
meas_copied(meas_copied == ' ') = '_';
obj.par.(obj.info.event.current_session).(new_session_forpar)=obj.par.(obj.data.copied_frm_session).(meas_copied);
catch
disp('error at cb_pmd_lb_measures_pastedown')
end
index=obj.pmd.lb_measures.listbox.Value;
switch numel(obj.pmd.lb_measures.listbox.String)
case 0
obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox={new_session};
obj.data.meas_copied_orignial
obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox
obj.data.(obj.info.event.current_session).info.measurement_str=obj.data.meas_copied_orignial;
obj.data.(obj.info.event.current_session).info.measurement_str_original=obj.data.meas_copied_orignial;
obj.pmd.lb_measures.listbox.Value=1;
case 1
str_a=obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox(1);
str_b=new_session;
obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox=[str_a str_b];
str_a=obj.data.(obj.info.event.current_session).info.measurement_str_original(1);
str_b=obj.data.meas_copied_orignial;
obj.data.(obj.info.event.current_session).info.measurement_str=[str_a str_b];
obj.data.(obj.info.event.current_session).info.measurement_str_original=[str_a str_b];
obj.pmd.lb_measures.listbox.Value=2;
otherwise
if(obj.pmd.lb_sessions.listbox.Value<(numel(obj.pmd.lb_measures.listbox.String)))
str_a=obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox(1:index);
str_b=new_session;
str_c=obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox(index+1:numel(obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox));
obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox=[str_a str_b str_c];
str_a=obj.data.(obj.info.event.current_session).info.measurement_str_original(1:index);
str_b=obj.data.meas_copied_orignial;
str_c=obj.data.(obj.info.event.current_session).info.measurement_str_original(index+1:numel(obj.data.(obj.info.event.current_session).info.measurement_str_original));
obj.data.(obj.info.event.current_session).info.measurement_str=[str_a str_b str_c];
obj.data.(obj.info.event.current_session).info.measurement_str_original=[str_a str_b str_c];
obj.pmd.lb_measures.listbox.Value=paste_value;
else
str_a=obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox(1:index);
str_b=new_session;
obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox=[str_a str_b];
str_a=obj.data.(obj.info.event.current_session).info.measurement_str_original(1:index);
str_b=obj.data.meas_copied_orignial;
obj.data.(obj.info.event.current_session).info.measurement_str=[str_a str_b];
obj.data.(obj.info.event.current_session).info.measurement_str_original=[str_a str_b];
obj.pmd.lb_measures.listbox.Value=paste_value;
end
end
obj.pmd.lb_measures.listbox.String=obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox;
obj.data.(obj.info.event.current_session).info.measurement_no=obj.data.(obj.info.event.current_session).info.measurement_no+1;
obj.data.meas_copied=[];
obj.info.event.current_measure_fullstr=new_session_forpar;
obj.info.event.current_measure=obj.data.meas_copied_orignial;
obj.info.event.current_measure=obj.info.event.current_measure{1};
obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).Enable{1,1}='on';
obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).ProtocolStatus={'created'};
obj.cb_measure_listbox;
end
end
function cb_pmd_lb_measures_moveup(obj)
if(numel(obj.pmd.lb_measures.listbox.String)==0 || obj.pmd.lb_measures.listbox.Value==0)
return
else
if(numel(obj.pmd.lb_measures.listbox.String)>1 && obj.pmd.lb_measures.listbox.Value~=1)
moveup_session=obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox(obj.pmd.lb_measures.listbox.Value);
movedown_session=obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox(obj.pmd.lb_measures.listbox.Value-1);
obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox(obj.pmd.lb_measures.listbox.Value-1)=moveup_session;
obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox(obj.pmd.lb_measures.listbox.Value)=movedown_session;
obj.pmd.lb_measures.listbox.String=obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox;
moveup_session=obj.data.(obj.info.event.current_session).info.measurement_str(obj.pmd.lb_measures.listbox.Value);
movedown_session=obj.data.(obj.info.event.current_session).info.measurement_str(obj.pmd.lb_measures.listbox.Value-1);
obj.data.(obj.info.event.current_session).info.measurement_str(obj.pmd.lb_measures.listbox.Value-1)=moveup_session;
obj.data.(obj.info.event.current_session).info.measurement_str(obj.pmd.lb_measures.listbox.Value)=movedown_session;
obj.data.(obj.info.event.current_session).info.measurement_str_original=obj.data.(obj.info.event.current_session).info.measurement_str;
obj.pmd.lb_measures.listbox.Value=obj.pmd.lb_measures.listbox.Value-1;
moveup_session=[];
movedown_session=[];
obj.cb_measure_listbox
else
return
end
end
end
function cb_pmd_lb_measures_movedown(obj)
if(numel(obj.pmd.lb_measures.listbox.String)==0 || obj.pmd.lb_measures.listbox.Value==0)
return
else
if(numel(obj.pmd.lb_measures.listbox.String)>1 && obj.pmd.lb_measures.listbox.Value<obj.data.(obj.info.event.current_session).info.measurement_no)
moveup_session=obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox(obj.pmd.lb_measures.listbox.Value+1);
movedown_session=obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox(obj.pmd.lb_measures.listbox.Value);
obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox(obj.pmd.lb_measures.listbox.Value)=moveup_session;
obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox(obj.pmd.lb_measures.listbox.Value+1)=movedown_session;
obj.pmd.lb_measures.listbox.String=obj.data.(obj.info.event.current_session).info.measurement_str_to_listbox;
moveup_session=obj.data.(obj.info.event.current_session).info.measurement_str(obj.pmd.lb_measures.listbox.Value+1);
movedown_session=obj.data.(obj.info.event.current_session).info.measurement_str(obj.pmd.lb_measures.listbox.Value);
obj.data.(obj.info.event.current_session).info.measurement_str(obj.pmd.lb_measures.listbox.Value)=moveup_session;
obj.data.(obj.info.event.current_session).info.measurement_str(obj.pmd.lb_measures.listbox.Value+1)=movedown_session;
obj.data.(obj.info.event.current_session).info.measurement_str_original=obj.data.(obj.info.event.current_session).info.measurement_str;
obj.pmd.lb_measures.listbox.Value=obj.pmd.lb_measures.listbox.Value+1;
moveup_session=[];
movedown_session=[];
obj.cb_measure_listbox
else
return
end
end
end
function cb_pmd_sub_code_editfield(obj)
if(isvarname(obj.pmd.sub_code.editfield.String)==0)
errordlg('Subject is an invalid string. Characters found in your string are not allowed by your operating system as filename. Please use a meaningful string that is not starting with a numeric character or space charachet and do not contain any special characters to proceed.','BEST Toolbox');
obj.pmd.sub_code.editfield.String=[];
return
end
end
function cb_pmd_lb_measure_menu_loadresult(obj)
if ~isfield(obj.bst.sessions,obj.info.event.current_session) || numel(obj.pmd.lb_measures.listbox.String)==0 %only sessions tree is added, add tree of measure here as well
errordlg('No results exist for this measurement, Please collect the data if you wish to see the results for this particular measure.','BEST Toolbox');
return
end
obj.fig.main.Widths([1 2 3])=[-1.15 -0 -3.35];
obj.bst.factorizeConditions
obj.resultsPanel;
obj.bst.inputs.Figures=obj.bst.sessions.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).Figures;
for i=1:obj.pr.axesno
ax=['ax' num2str(i)];
Parent=obj.pr.ax.(ax).Parent;
UIContextMenu=obj.pr.ax.(ax).UIContextMenu;
delete(allchild(Parent))
Figure=copy(obj.bst.inputs.Figures{i});
Figure.Parent=Parent;
Figure.UIContextMenu=UIContextMenu;
obj.pr.ax.(ax)=Figure;
end
%% better would be to save all the app.pr parameters in object too so that entire information is intact, when results is called those may be assigned from the obj.inputs
%% load all from particualr session and measure into inputs
%% call results
%% try copying in legacy mode so that all the necessary callbacks are copied too
%% reasign Parent --DONE!
%copy figures from
% clear inputs ,
% load Figures result from this particular measure and session into inputs
% obj.bst.inputs.rawData=obj.bst.sessions.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).RawData;
% obj.bst.inputs.results=obj.bst.sessions.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).Results;
% obj.bst.inputs.trial=1;
% for tt=1:obj.bst.inputs.totalTrials
% obj.bst.plotTrial;
% obj.bst.inputs.trial=obj.bst.inputs.trial+1;
% end
%% Old Code
% if(numel(obj.pmd.lb_measures.listbox.String)==0)
% return
% else
% if(strcmp(obj.par.(obj.info.event.current_session).(obj.info.event.current_measure_fullstr).runEnable,'off'))
% delete(obj.pr.mep.axes1)
% delete(obj.pr.hotspot.axes1)
% delete(obj.pr.mt.axes_mep)
% delete(obj.pr.mt.axes_mtplot)
% delete(obj.pr.ioc.axes_mep)
% delete(obj.pr.ioc.axes_scatplot)
% delete(obj.pr.ioc.axes_fitplot)
% switch obj.info.event.current_measure
% case 'MEP Measurement'
% obj.pr_mep;
% obj.bst.inputs.current_session=obj.info.event.current_session;
% obj.bst.inputs.current_measurement=obj.info.event.current_measure_fullstr;
% obj.bst.best_mep_posthoc();
% case 'MEP Hotspot Search'
% obj.pr_hotspot
% obj.bst.inputs.current_session=obj.info.event.current_session;
% obj.bst.inputs.current_measurement=obj.info.event.current_measure_fullstr;
% obj.bst.best_hotspot_posthoc();
% case 'MEP Motor Threshold Hunting'
% obj.pr_mt
% obj.bst.inputs.current_session=obj.info.event.current_session;
% obj.bst.inputs.current_measurement=obj.info.event.current_measure_fullstr;
% obj.bst.best_mt_posthoc();
% case 'MEP Dose Response Curve_sp'
% obj.pr_ioc
% obj.bst.inputs.current_session=obj.info.event.current_session;
% obj.bst.inputs.current_measurement=obj.info.event.current_measure_fullstr;
% obj.bst.best_ioc_posthoc();
% end
% else
% errordlg('No results exist for this measurement, Please collect the data if you wish to see the results for this particular measure.','BEST Toolbox');
% return
% end