justingardner / mgl

A suite of mex/m files for displaying psychophysics stimuli
http://justingardner.net/mgl
Other
18 stars 22 forks source link

doStaircase('init', ...) functionality #1

Closed dbirman closed 9 years ago

dbirman commented 9 years ago

You can't override the init arguments when calling doStaircase('init',s,...). It would be great to be able to do doStaircase('init', s, 'initialThreshold', x); and have it override the calculated threshold or whatever other arguments you want to include.

I'm working around this issue by calling: [args, vals, ~] = getArgs(s(1).initArgs); s(end+1) = doStaircase('init','updown',args{1},vals{1},args{2},vals{2}); instead of using doStaircase('init',s, ...);

But obviously that's a mess and only works because I happen to know the number of initArgs I was using originally. If there's a better way to do this, or if the functionality exists and I just don't understand it let me know.

justingardner commented 9 years ago

Should be able to do that by changing the code around Line 141 to:

if isStaircase(type) oldS = type; restartArgs = getRestartArgs(oldS,1); args = {restartArgs{:} args{:}}; type = oldS(end).type; else

Can you try that and make sure that it works (I don't have sample data structures and stuff to test this easily). getArgs may give you a warning that it is setting the arguments 2 times (we can suppress that later if this works as expected).

dbirman commented 9 years ago

Tested, seems to be functional. Both initStaircase and initUpDownStaircase generated warnings.

(initStaircase) Warning: Variable 'initialStepsize' has been set 2 times
(initStaircase) Warning: Variable 'initialThreshold' has been set 2 times
(initUpDownStaircase) Warning: Variable 'initialStepsize' has been set 2 times
(initUpDownStaircase) Warning: Variable 'initialThreshold' has been set 2 times
justingardner commented 9 years ago

Cool. I think then you just need to set the flag for getArgs not to complain about multiple settings (in the getArgs call that follows these lines)

suppressMultipleSettingMessage=0