Skip to content

Commit 35a3870

Browse files
jaib1jaib1
authored andcommitted
Rebased 'TestPanelClasses' onto 'dev' at diverge point c9c27a2 after pull request changes
Test Panel as Classes modeled off SignalsExp & MControl variable name changes to exp.SignalsExp added 'cprintf.m' updated signals submodule updated signals submodule updates submodule signals updates signals submodule (TestPanelClasses branch) updated submodule signals (TestPanelClasses branch) MControl and mc commits to match dev branch alyx-related commits to match dev branch updated submodule signals (TestPanelClasses branch) updated submodule signals (TestPanelClasses branch) updated signals submodule (to 'TestPanelClasses' branch) and alyx-matlab(to 'dev' branch) and improved 'namedArg' updated signals submodule ('TestPanelClasses') after rebasing that branch in that submodule typo fix in 'hw.devices' made changes for Miles updated signals (TestPanelClasses) submodule Rebased 'TestPanelClasses' onto 'dev' at diverge point after pull request changes Rebased 'TestPanelClasses' onto 'dev' at diverge point Test Panel as Classes modeled off SignalsExp & MControl variable name changes to exp.SignalsExp added 'cprintf.m' updated signals submodule updated signals submodule updates submodule signals updates signals submodule (TestPanelClasses branch) updated submodule signals (TestPanelClasses branch) MControl and mc commits to match dev branch alyx-related commits to match dev branch updated submodule signals (TestPanelClasses branch) updated submodule signals (TestPanelClasses branch) updated signals submodule (to 'TestPanelClasses' branch) and alyx-matlab(to 'dev' branch) and improved 'namedArg' updated signals submodule ('TestPanelClasses') after rebasing that branch in that submodule typo fix in 'hw.devices' made changes for Miles updated signals (TestPanelClasses) submodule updated signals (TestPannelClasses) submodule after incorporating pull request changes undid variable name changes for Miles
1 parent c9c27a2 commit 35a3870

File tree

9 files changed

+39
-58
lines changed

9 files changed

+39
-58
lines changed

+eui/AlyxPanel.m

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ function login(obj)
217217
% Logging out does not cause the token to expire, instead the
218218
% token is simply deleted from this object.
219219

220+
% Temporarily disable the Subject Selector
221+
obj.NewExpSubject.UIControl.Enable = 'off';
220222
% Reset headless flag in case user wishes to retry connection
221223
obj.AlyxInstance.Headless = false;
222224
% Are we logging in or out?
@@ -282,6 +284,8 @@ function login(obj)
282284
notify(obj, 'Disconnected'); % Notify listeners of logout
283285
obj.log('Logged out of Alyx');
284286
end
287+
% Reable the Subject Selector
288+
obj.NewExpSubject.UIControl.Enable = 'on';
285289
obj.dispWaterReq()
286290
end
287291

@@ -314,7 +318,7 @@ function giveFutureWater(obj)
314318
'enter space-separated numbers, i.e. \n',...
315319
'[tomorrow, day after that, day after that.. etc] \n\n',...
316320
'Enter "0" to skip a day\nEnter "-1" to indicate training for that day\n']);
317-
amtStr = inputdlg(prompt,'Future Amounts', [1 50]);
321+
amtStr = newid(prompt,'Future Amounts', [1 50]);
318322
if isempty(amtStr)||~obj.AlyxInstance.IsLoggedIn
319323
return % user pressed 'Close' or 'x'
320324
end
@@ -446,10 +450,10 @@ function recordWeight(obj, weight, subject)
446450
dlgTitle = 'Manual weight logging';
447451
numLines = 1;
448452
defaultAns = {'',''};
449-
weight = inputdlg(prompt, dlgTitle, numLines, defaultAns);
453+
weight = newid(prompt, dlgTitle, numLines, defaultAns);
450454
if isempty(weight); return; end
451455
end
452-
% inputdlg returns weight as a cell, otherwise it may now be
456+
% newid returns weight as a cell, otherwise it may now be
453457
weight = ensureCell(weight); % ensure it's a cell
454458
% convert to double if weight is a string
455459
weight = iff(ischar(weight{1}), str2double(weight{1}), weight{1});
@@ -601,13 +605,13 @@ function viewSubjectHistory(obj, ax)
601605
axWater = axes('Parent',plotBox);
602606
plot(axWater, dates, obj.round([records.given_water_total], 'up'), '.-');
603607
hold(axWater, 'on');
604-
plot(axWater, dates, obj.round([records.given_water_hydrogel], 'down'), '.-');
605-
plot(axWater, dates, obj.round([records.given_water_liquid], 'down'), '.-');
608+
plot(axWater, dates, obj.round([records.given_water_supplement], 'down'), '.-');
609+
plot(axWater, dates, obj.round([records.given_water_reward], 'down'), '.-');
606610
plot(axWater, dates, obj.round([records.expected_water], 'up'), 'r', 'LineWidth', 2.0);
607611
box(axWater, 'off');
608612
xlim(axWater, [min(dates) maxDate]);
609613
set(axWater, 'XTickLabel', arrayfun(@(x)datestr(x, 'dd-mmm'), get(axWater, 'XTick'), 'uni', false))
610-
ylabel(axWater, 'water/hydrogel (mL)');
614+
ylabel(axWater, 'water (mL)');
611615

612616
% Create table of useful weight and water information,
613617
% sorted by date
@@ -627,14 +631,14 @@ function viewSubjectHistory(obj, ax)
627631
arrayfun(@(x)iff(isnan(x), [], @()sprintf('%.1f', 0.8*(x-iw)+iw)), expected', 'uni', false), ...
628632
weightPctByDate');
629633
waterDat = (...
630-
num2cell(horzcat([records.given_water_liquid]', [records.given_water_hydrogel]', ...
634+
num2cell(horzcat([records.given_water_reward]', [records.given_water_supplement]', ...
631635
[records.given_water_total]', [records.expected_water]',...
632636
[records.given_water_total]'-[records.expected_water]')));
633637
waterDat = cellfun(@(x)sprintf('%.2f', x), waterDat, 'uni', false);
634638
waterDat(~[records.is_water_restricted],[1,3]) = {'ad lib'};
635639
dat = horzcat(dat, waterDat);
636640

637-
set(histTable, 'ColumnName', {'date', 'meas. weight', '80% weight', 'weight pct', 'water', 'hydrogel', 'total', 'min water', 'excess'}, ...
641+
set(histTable, 'ColumnName', {'date', 'meas. weight', '80% weight', 'weight pct', 'water', 'supplement', 'total', 'min water', 'excess'}, ...
638642
'Data', dat(end:-1:1,:),...
639643
'ColumnEditable', false(1,5));
640644
histbox.Widths = [ -1 725];

+eui/MControl.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
end
2121

2222
properties (SetAccess = private)
23+
AlyxPanel % holds the AlyxPanel object (see buildUI(), eui.AlyxPanel())
2324
LogSubject % Subject selector control
2425
NewExpSubject % Experiment selector control
2526
NewExpType % Experiment type selector control
@@ -33,7 +34,6 @@
3334
properties (Access = private)
3435
ParamEditor
3536
ParamPanel
36-
AlyxPanel % holds the AlyxPanel object (see buildUI(), eui.AlyxPanel())
3737
BeginExpButton % The 'Start' button that begins an experiment
3838
RigOptionsButton % The 'Options' button that opens the rig options dialog
3939
NewExpFactory % A struct containing all availiable experiment types and function handles to constructors for their default parameters

+exp/SignalsExp.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,8 @@ function mainLoop(obj)
720720
obj.Data.stimWindowRenderTimes(obj.StimWindowUpdateCount) = renderTime;
721721
obj.StimWindowInvalid = false;
722722
end
723+
% make sure some minimum time passes before updating signals, to
724+
% improve performance on MC
723725
if (obj.Clock.now - t) > 0.1 || obj.IsLooping == false
724726
sendSignalUpdates(obj);
725727
t = obj.Clock.now;

+exp/inferParameters.m

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,51 +5,35 @@
55
% create some signals just to pass to the definition function and track
66
% which parameter names are used
77

8-
% if ischar(expdef) && file.exists(expdef)
9-
% expdeffun = fileFunction(expdef);
10-
% else
11-
% expdeffun = expdef;
12-
% expdef = which(func2str(expdef));
13-
% end
148
if ischar(expdef) && file.exists(expdef)
159
expdeffun = fileFunction(expdef);
1610
else
1711
expdeffun = expdef;
1812
expdef = which(func2str(expdef));
1913
end
2014

21-
net = sig.Net;
22-
e = struct;
23-
e.t = net.origin('t');
24-
e.events = net.subscriptableOrigin('events');
25-
e.pars = net.subscriptableOrigin('pars');
26-
e.pars.CacheSubscripts = true;
27-
e.visual = net.subscriptableOrigin('visual');
28-
e.audio.Devices = @dummyDev;
29-
e.inputs = net.subscriptableOrigin('inputs');
30-
e.outputs = net.subscriptableOrigin('outputs');
15+
e = sig.void;
16+
pars = sig.void(true);
17+
audio.Devices = @dummyDev;
3118

3219
try
20+
expdeffun(e.t, e.events, pars, e.visual, e.inputs, e.outputs, audio);
3321

34-
expdeffun(e.t, e.events, e.pars, e.visual, e.inputs, e.outputs, e.audio);
35-
36-
% paramNames will be the strings corresponding to the fields of e.pars
22+
% paramNames will be the strings corresponding to the fields of pars
3723
% that the user tried to reference in her expdeffun.
38-
paramNames = e.pars.Subscripts.keys';
39-
%The paramValues are signals corresponding to those parameters and they
40-
%will all be empty, except when they've been given explicit numerical
41-
%definitions right at the end of the function - and in that case, we'll
42-
%take those values (extracted into matlab datatypes, from the signals,
43-
%using .Node.CurrValue) to be the desired default values.
44-
paramValues = e.pars.Subscripts.values';
45-
parsStruct = cell2struct(cell(size(paramNames)), paramNames);
46-
for i = 1:size(paramNames,1)
47-
parsStruct.(paramNames{i}) = paramValues{i}.Node.CurrValue;
48-
end
24+
parsStruct = pars.Subscripts;
25+
26+
% Check for reserved fieldnames
27+
reserved = {'randomiseConditions', 'services', 'expPanelFun', ...
28+
'numRepeats', 'defFunction', 'waterType', 'isPassive'};
29+
assert(~any(ismember(fieldnames(parsStruct), reserved)), ...
30+
'exp:InferParameters:ReservedParameters', ...
31+
'The following param names are reserved:\n%s', ...
32+
strjoin(intersect(fieldnames(parsStruct), reserved), ', '))
33+
34+
szFcn = @(a)iff(ischar(a), @()size(a,1), @()size(a,2));
4935
sz = iff(isempty(fieldnames(parsStruct)), 1,... % if there are no paramters sz = 1
50-
structfun(@(a)size(a,2), parsStruct)); % otherwise get number of columns
51-
isChar = structfun(@ischar, parsStruct); % we disregard charecter arrays
52-
if any(isChar); sz = sz(~isChar); end
36+
structfun(szFcn, parsStruct)); % otherwise get number of columns
5337
% add 'numRepeats' parameter, where total number of trials = 1000
5438
parsStruct.numRepeats = ones(1,max(sz))*floor(1000/max(sz));
5539
parsStruct.defFunction = expdef;
@@ -60,12 +44,9 @@
6044
ExpPanel_fn = [path filesep ExpPanel_name ext];
6145
if exist(ExpPanel_fn,'file'); parsStruct.expPanelFun = ExpPanel_name; end
6246
catch ex
63-
net.delete();
6447
rethrow(ex)
6548
end
6649

67-
net.delete();
68-
6950
function dev = dummyDev(~)
7051
% Returns a dummy audio device structure, regardless of input
7152
% Returns a standard structure with values for generating tone
@@ -75,4 +56,4 @@
7556
'DefaultSampleRate', 44100,...
7657
'NrOutputChannels', 2);
7758
end
78-
end
59+
end

+hw/devices.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@
6969
% Get list of audio devices
7070
devs = getOr(rig, 'audioDevices', PsychPortAudio('GetDevices'));
7171
% Sanitize the names
72-
names = matlab.lang.makeValidName([{'default'} {devs(2:end).DeviceName}],...
73-
'ReplacementStyle', 'delete');
72+
names = matlab.lang.makeValidName({devs.DeviceName}, 'ReplacementStyle', 'delete');
73+
names = iff(ismember('default', names), names, @()[{'default'} names(2:end)]);
7474
for i = 1:length(names); devs(i).DeviceName = names{i}; end
7575
rig.audioDevices = devs;
7676
end
@@ -93,4 +93,4 @@ function configure(deviceName, usedaq)
9393
end
9494
end
9595

96-
end
96+
end

cb-tools/burgbox/namedArg.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
% 2014-02 CB created
1010

11-
defIdx = find(cellfun(@(a) isequal(a, name), args), 1);
11+
defIdx = find(cellfun(@(a) strcmpi(a, name), args), 1);
1212
if ~isempty(defIdx)
1313
present = true;
1414
value = args{defIdx + 1};

cortexlab/+git/changes.m

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)