Repository navigation
Expand file tree
/
Copy pathexploreFNIRS.m
More file actions
5465 lines (4176 loc) · 198 KB
/
Copy pathexploreFNIRS.m
File metadata and controls
5465 lines (4176 loc) · 198 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
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
function varargout = exploreFNIRS(varargin) % exploreFNIRS(data,timeShiftTo0,blStart,blEnd,blockStart,blockEnd,plotStart,plotEnd,barSegmentLength)
% exploreFNIRS is a program which organizes experimental FNIRS data into an exportable table, or for plotting
% Accepts a cell array of FNIRS structs (ideally with populated FNIRS.info fields and timeshifted so that the task/segment of interest starts at t=0 or the same time)
% Use the Groupby buttons to specify important grouping levels such as Session X Condition or Group X Trial depending on your variables of interest
% Behavioral and FNIRS data is averaged by default according to the within subject heirarchy options
% ie: a subjects average score is the average of their sessions each of which is the average of all trials (this hierarchy can be changed in the GUI)
% Alternatively averaging can be set to Flat to change it so that subject data is averaged without respect to experimental hierarchy (necessary for LME models)
% % ie: a subjects average score is the average of all their scores regardless of how many trials are in each session
% Plots are generated based on your groupby selection and the number of optodes/biomarkers you have selected to plot simultaneously
% There is an additional plotby button which allows one of the groupby factors to be used to split plots based on that factor
% (Otherwise all groups show up as different colors on the same plot)
% A variable from the info field may be assigned as a groupby factor (best used for non-numeric data)
% A second variable from the info field may be plotted and optionally used as a covariate in the LME outputs
% Plot colors may be selected automatically using defined color maps (or a mycolorfunc you define)
% Additionally manual colors may be saved/loaded in a 3x10color csv file (rows are r,g,b (from 0 to 1) and each column is a color)
% Exported data will come out as a CSV file with all barchart timepoints and All biomarkers for the currently selected groups (in wide format)
% Exporting as a MAT file will also contain grand average structs and other data
% Todo
% Implement units in plots (currently just assumes uM)
% Implement efficiency plots
% Implement post-hoc for LME
% Implement GLM approach for temporal data
% Implement region of interest grouping for channels
% Implement more flexible LME model options
% Better/3D parametric plots
% Parametric plots for correlation
% Ability to plot/analyze aux data
% See CHANGELOG.md for version history
% EXPLOREFNIRS MATLAB code for exploreFNIRS.fig
% EXPLOREFNIRS, by itself, creates a new EXPLOREFNIRS or raises the existing
% singleton*.
%
% H = EXPLOREFNIRS returns the handle to a new EXPLOREFNIRS or the handle to
% the existing singleton*.
%
% EXPLOREFNIRS('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in EXPLOREFNIRS.M with the given input arguments.
%
% EXPLOREFNIRS('Property','Value',...) creates a new EXPLOREFNIRS or raises
% the existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before exploreFNIRS_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to exploreFNIRS_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 exploreFNIRS
% Last Modified by GUIDE v2.5 26-Aug-2019 17:40:22
if pf2_base.env.isOctave()
error('pf2:gui:octaveUnsupported', ...
['exploreFNIRS requires MATLAB. Under Octave, use the programmatic ' ...
'group-analysis API instead of the GUI.']);
end
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @exploreFNIRS_OpeningFcn, ...
'gui_OutputFcn', @exploreFNIRS_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 exploreFNIRS is made visible.
function exploreFNIRS_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 exploreFNIRS (see VARARGIN)
% Choose default command line output for exploreFNIRS
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
pf2_base.applyLightTheme(hObject);
% Add File menu with Import options
mFile = uimenu(hObject, 'Label', 'File');
uimenu(mFile, 'Label', 'Import File...', 'Callback', @(s,e) menu_import_file_Callback(handles));
uimenu(mFile, 'Label', 'Import Directory...', 'Callback', @(s,e) menu_import_dir_Callback(handles));
initialize_gui(hObject, handles, false);
global ExFNIRS
if(~isfield(ExFNIRS,'defaultRootPath'))
[ExFNIRS_folder,~,~] = fileparts(mfilename('fullpath'));
ExFNIRS.defaultRootPath=ExFNIRS_folder;
curdir=cd;
cd(ExFNIRS.defaultRootPath);
addpath('base_functions','GUI','functions');
cd(curdir);
end
% Self-healing: ensure stats-toolbox fallbacks (nan*) are on the path when
% the toolbox is absent (END of path, so the toolbox wins when present).
pf2_base.ensureStatsFallbacks();
set(handles.text_versInfo,'String',exploreFNIRS.versInfo());
warning('OFF','MATLAB:table:RowsAddedExistingVars')
p=inputParser;
validScalarNum = @(x) isnumeric(x) && isscalar(x);
validScalarPosNum = @(x) isnumeric(x) && isscalar(x) && (x > 0);
if(~isfield(ExFNIRS,'settings')||~isfield(ExFNIRS.settings,'baseline_start'))
ExFNIRS.settings.baseline_start=0;
ExFNIRS.settings.baseline_end=5;
ExFNIRS.settings.block_start=5;
ExFNIRS.settings.block_end=65;
ExFNIRS.settings.plot_start=[];
ExFNIRS.settings.plot_end=[];
ExFNIRS.settings.barchart_resample_size=60;
ExFNIRS.settings.timeShiftTo0=true;
ExFNIRS.settings.ChannelMode='fNIR'; % valid is fNIR, ROI, and Aux
ExFNIRS.settings.ChannelModes={1,'fNIR';2,'ROI';3,'Aux'};
ExFNIRS.settings.processRaw=get(handles.checkbox_process_raw,'Value');
ExFNIRS.settings.LME_use_intercept=get(handles.checkbox_LME_use_intercept,'Value');
ExFNIRS.settings.LME_use_discreteTime=get(handles.checkbox_discreteTime,'Value');
% Map legacy checkbox to new TimeModel setting
if ExFNIRS.settings.LME_use_discreteTime
ExFNIRS.settings.LME_timeModel = 'discrete';
else
ExFNIRS.settings.LME_timeModel = 'polynomial';
end
ExFNIRS.settings.LME_polyOrder = 2;
ExFNIRS.settings.LME_randomFxStr='1|SubjectID';
ExFNIRS.settings.LME_use_customStr=get(handles.checkbox_lme_usecustom,'Value');
ExFNIRS.settings.topoSigThrehold={'p',0.05};
ExFNIRS.settings.LME_customStr='';
ExFNIRS.settings.use_info=true;
ExFNIRS.settings.use_group=get(handles.checkbox_use_group,'Value');
ExFNIRS.settings.plot_temporal_y0=get(handles.checkbox_yaxis,'Value');
ExFNIRS.settings.use_baseline=get(handles.checkbox_usebaseline,'Value');
ExFNIRS.dataHierarchy={'SubjectID','Session','Condition','Trial','Block'};
end
addParameter(p,'filename','',@ischar);
addOptional(p,'data',[],@(x) iscell(x) || isa(x, 'exploreFNIRS.core.Experiment')); % Cell of FNIRS structs, or an Experiment object
addOptional(p,'timeShiftTo0',ExFNIRS.settings.timeShiftTo0,@islogical); %Specifies whether to automatically shift the start of the FNIRS period to 0,
%best practice though is to turn this off and do it yourself before hand so that task starts at 0s and the baseline is before/after/during. See setT0fnirs()
addOptional(p,'blStart', ExFNIRS.settings.baseline_start,validScalarNum); %Time at which baseline starts (absolute)
addOptional(p,'blEnd',ExFNIRS.settings.baseline_end,validScalarNum); %Time at which baseline ends (absolute)
addOptional(p,'blockStart',ExFNIRS.settings.block_start,validScalarNum); %Time at which block or task starts (absolute)
addOptional(p,'blockEnd',ExFNIRS.settings.block_end,validScalarNum); %Time at which block or task ends (absolute)
addOptional(p,'plotStart',ExFNIRS.settings.plot_start,validScalarNum); %Default parameter for lower xlimit on plots (affects which models are displayed in barcharts and which timepoints are included)
addOptional(p,'plotEnd',ExFNIRS.settings.plot_end,validScalarNum); %Default parameter for upper xlimit on plots (see above note)
addOptional(p,'barSegmentLength', ExFNIRS.settings.barchart_resample_size,validScalarPosNum); %Default averaging/binning period for barcharts AND relevant export information
addOptional(p,'resampleSize',nan,validScalarPosNum); % ExFNIRS.settings.grandavg_resample_size, used for resampling
parse(p,varargin{:});
% Detect Experiment object and extract data + settings
inputData = p.Results.data;
experimentSource = [];
if isa(inputData, 'exploreFNIRS.core.Experiment')
experimentSource = inputData;
inputData = experimentSource.data;
% Map Experiment settings → ExFNIRS settings
exS = experimentSource.settings;
ExFNIRS.settings.baseline_start = exS.baseline(1);
ExFNIRS.settings.baseline_end = exS.baseline(2);
ExFNIRS.settings.block_start = exS.taskStart;
ExFNIRS.settings.use_baseline = exS.useBaseline;
ExFNIRS.settings.timeShiftTo0 = false;
ExFNIRS.dataHierarchy = experimentSource.hierarchy;
if exS.barBinSize > 0
ExFNIRS.settings.barchart_resample_size = exS.barBinSize;
else
% barBinSize=0 means full task window; derive from task duration
ExFNIRS.settings.barchart_resample_size = -1; % placeholder, resolved below
end
if exS.resampleRate > 0
ExFNIRS.settings.grandavg_resample_size = exS.resampleRate;
end
% Map avgMode → within_sub_avg_mode popup index
switch lower(exS.avgMode)
case 'none', ExFNIRS.settings.within_sub_avg_mode = 1;
case 'flat', ExFNIRS.settings.within_sub_avg_mode = 2;
case 'hierarchy', ExFNIRS.settings.within_sub_avg_mode = 3;
end
fprintf('Loaded Experiment object (%d segments)\n', length(inputData));
end
if ~isempty(inputData) || ~isfield(ExFNIRS, 'data')
ExFNIRS.data = inputData;
if size(ExFNIRS.data,2) > size(ExFNIRS.data,1)
ExFNIRS.data = ExFNIRS.data';
end
elseif ~isempty(p.Results.filename)
exploreFNIRS.loadEx(p.Results.filename);
end
if isempty(experimentSource)
ExFNIRS.settings.baseline_start=p.Results.blStart;
ExFNIRS.settings.baseline_end=p.Results.blEnd;
ExFNIRS.settings.block_start=p.Results.blockStart;
ExFNIRS.settings.block_end=p.Results.blockEnd;
ExFNIRS.settings.plot_start=p.Results.plotStart;
ExFNIRS.settings.plot_end=p.Results.plotEnd;
ExFNIRS.settings.barchart_resample_size=p.Results.barSegmentLength;
ExFNIRS.settings.grandavg_resample_size=p.Results.resampleSize;
else
% Use Experiment taskEnd if set, otherwise derive from data
exS = experimentSource.settings;
if isfinite(exS.taskEnd)
ExFNIRS.settings.block_end = exS.taskEnd;
else
firstSeg = ExFNIRS.data{1};
if isfield(firstSeg, 'time') && ~isempty(firstSeg.time)
ExFNIRS.settings.block_end = max(firstSeg.time);
end
end
% Derive bar bin size from task window if not explicitly set
if ExFNIRS.settings.barchart_resample_size <= 0
ExFNIRS.settings.barchart_resample_size = ...
ExFNIRS.settings.block_end - ExFNIRS.settings.block_start;
end
ExFNIRS.settings.plot_start = min(0, ExFNIRS.settings.block_start);
ExFNIRS.settings.plot_end = ExFNIRS.settings.block_end;
end
segInfoVars={'Session','Trial','Block','Condition','Time'};
randFxStr{1}='1|SubjectID';
for i=2:2:length(segInfoVars)*2
randFxStr{i}=sprintf('%s|SubjectID',segInfoVars{(i)/2});
randFxStr{i+1}=sprintf('-1+%s|SubjectID',segInfoVars{(i)/2});
end
set(handles.popupmenu_lmer_randomeffects,'String',randFxStr);
ExFNIRS.settings.LME_randomFxStrs=randFxStr;
if(ExFNIRS.settings.processRaw)
set(handles.listbox_raw_methods,'Enable','on');
else
set(handles.listbox_raw_methods,'Enable','off');
set(handles.listbox_raw_methods,'Value',1);
end
if(isempty(ExFNIRS.settings.plot_start))
ExFNIRS.settings.plot_start=min(0,ExFNIRS.settings.block_start);
end
if(isempty(ExFNIRS.settings.plot_end))
ExFNIRS.settings.plot_end=ExFNIRS.settings.block_end;
end
if ~isempty(experimentSource)
% Set GUI widgets to match Experiment-provided values
set(handles.popupmenu_within_sub_avg,'Value', ExFNIRS.settings.within_sub_avg_mode);
set(handles.checkbox_usebaseline,'Value', ExFNIRS.settings.use_baseline);
else
ExFNIRS.settings.within_sub_avg_mode=get(handles.popupmenu_within_sub_avg,'Value');
ExFNIRS.settings.timeShiftTo0=p.Results.timeShiftTo0;
end
set(handles.listbox_hierarchy,'String',ExFNIRS.dataHierarchy(2:end));
set(handles.edit_baseline_start,'String',sprintf('%.2f',ExFNIRS.settings.baseline_start));
set(handles.edit_baseline_end,'String',sprintf('%.2f',ExFNIRS.settings.baseline_end));
set(handles.edit_block_start,'String',sprintf('%.2f',ExFNIRS.settings.block_start));
set(handles.edit_block_end,'String',sprintf('%.2f',ExFNIRS.settings.block_end));
set(handles.edit_plot_start,'String',sprintf('%.2f',ExFNIRS.settings.plot_start));
set(handles.edit_plot_end,'String',sprintf('%.2f',ExFNIRS.settings.plot_end));
set(handles.edit_barchart_resample_size,'String',sprintf('%.2f',ExFNIRS.settings.barchart_resample_size));
set(handles.checkbox_process_raw,'Value',ExFNIRS.settings.processRaw);
strs=get(handles.popupmenu_info_group,'String');
val=get(handles.popupmenu_info_group,'Value');
if(~iscell(strs))
selStr=strs;
else
selStr=strs{val};
end
ExFNIRS.settings.curInfoGroup=selStr;
strs=get(handles.popupmenu_groupby_info_field,'String');
val=get(handles.popupmenu_groupby_info_field,'Value');
if(~iscell(strs))
selStr=strs;
else
selStr=strs{val};
end
ExFNIRS.settings.curInfoGroupBy=selStr;
if(isempty(ExFNIRS.data))
error('Must supply data!');
end
initializeGUIvalues(handles);
% UIWAIT makes exploreFNIRS wait for user response (see UIRESUME)
% uiwait(handles.figure1);
function menu_import_file_Callback(handles)
% Import a single fNIRS file and open a new exploreFNIRS instance
try
data = pf2.import.import();
catch ME
errordlg(ME.message, 'Import Error');
return;
end
if isempty(data), return; end
if isstruct(data), data = {data}; end
exploreFNIRS(data);
function menu_import_dir_Callback(handles)
% Import a directory of fNIRS files and open a new exploreFNIRS instance
dirPath = uigetdir('', 'Select fNIRS Data Directory');
if isequal(dirPath, 0), return; end
try
data = pf2.import.import(dirPath);
catch ME
errordlg(ME.message, 'Import Error');
return;
end
if isempty(data), return; end
if isstruct(data), data = {data}; end
exploreFNIRS(data);
function PopulateGUIfields(dataTable,handles)
global ExFNIRS
fieldNames={'SubjectID','Group','Subgroup','Session','Trial','Condition','Block'};
defaultFields={'Group','Condition'};
for f = 1:length(fieldNames)
uItems=unique(dataTable.(fieldNames{f}));
lowerNamePart=fieldNames{f};
lowerNamePart(1)=lower(lowerNamePart(1));
listboxName=sprintf('listbox_%s',lowerNamePart);
checkboxName=sprintf('checkbox_%s_plotby',lowerNamePart);
set(handles.(listboxName),'String',uItems);
set(handles.(listboxName),'Value',1:length(uItems));
if(length(uItems)<=1)
set(handles.(listboxName),'Enable','off');
if(~strcmp(checkboxName,'checkbox_subgroup_plotby'))
set(handles.(checkboxName),'Enable','off');
set(handles.(checkboxName),'Value',0);
end
ExFNIRS.settings.plotby.(fieldNames{f})=0;
else
set(handles.(listboxName),'Enable','on');
if(~strcmp(checkboxName,'checkbox_subgroup_plotby'))
set(handles.(checkboxName),'Enable','on');
set(handles.(checkboxName),'Value',ismember(fieldNames{f},defaultFields));
else
set(handles.checkbox_group_plotby,'Enable','on');
end
ExFNIRS.settings.plotby.(fieldNames{f})=ismember(fieldNames{f},defaultFields);
end
end
curRawMethods=processFNIRS2_configureMethods('currentRawMethodsCallback',1,[],handles);
if(~isempty(curRawMethods))
set(handles.listbox_raw_methods,'String',curRawMethods);
end
curOxyMethods=processFNIRS2_configureMethods('currentOxyMethodsCallback',1,[],handles);
if(~isempty(curOxyMethods))
set(handles.listbox_oxy_methods,'String',curOxyMethods);
end
setExChannelMode('ROI',handles,true)%initialize ROI fields
setExChannelMode('fNIR',handles,true);
% --- Outputs from this function are returned to the command line.
function varargout = exploreFNIRS_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)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --------------------------------------------------------------------
function initialize_gui(fig_handle, handles, isreset)
% If the metricdata field is present and the reset flag is false, it means
% we are we are just re-initializing a GUI by calling it from the cmd line
% while it is up. So, bail out as we dont want to reset the data.
% Update handles structure
guidata(handles.figure1, handles);
% --- Executes on selection change in listbox_subjectID.
function listbox_subjectID_Callback(hObject, eventdata, handles)
% hObject handle to listbox_subjectID (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 listbox_subjectID contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox_subjectID
global ExFNIRS
if(ExFNIRS.settings.updateOnChange)
updateSelectedTable(handles);
else
flagForUpdate(true,handles);
end
function flagForUpdate(UpdateNeeded,handles)
global ExFNIRS
if(~isfield(ExFNIRS,'UpdateNeeded'))
ExFNIRS.UpdateNeeded=3;
end
if(UpdateNeeded>0)
if(ExFNIRS.UpdateNeeded<UpdateNeeded) % 1 indicates that table just needs to be arranged and averaged
ExFNIRS.UpdateNeeded=UpdateNeeded; %2 indicates fNIRS data needs to be resampled as well
% 3 indicates fNIRS must be
% reprocessed entirely
% (ie new method)
% 4 indicates that entire
% dataset/ data table needs to
% be reproduced
end
set(handles.pushbutton_process_selection,'BackgroundColor','Red');
updateSelectedTable(handles,false);
else
ExFNIRS.UpdateNeeded=false;
set(handles.pushbutton_process_selection,'BackgroundColor','Green');
end
% --- Executes during object creation, after setting all properties.
function listbox_subjectID_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox_subjectID (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox 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 listbox_group.
function listbox_group_Callback(hObject, eventdata, handles)
% hObject handle to listbox_group (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 listbox_group contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox_group
global ExFNIRS
if(ExFNIRS.settings.updateOnChange)
updateSelectedTable(handles);
else
flagForUpdate(true,handles);
end
% --- Executes during object creation, after setting all properties.
function listbox_group_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox_group (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox 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 listbox_session.
function listbox_session_Callback(hObject, eventdata, handles)
% hObject handle to listbox_session (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 listbox_session contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox_session
global ExFNIRS
if(ExFNIRS.settings.updateOnChange)
updateSelectedTable(handles);
else
flagForUpdate(true,handles);
end
% --- Executes during object creation, after setting all properties.
function listbox_session_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox_session (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox 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 listbox_trial.
function listbox_trial_Callback(hObject, eventdata, handles)
% hObject handle to listbox_trial (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 listbox_trial contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox_trial
global ExFNIRS
if(ExFNIRS.settings.updateOnChange)
updateSelectedTable(handles);
else
flagForUpdate(true,handles);
end
% --- Executes during object creation, after setting all properties.
function listbox_trial_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox_trial (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox 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 listbox_condition.
function listbox_condition_Callback(hObject, eventdata, handles)
% hObject handle to listbox_condition (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 listbox_condition contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox_condition
global ExFNIRS
if(ExFNIRS.settings.updateOnChange)
updateSelectedTable(handles);
else
flagForUpdate(true,handles);
end
% --- Executes during object creation, after setting all properties.
function listbox_condition_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox_condition (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox 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 pushbutton_group_select_all.
function pushbutton_group_select_all_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_group_select_all (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global ExFNIRS
if(ExFNIRS.settings.use_group)
strs=get(handles.listbox_group,'String');
if(iscell(strs)||ismatrix(strs))
set(handles.listbox_group,'Value',[1:size(strs,1)]);
end
else
strs=get(handles.listbox_subgroup,'String');
if(iscell(strs)||ismatrix(strs))
set(handles.listbox_subgroup,'Value',[1:size(strs,1)]);
end
end
if(ExFNIRS.settings.updateOnChange)
updateSelectedTable(handles);
else
flagForUpdate(true,handles);
end
% --- Executes on button press in pushbutton_group_select_none.
function pushbutton_group_select_none_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_group_select_none (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global ExFNIRS
if(ExFNIRS.settings.use_group)
set(handles.listbox_group,'Value',[]);
else
set(handles.listbox_subgroup,'Value',[]);
end
% --- Executes on button press in pushbutton_session_select_all.
function pushbutton_session_select_all_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_session_select_all (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
strs=get(handles.listbox_session,'String');
if(iscell(strs)||ismatrix(strs))
set(handles.listbox_session,'Value',[1:size(strs,1)]);
end
global ExFNIRS
if(ExFNIRS.settings.updateOnChange)
updateSelectedTable(handles);
else
flagForUpdate(true,handles);
end
% --- Executes on button press in pushbutton_session_select_none.
function pushbutton_session_select_none_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_session_select_none (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.listbox_session,'Value',[]);
% --- Executes on button press in pushbutton_trial_select_all.
function pushbutton_trial_select_all_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_trial_select_all (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
strs=get(handles.listbox_trial,'String');
if(iscell(strs)||ismatrix(strs))
set(handles.listbox_trial,'Value',[1:size(strs,1)]);
end
global ExFNIRS
if(ExFNIRS.settings.updateOnChange)
updateSelectedTable(handles);
else
flagForUpdate(true,handles);
end
% --- Executes on button press in pushbutton_trial_select_none.
function pushbutton_trial_select_none_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_trial_select_none (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.listbox_trial,'Value',[]);
% --- Executes on button press in pushbutton_condition_select_all.
function pushbutton_condition_select_all_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_condition_select_all (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
strs=get(handles.listbox_condition,'String');
if(iscell(strs)||ismatrix(strs))
set(handles.listbox_condition,'Value',[1:size(strs,1)]);
end
global ExFNIRS
if(ExFNIRS.settings.updateOnChange)
updateSelectedTable(handles);
else
flagForUpdate(true,handles);
end
% --- Executes on button press in pushbutton_condition_select_none.
function pushbutton_condition_select_none_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_condition_select_none (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.listbox_condition,'Value',[]);
% --- Executes on button press in pushbutton_subjectID_select_all.
function pushbutton_subjectID_select_all_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_subjectID_select_all (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
strs=get(handles.listbox_subjectID,'String');
if(iscell(strs)||ismatrix(strs))
set(handles.listbox_subjectID,'Value',[1:size(strs,1)]);
end
global ExFNIRS
if(ExFNIRS.settings.updateOnChange)
updateSelectedTable(handles);
else
flagForUpdate(true,handles);
end
% --- Executes on button press in pushbutton_subjectID_select_none.
function pushbutton_subjectID_select_none_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_subjectID_select_none (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.listbox_subjectID,'Value',[]);
function edit_baseline_start_Callback(hObject, eventdata, handles)
% hObject handle to edit_baseline_start (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 edit_baseline_start as text
% str2double(get(hObject,'String')) returns contents of edit_baseline_start as a double
global ExFNIRS
ExFNIRS.settings.baseline_start=str2num(get(handles.edit_baseline_start,'String'));
set(handles.edit_baseline_start,'String',sprintf('%.2f',ExFNIRS.settings.baseline_start));
if(ExFNIRS.settings.updateOnChange)
updateSelectedTable(handles);
else
flagForUpdate(2,handles);
end
exploreFNIRS.plotExTimeline();
% --- Executes during object creation, after setting all properties.
function edit_baseline_start_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_baseline_start (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
function edit_baseline_end_Callback(hObject, eventdata, handles)
% hObject handle to edit_baseline_end (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 edit_baseline_end as text
% str2double(get(hObject,'String')) returns contents of edit_baseline_end as a double
global ExFNIRS
ExFNIRS.settings.baseline_end=str2num(get(handles.edit_baseline_end,'String'));
set(handles.edit_baseline_end,'String',sprintf('%.2f',ExFNIRS.settings.baseline_end));
if(ExFNIRS.settings.updateOnChange)
updateSelectedTable(handles);
else
flagForUpdate(2,handles);
end
exploreFNIRS.plotExTimeline();
% --- Executes during object creation, after setting all properties.
function edit_baseline_end_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_baseline_end (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
function edit_block_start_Callback(hObject, eventdata, handles)
% hObject handle to edit_block_start (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 edit_block_start as text
% str2double(get(hObject,'String')) returns contents of edit_block_start as a double
global ExFNIRS
ExFNIRS.settings.block_start=str2num(get(handles.edit_block_start,'String'));
set(handles.edit_block_start,'String',sprintf('%.2f',ExFNIRS.settings.block_start));
syncBlockSettingsUI(handles);
exploreFNIRS.plotExTimeline();
if(ExFNIRS.settings.updateOnChange)
updateSelectedTable(handles);
else
flagForUpdate(2,handles);
end
% --- Executes during object creation, after setting all properties.
function edit_block_start_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_block_start (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
function edit_block_end_Callback(hObject, eventdata, handles)
% hObject handle to edit_block_end (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 edit_block_end as text
% str2double(get(hObject,'String')) returns contents of edit_block_end as a double
global ExFNIRS
ExFNIRS.settings.block_end=str2num(get(handles.edit_block_end,'String'));
set(handles.edit_block_end,'String',sprintf('%.2f',ExFNIRS.settings.block_end));
syncBlockSettingsUI(handles);
exploreFNIRS.plotExTimeline();
% --- Executes during object creation, after setting all properties.
function edit_block_end_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_block_end (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
function edit_plot_start_Callback(hObject, eventdata, handles)
% hObject handle to edit_plot_start (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 edit_plot_start as text
% str2double(get(hObject,'String')) returns contents of edit_plot_start as a double
global ExFNIRS
ExFNIRS.settings.plot_start=str2num(get(handles.edit_plot_start,'String'));
set(handles.edit_plot_start,'String',sprintf('%.2f',ExFNIRS.settings.plot_start));
exploreFNIRS.plotExTimeline();
% --- Executes during object creation, after setting all properties.
function edit_plot_start_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_plot_start (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
function edit_plot_end_Callback(hObject, eventdata, handles)
% hObject handle to edit_plot_end (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 edit_plot_end as text
% str2double(get(hObject,'String')) returns contents of edit_plot_end as a double
global ExFNIRS
ExFNIRS.settings.plot_end=str2num(get(handles.edit_plot_end,'String'));
set(handles.edit_plot_end,'String',sprintf('%.2f',ExFNIRS.settings.plot_end));
exploreFNIRS.plotExTimeline();
% --- Executes during object creation, after setting all properties.
function edit_plot_end_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_plot_end (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
function edit_barchart_resample_size_Callback(hObject, eventdata, handles)
% hObject handle to edit_barchart_resample_size (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 edit_barchart_resample_size as text
% str2double(get(hObject,'String')) returns contents of edit_barchart_resample_size as a double
global ExFNIRS
ExFNIRS.settings.barchart_resample_size=str2num(get(handles.edit_barchart_resample_size,'String'));
set(handles.edit_barchart_resample_size,'String',sprintf('%.2f',ExFNIRS.settings.barchart_resample_size));
if(ExFNIRS.settings.updateOnChange)
updateSelectedTable(handles);
else
flagForUpdate(2,handles);
end
exploreFNIRS.plotExTimeline();
% --- Executes during object creation, after setting all properties.
function edit_barchart_resample_size_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_barchart_resample_size (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 listbox_optode.
function listbox_optode_Callback(hObject, eventdata, handles)
% hObject handle to listbox_optode (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB