klabhub / neurostim

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

Bug fix in neurostim.design affecting factorials with >2 factors. #99

Closed cnuahs closed 6 years ago

cnuahs commented 6 years ago

A bug in neurostim.design (in subsasgn()) caused multiple calls to .conditions() to always overwrite the previous contents of .conditionSpecs if the last factor in the factorial was a singleton. This was because ndims(o.conditionSpecs) returned [N M] even if the factorial had three factors, i.e., was actually N x M x 1. This was true for all factorial designs with >2 factors where the last factor was a singleton.

The fix provided here initializes o.conditionSpecs to a cell array (of appropriate dimensions to match the factorial) of empty matricies on the first call to .conditions(), and concatenates the contents of .conditionSpecs thereafter.