-
Notifications
You must be signed in to change notification settings - Fork 1
/
OFFAD.m
110 lines (91 loc) · 4.47 KB
/
OFFAD.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
function OFFAD( arg )
%
% Opening page: Start new study or load previous
%
% Author: Christian Harding 2022
% OFF Period Automated Detection (OFFAD) toolbox
% christian.harding@sjc.ox.uk
%
% Requires:
% - Statistics and Machine learning toolbox
% - Signal processing toolbox
%
if nargin < 1 % Starting new study
% Clear exisiting GUI
hh = findobj('Type','figure','-regexp','Tag','OFFAD*');
if ~isempty(hh)
warning('There can be only one OFFAD window open, closing existing windows');
delete(hh);
end
% Get screensize to set figure position
screensize = get( groot, 'Screensize' );
% Create inital GUI figure
g.Main = figure('name', 'OFFAD (OFF_period Automated Detection)', ...
'numbertitle', 'off', ...
'Position',[screensize(3)/4,screensize(4)/8,screensize(3)/2,screensize(4)/1.4], ...
'Toolbar','none',...
'Menubar','none',...
'Tag','OFFAD');
% Button to start a new study
uicontrol(g.Main,'Style', 'pushbutton','String','New study (no presets)',...
'FontWeight','bold','FontSize',20,...
'BackgroundColor',[0.3 0.8 0.8],'Units','normalized',...
'Position',[0.2 0.7 0.6 0.25],...
'Tag','M_IMPORT',...
'Callback',['OFFAD_importdata;']);
% Button to start a new study using presets from a previous study
uicontrol(g.Main,'Style', 'pushbutton','String','New study (use presets)',...
'FontWeight','bold','FontSize',20,...
'BackgroundColor',[0.3 0.8 0.8],'Units','normalized',...
'Position',[0.2 0.4 0.6 0.25],...
'Tag','M_IMPORT_PRE',...
'Callback',['[filename, filepath] = uigetfile(''*'', ''Select file''); [OFFDATA] = OFFAD_preset([filepath,filename]);clear filename filepath']);
% Button load and view the output from a previous study
uicontrol(g.Main,'Style', 'pushbutton','String','Load previous study',...
'FontWeight','bold','FontSize',20,...
'BackgroundColor',[0.3 0.8 0.8],'Units','normalized',...
'Tag','M_LOAD',...
'Position',[0.2 0.1 0.6 0.25],'Callback',['uiload;' 'global OFFDATA;' 'if ~isempty(OFFDATA);'...
'OFFAD(''redraw'');' 'end;']);
else % Viewing output data from current or previous study
% Make other tabs (data import, clustering etc.) invisible
set(findobj('Tag','M_IMPORT'),'Visible','Off')
set(findobj('Tag','M_IMPORT_PRE'),'Visible','Off')
set(findobj('Tag','M_LOAD'),'Visible','Off')
set(findobj('Tag','OFFAD'),'Visible','On')
g.Main=findobj('Tag','OFFAD');
global OFFDATA
% Display name of study being viewed
uicontrol(g.Main,'Style', 'text','String',['Dataset: ' OFFDATA.datasetname],...
'FontWeight','bold','FontSize',18,...
'Units','normalized',...
'Position',[0.01 0.85 0.98 0.1]);
% Button to open OFF/ON period scroller
uicontrol(g.Main,'Style', 'pushbutton','String','Scroll through OFF/ON periods',...
'FontWeight','bold','FontSize',18,...
'BackgroundColor',[0.3 0.8 0.8],'Units','normalized',...
'Position',[0.2 0.6 0.6 0.15],...
'Tag','M_VIEWER',...
'Callback','OFFAD_scroll(OFFDATA);');
% Button to compute and view statistics of OFF/ON period detection
uicontrol(g.Main,'Style', 'pushbutton','String','Compute channel statistics',...
'FontWeight','bold','FontSize',18,...
'BackgroundColor',[0.3 0.8 0.8],'Units','normalized',...
'Position',[0.2 0.4 0.6 0.15],...
'Tag','M_CHANSTAT',...
'Callback','[OFFDATA]=OFFAD_channelstats(OFFDATA,1);');
% Button to save changes to dataset being viewed to current folder
uicontrol(g.Main,'Style', 'pushbutton','String','Save to current folder',...
'FontWeight','bold','FontSize',18,...
'BackgroundColor',[0.3 0.8 0.8],'Units','normalized',...
'Position',[0.2 0.2 0.6 0.15],...
'Tag','M_SAVECURR',...
'Callback','save([OFFDATA.datasetname,''.mat''],''OFFDATA'')');
% Button to save changes to dataset being viewed to a new folder
uicontrol(g.Main,'Style', 'pushbutton','String','Save to new folder',...
'FontWeight','bold','FontSize',18,...
'BackgroundColor',[0.3 0.8 0.8],'Units','normalized',...
'Position',[0.2 0.02 0.6 0.15],...
'Tag','M_SAVECURR',...
'Callback','uisave(''OFFDATA'',OFFDATA.datasetname)');
end