Skip to content

Commit 923d407

Browse files
committed
changes to make protocol work without runrats
1 parent 093aae4 commit 923d407

File tree

4 files changed

+54
-45
lines changed

4 files changed

+54
-45
lines changed

ExperPort/Modules/@dispatcher/RunningSection.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@
284284
runrats('crashed',me);
285285
Running.value = 0;
286286
else
287+
Running.value = 0;
287288
rethrow(me);
288289
end
289290

Protocols/@ArpitSoundCatContinuous/ArpitSoundCatContinuous.m

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
HeaderParam(obj, 'prot_title', [mfilename ': ' expmtr ', ' rname], x, y, 'position', [10 figpos(4)-25, 800 20]);
112112

113113
[x, y] = WaterValvesSection(obj, 'init', x, y);next_row(y);
114-
[x, y] = PokesPlotSection(obj, 'init', x, y);next_row(y);
114+
% [x, y] = PokesPlotSection(obj, 'init', x, y);next_row(y);
115115
[x, y] = CommentsSection(obj, 'init', x, y);next_row(y);
116116
[x, y] = BonsaiCameraInterface(obj,'init',x,y,name,expmtr,rname);next_row(y);
117117

@@ -126,7 +126,12 @@
126126
x=oldx; y=oldy;
127127
SessionDefinition(obj, 'init', x, y, value(myfig)); next_row(y, 2); %#ok<NASGU>
128128

129+
% saving auto frequency to 20 just in case changed running ephys
130+
% experiment. If so then it will again change back to 1;
131+
SavingSection(obj,'set_autosave_frequency',20);
132+
129133
ArpitSoundCatContinuousSMA(obj, 'init');
134+
130135
% feval(mfilename, obj, 'prepare_next_trial');
131136

132137
case 'change_water_modulation_params'
@@ -143,11 +148,12 @@
143148

144149
BonsaiCameraInterface(obj,'record_start');
145150

146-
case 'set_setting_params'
151+
case 'set_setting_params' % special case used during ephys experiments when not using runrats
147152

148153
SavingSection(obj,'set','ratname',varargin{1});
149154
SavingSection(obj,'set','experimenter',varargin{2});
150155
SavingSection(obj,'set_setting_info',varargin{3},varargin{4});
156+
SavingSection(obj,'set_autosave_frequency',1); % saving setting every trial instead of 20
151157
BonsaiCameraInterface(obj,'set_video_filepath',varargin{5});
152158

153159

@@ -183,20 +189,21 @@
183189
% Update the Metrics Calculated
184190
PerformanceSection(obj,'evaluate');
185191
PsychometricSection(obj, 'update');
192+
186193
% Do any updates in the protocol that need doing:
187194
feval(mfilename, 'update');
188195

189196
%% update
190197
case 'update'
191-
PokesPlotSection(obj, 'update');
198+
% PokesPlotSection(obj, 'update');
192199
if n_done_trials==1
193200
[expmtr, rname]=SavingSection(obj, 'get_info');
194201
prot_title.value=[mfilename ' on rig ' get_hostname ' : ' expmtr ', ' rname '. Started at ' datestr(now, 'HH:MM')];
195202
end
196203

197204
%% close
198205
case 'close'
199-
PokesPlotSection(obj, 'close');
206+
% PokesPlotSection(obj, 'close');
200207
SideSection(obj, 'close');
201208
StimulusSection(obj,'close');
202209
BonsaiCameraInterface(obj,'close');
@@ -218,20 +225,6 @@
218225
StimulusSection(obj,'hide');
219226
SessionDefinition(obj, 'run_eod_logic_without_saving');
220227

221-
% perf = PerformanceSection(obj, 'evaluate');
222-
% cp_durs = SideSection(obj, 'get_cp_history');
223-
%
224-
% [stim1dur] = SideSection(obj,'get_stimdur_history');
225-
%stim_history = StimulatorSection(obj,'get_history');
226-
% pd.hits=hit_history(:);
227-
% pd.sides=previous_sides(:);
228-
% pd.viols=violation_history(:);
229-
% pd.timeouts=timeout_history(:);
230-
% pd.cp_durs=cp_durs(:);
231-
% pd.stim1dur=stim1dur(:);
232-
%pd.stimul=stim_history(:);
233-
% sendsummary(obj,'protocol_data',pd);
234-
235228
sendsummary(obj);
236229

237230
%% otherwise

Protocols/@ArpitSoundCatContinuous/PsychometricSection.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@
273273
xGrid = linspace(Stim_Params(1), Stim_Params(3), 300)';
274274
cla(value(axplot2));
275275
hold (value(axplot2),'on')
276+
277+
colors_to_use = createTemporalColormap(value(thiscontext));
278+
276279
for n_plot = 1:value(thiscontext)
277280

278281
eval(sprintf('trial_start = value(Context%i_trialStart);',n_plot));
@@ -319,8 +322,8 @@
319322

320323
% Plot the Psychometric
321324
if ~(contains(methodUsed,'Failed') || contains(methodUsed,'Canceled'))
322-
plot(value(axplot2),xGrid, y_pred, 'b-', 'LineWidth', 2);
323-
xline(value(axplot2),fitParams(1), 'g--', sprintf('PSE (%.2f)', fitParams(1)));
325+
plot(value(axplot2),xGrid, y_pred, 'Color', colors_to_use(n_plot, :), 'LineWidth', 2,'DisplayName',sprintf('Context %s',category_selected));
326+
xline(value(axplot2),fitParams(1), '--','Color', colors_to_use(n_plot, :), 'Label', sprintf('PSE (%.2f)', fitParams(1)));
324327
end
325328

326329
end

Protocols/@Rigtest_singletrial/Rigtest_singletrial.m

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@
132132
set(value(myfig), 'Name', name, 'Tag', name, ...
133133
'closerequestfcn', 'dispatcher(''close_protocol'')', 'MenuBar', 'none');
134134

135-
136-
135+
% This flag will be set to 1 when the single trial is complete.
136+
SoloParamHandle(obj, 'ManualTestComplete', 'value', 0, 'saveable', 0);
137137
% At this point we have one SoloParamHandle, myfig
138138
% Let's put the figure where we want it and give it a reasonable size:
139139
set(value(myfig), 'Position', [485 144 300 400]);
@@ -148,23 +148,24 @@
148148
next_row(y);
149149

150150
DispParam(obj, 'nTrials', 0, x, y); next_row(y);
151-
% For plotting with the pokesplot plugin, we need to tell it what
152-
% colors to plot with:
153-
my_state_colors = struct( ...
154-
'wait_for_left', [0.2 0.5 0.2], ...
155-
'in_left', [0.5 0.5 1], ...
156-
'in_center', [0.5 1 0.5], ...
157-
'in_right', [1 0.5 0.5], ...
158-
'state_0', [1 1 1], ...
159-
'final_state', [0.5 0 0], ...
160-
'check_next_trial_ready', [0.7 0.7 0.7]);
161-
% In pokesplot, the poke colors have a default value, so we don't need
162-
% to specify them, but here they are so you know how to change them.
163-
my_poke_colors = struct( ...
164-
'L', 0.6*[1 0.66 0], ...
165-
'C', [0 0 0], ...
166-
'R', 0.9*[1 0.66 0]);
167151

152+
% % For plotting with the pokesplot plugin, we need to tell it what
153+
% % colors to plot with:
154+
% my_state_colors = struct( ...
155+
% 'wait_for_left', [0.2 0.5 0.2], ...
156+
% 'in_left', [0.5 0.5 1], ...
157+
% 'in_center', [0.5 1 0.5], ...
158+
% 'in_right', [1 0.5 0.5], ...
159+
% 'state_0', [1 1 1], ...
160+
% 'final_state', [0.5 0 0], ...
161+
% 'check_next_trial_ready', [0.7 0.7 0.7]);
162+
% % In pokesplot, the poke colors have a default value, so we don't need
163+
% % to specify them, but here they are so you know how to change them.
164+
% my_poke_colors = struct( ...
165+
% 'L', 0.6*[1 0.66 0], ...
166+
% 'C', [0 0 0], ...
167+
% 'R', 0.9*[1 0.66 0]);
168+
%
168169
% [x, y] = PokesPlotSection(obj, 'init', x, y, ...
169170
% struct('states', my_state_colors, 'pokes', my_poke_colors));
170171

@@ -229,14 +230,25 @@
229230
%% Modified by Arpit to run without Runrats
230231
% <~> If we've completed our trial, tell RunRats that we're done.
231232
if n_done_trials > 0
232-
if nTrials > 0 && runrats('is_running')
233-
runrats('rigtest_singletrial_is_complete');
234-
return;
235-
else
236-
return;
237-
end
233+
234+
% Set our completion flag to 1. The main GUI will be polling for this.
235+
ManualTestComplete.value = 1;
236+
237+
if nTrials > 0 && runrats('is_running')
238+
runrats('rigtest_singletrial_is_complete');
239+
return;
240+
else % probably called by another function so need to stop the dispatcher from here itself
241+
% Send a dummy state machine that does nothing and ends quickly.
242+
% This prevents the protocol from running a second trial.
243+
sma = StateMachineAssembler('full_trial_structure');
244+
sma = add_state(sma, 'name', 'do_nothing', 'self_timer', 0.01, ...
245+
'input_to_statechange', {'Tup', 'check_next_trial_ready'});
246+
dispatcher('send_assembler', sma, 'do_nothing');
247+
return; % IMPORTANT: Exit here to prevent building the real state machine again.
248+
249+
end
238250
end
239-
251+
240252
% <~> end adaptation for single-trial use :P
241253

242254

0 commit comments

Comments
 (0)