klabhub / neurostim

Design and run visual neuroscience experiments using Matlab and the Psychophysics Toolbox.
MIT License
4 stars 3 forks source link

Fix direct assignment of adaptive objects for designs with multiple factors. #194

Closed cnuahs closed 2 years ago

cnuahs commented 2 years ago

Recent changes to handling of adaptive objects (c.f., ca6c17b) cause direct assignment of an adaptive object to a parameter to fail for designs with multiple factors. See for example demos/behaviorDemo.m on the current master branch (c.f., 6c7aa72).

This is because design.addAdaptive() calls design.subsasgn() with a linear index into .conditions, but design.subsasgn() does not currently handle linear indices.

I think there are two possible solutions here:

  1. Modify design.addAdaptive() to pass subscripts (rather than linear indices) in it's call to design.subsasgn(), or
  2. Modify design.subsasgn() to accept linear indices in assignments to .conditions.

This change implements the second option.

Is there any reason that linear indices should not be allowed in assignments to .conditions?