-
Notifications
You must be signed in to change notification settings - Fork 0
/
SavingSection.m
156 lines (121 loc) · 5.79 KB
/
SavingSection.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
% [x, y] = SavingSection(obj, action, x, y)
%
% Section that takes care of saving/loading, etc.
%
% PARAMETERS:
% -----------
%
% obj Default object argument.
%
% action One of:
% 'init' To initialise the section and set up the GUI
% for it
%
% 'reinit' Delete all of this section's GUIs and data,
% and reinit, at the same position on the same
% figure as the original section GUI was placed.
%
% 'savesets' Save GUI settings to a file
%
% 'loadsets' Load GUI settings to a file
%
% 'savedata' Save all SoloParamHandles to a file
%
% 'loaddata' Load all SoloParamHandles from a file
%
%
% x, y Only relevant to action = 'init'; they indicate the initial
% position to place the GUI at, in the current figure window
%
% RETURNS:
% --------
%
% [x, y] When action == 'init', returns x and y, pixel positions on
% the current figure, updated after placing of this section's GUI.
%
function [x, y] = SavingSection(obj, action, x, y)
GetSoloFunctionArgs;
switch action
case 'init', % ------------ CASE INIT --------------------
% Save the figure and the position in the figure where we are
% going to start adding GUI elements:
SoloParamHandle(obj, 'my_gui_info', 'value', [x y gcf]);
% PushButtonParam(obj, 'loaddata', x, y, 'label', 'Load Data');
% set_callback(loaddata, {mfilename, 'loaddata'}); next_row(y);
% PushButtonParam(obj, 'savedata', x, y, 'label', 'Save Data');
% set_callback(savedata, {mfilename, 'savedata'}); next_row(y, 1.5);
EditParam(obj, 'MouseName', 'JF000', x, y); next_row(y, 1.5);
PushButtonParam(obj, 'loadsets', x, y, 'label', 'Load Settings');
set_callback(loadsets, {mfilename, 'loadsets'});
next_row(y);
PushButtonParam(obj, 'savesets', x, y, 'label', 'Save Settings');
set_callback(savesets, {mfilename, 'savesets'});
next_row(y, 1.5);
% PushButtonParam(obj, 'loaddata', x, y, 'label', 'Load Data');
% set_callback(loaddata, {mfilename, 'loaddata'});
% next_row(y);
PushButtonParam(obj, 'savedata', x, y, 'label', 'Save Data');
set_callback(savedata, {mfilename, 'savedata'});
next_row(y, 1.5);
% SubheaderParam(obj, 'sectiontitle', 'Saving/Loading', x, y);
% next_row(y, 1.5);
%
SoloParamHandle(obj, 'SaveTime');
SoloParamHandle(obj, 'hostname', 'value', get_hostname);
EditParam(obj, 'Weight', 'Not recorded', x, y); next_row(y);
EditParam(obj, 'WeightAfterExp', 'Not recorded', x, y); next_row(y);
MenuParam(obj, 'HeadFixed', {'Fixed w/o anesthesia','Fixed after anesthesia','Not fixed'},'Fixed after anesthesia', x, y); next_row(y);
MenuParam(obj, 'Lighting', {'IR Security Cam','Diffuse 940nm for Security Cam','940nm High-speed Imaging','White light','Totally Dark'},'Diffuse 940nm for Security Cam', x, y); next_row(y);
MenuParam(obj, 'Punishment', {'None','ExtraITI','60 psi',...
'55 psi','50 psi','45 psi','40 psi','35 psi','30 psi','25 psi',...
'20 psi','15 psi','10 psi','Quinine'},'ExtraITI', x, y); next_row(y);
MenuParam(obj, 'WhiskerSet', {'Full','C2 only','None','Row C only'},'Full', x, y);
next_row(y, 1);
% Record which rig experiment was run on:
[status,host] = system('hostname');
SoloParamHandle(obj, 'RigComputer', 'value', host);
SoloParamHandle(obj, 'SaveTime');
% PushButtonParam(obj, 'loadsets', x, y, 'label', 'Load Settings');
% set_callback(loadsets, {mfilename, 'loadsets'});
% next_row(y);
% PushButtonParam(obj, 'savesets', x, y, 'label', 'Save Settings');
% set_callback(savesets, {mfilename, 'savesets'});
% next_row(y, 1.5);
SubheaderParam(obj, 'sectiontitle', 'Documentation', x, y);
next_row(y, 1.5);
return;
case 'savesets', % ------------ CASE SAVESETS --------------------
SaveTime.value = datestr(now);
save_solouiparamvalues(value(MouseName));
disp(['Settings saved at ' value(SaveTime) ' for ' value(MouseName)]);
return;
case 'loadsets', % ------------ CASE LOADSETS --------------------
load_solouiparamvalues(value(MouseName));
return;
case 'autosave', % ------------ CASE AUTOSAVE --------------------
sp_autosave(value(MouseName));
return;
case 'savedata', % ------------ CASE SAVEDATA --------------------
SaveTime.value = datestr(now);
% Get string from annotation object, put in a SoloParamHandle (notes) which will be saved:
% notes.value = get(value(noteshandle),'String');
save_soloparamvalues(value(MouseName));
disp(['Data saved at ' value(SaveTime) ' for ' value(MouseName)]);
return;
% case 'loaddata', % ------------ CASE LOADDATA --------------------
% load_soloparamvalues(value(MouseName));
%
% return;
case 'reinit', % ------------ CASE REINIT --------------------
currfig = gcf;
% Get the original GUI position and figure:
x = my_gui_info(1); y = my_gui_info(2); figure(my_gui_info(3));
% Delete all SoloParamHandles who belong to this object and whose
% fullname starts with the name of this mfile:
delete_sphandle('owner', ['^@' class(obj) '$'], ...
'fullname', ['^' mfilename]);
% Reinitialise at the original GUI position and figure:
[x, y] = feval(mfilename, obj, 'init', x, y);
% Restore the current figure:
figure(currfig);
end;