Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a plugin (re-)ordering bug (re: #200). #206

Merged
merged 2 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions +neurostim/cic.m
Original file line number Diff line number Diff line change
Expand Up @@ -579,13 +579,21 @@ function restoreTextPrefs(c)





function newOrder = order(c,varargin)
% pluginOrder = c.order([plugin1] [,plugin2] [,...])
% Returns pluginOrder when no input is given.
% Inputs: lists name of plugins in the order they are requested
% to be executed in.
function newOrder = setPluginOrder(c,varargin)
% Set and return pluginOrder.
%
% pluginOrder = c.setPluginOrder([plugin1] [,plugin2] [,...])
%
% Inputs:
% A list of plugin names in the order they are requested to
% be executed in.
%
% If called with no arguments, the plugin order will be reset
% to the default order, i.e., the order in which plugins were
% added to cic.
%
% Output:
% A list of plugin names reflecting the new plugin order.

%If there is an existing order, preserve it, unless an empty
%vector has been supplied (to clear it back to default order)
Expand Down Expand Up @@ -954,7 +962,7 @@ function run(c,block1,varargin)
end

%% Set up order and blocks
order(c,c.pluginOrder);
setPluginOrder(c,c.pluginOrder);
setupExperiment(c,block1,varargin{:});

% Force adaptive plugins assigned directly to parameters into
Expand Down Expand Up @@ -1790,9 +1798,9 @@ function handleAdaptives(c)
% the block design object(s) instead. This ensures the adaptive
% plugins are updated correctly (by the block object(s)).

plgs = c.order; % *all* plugins
plgs = {c.pluginOrder.name}; % *all* plugins
for ii = 1:numel(plgs)
plg = plgs{ii};
plg = plgs{ii};
prms = prmsByClass(c.(plg),'neurostim.plugins.adaptive');
if isempty(prms)
% no adaptive plugins/parameters
Expand Down
2 changes: 1 addition & 1 deletion demos/noiseGridDemo.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function noiseGridDemo(varargin)
myBlock.nrRepeats=10;

%% Run the experiment.
c.order('disk','grid'); %Ignore this for now - we hope to remove the need for this.
c.setPluginOrder('disk','grid'); %Ignore this for now - we hope to remove the need for this.
c.subject = 'easyD';
c.run(myBlock);

Expand Down
2 changes: 1 addition & 1 deletion demos/noiseHexGridDemo.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
myBlock.nrRepeats = 10;

% Run the experiment.
c.order('fix','noise');
c.setPluginOrder('fix','noise');
c.subject = 'easyD';
c.run(myBlock);
end
2 changes: 1 addition & 1 deletion demos/noiseRadialGridDemo.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
myBlock.nrRepeats=10;

%% Run the experiment.
c.order('fix','grid'); %Ignore this for now - we hope to remove the need for this.
c.setPluginOrder('fix','grid'); %Ignore this for now - we hope to remove the need for this.
c.subject = 'easyD';
c.run(myBlock);

2 changes: 1 addition & 1 deletion demos/saccadeIntanDemo.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,6 @@ function saccadeIntanDemo(varargin)
myBlock=block('myBlock',myDesign); %Create a block of trials using the factorial. Type "help neurostim/block" for more options.
myBlock.nrRepeats=1;
%% Make sure the plugins are in the right order
c.order(['eye'],['saccade'],['sound'],['soundFeedback'],['mcc'],['fix'],['target'],['estim'],['estim2'],['intan']); %#ok<NBRAK>
c.setPluginOrder(['eye'],['saccade'],['sound'],['soundFeedback'],['mcc'],['fix'],['target'],['estim'],['estim2'],['intan']); %#ok<NBRAK>
%% Run it
c.run(myBlock);
2 changes: 1 addition & 1 deletion demos/scripting.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ function respondMouse(c)
myBlock=neurostim.block('MyBlock',d);
myBlock.nrRepeats=5;
myBlock.randomization='RANDOMWITHREPLACEMENT';
c.order('fix','gabor');
c.setPluginOrder('fix','gabor');
c.run(myBlock);
end
2 changes: 1 addition & 1 deletion demos/textureDemo.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function textureDemo(varargin)
blk.nrRepeats = 10;

% now run the experiment...
% c.order('texture');
% c.setPluginOrder('texture');
c.subject = 'demo';
c.paradigm = 'textureDemo';
c.run(blk);
Expand Down