From 6e9da3601d753652d9cd542c65d3f240ba82501d Mon Sep 17 00:00:00 2001 From: Shaun Cloherty Date: Thu, 1 Sep 2022 18:03:20 +1000 Subject: [PATCH 1/2] Fix a plugin (re-)ordering bug (re: #200). This change fixes a bug introduced by commit 1988ab5 (re: #190) that causes any changes to the default plugin order, imposed in cic.run(), to be immediately reverted when handling adaptive plugins/parameters (see cic.handleAdaptives()). This change removes the call to c.order(), which reverts the plugin order, in favour of using c.pluginOrder directly. --- +neurostim/cic.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/+neurostim/cic.m b/+neurostim/cic.m index 74f806ed..29564bf6 100644 --- a/+neurostim/cic.m +++ b/+neurostim/cic.m @@ -1790,9 +1790,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 From 392242a01077cd26d6247043c58e7bf22ab1a5ca Mon Sep 17 00:00:00 2001 From: Shaun Cloherty Date: Fri, 9 Sep 2022 10:23:18 +1000 Subject: [PATCH 2/2] Rename c.order() to c.setPluginOrder() to better reflect its operation. --- +neurostim/cic.m | 24 ++++++++++++++++-------- demos/noiseGridDemo.m | 2 +- demos/noiseHexGridDemo.m | 2 +- demos/noiseRadialGridDemo.m | 2 +- demos/saccadeIntanDemo.m | 2 +- demos/scripting.m | 2 +- demos/textureDemo.m | 2 +- 7 files changed, 22 insertions(+), 14 deletions(-) diff --git a/+neurostim/cic.m b/+neurostim/cic.m index 29564bf6..0792378d 100644 --- a/+neurostim/cic.m +++ b/+neurostim/cic.m @@ -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) @@ -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 diff --git a/demos/noiseGridDemo.m b/demos/noiseGridDemo.m index 1ccf548f..dd2132e0 100644 --- a/demos/noiseGridDemo.m +++ b/demos/noiseGridDemo.m @@ -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); diff --git a/demos/noiseHexGridDemo.m b/demos/noiseHexGridDemo.m index 72f6b860..4f412d4e 100644 --- a/demos/noiseHexGridDemo.m +++ b/demos/noiseHexGridDemo.m @@ -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 diff --git a/demos/noiseRadialGridDemo.m b/demos/noiseRadialGridDemo.m index bbe7dfa9..3a85ac45 100644 --- a/demos/noiseRadialGridDemo.m +++ b/demos/noiseRadialGridDemo.m @@ -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); diff --git a/demos/saccadeIntanDemo.m b/demos/saccadeIntanDemo.m index 704b7fd6..2e218e08 100644 --- a/demos/saccadeIntanDemo.m +++ b/demos/saccadeIntanDemo.m @@ -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 +c.setPluginOrder(['eye'],['saccade'],['sound'],['soundFeedback'],['mcc'],['fix'],['target'],['estim'],['estim2'],['intan']); %#ok %% Run it c.run(myBlock); diff --git a/demos/scripting.m b/demos/scripting.m index fa1ad065..749f8d71 100644 --- a/demos/scripting.m +++ b/demos/scripting.m @@ -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 \ No newline at end of file diff --git a/demos/textureDemo.m b/demos/textureDemo.m index bd68be29..db5f4adf 100644 --- a/demos/textureDemo.m +++ b/demos/textureDemo.m @@ -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);