I've been using Bpod for a few months now with some existing code I've written, and for a new project I replicated the previous code I used and then altered and added some additional states as needed.
However, I've run into a fairly confusing problem, where first an otherwise syntactically correct state I wanted to add was flagged as causing an error in the InputMatrix, as seen with the following error message:
Unable to perform assignment because the size of the left side is 1-by-159 and the size of the right side is 1-by-102.
Error in AddState (line 62)
sma.InputMatrix(CurrentState,🙂 = BpodSystem.BlankStateMachine.InputMatrix*CurrentState;
Error in DiscriminationAssay (line 529)
   sma = AddState(sma, 'Name', 'NoReward', ...
Error in run (line 91)
evalin('caller', strcat(script, ';'));
Error in NewLaunchManager>LaunchProtocol (line 707)
run(ProtocolPath);
Â
Error while evaluating DestroyedObject Callback.
In this case, the state in question is a instantaneous state I added to my protocol here called DiscriminationAssay that I just use for my own data analysis; I can outline the state specifically here if it's relevant:
   sma = AddState(sma, 'Name', 'NoReward', ...
       'Timer', 0, ...
       'StateChangeConditions', {'Tup', 'Standby', 'GlobalTimer1_End', 'SessionEnd'}, ...
       'OutputActions', {});
What's odd is that this state existed without issue in this exact same form in my previous protocols, with the same states it both refers to it changes too also existing. If I temporarily removed this state, a functionally similar state named PokeFail which has the exact same parameters as this previously discussed NoReward state then also flags the same error above.
As an attempted solution, I moved these and similar accounting-type states that I've used higher up in the code that adds new states to the state machine, just to see if it made a difference. This time I got an altogether different error message:
Matrix dimensions must agree.
Error in SendStateMachine (line 142)
DifferenceMatrix = (sma.InputMatrix ~= DefaultInputMatrix)';
Error in SendStateMatrix (line 2)
Confirmed = SendStateMachine(sma);
Error in DiscriminationAssay (line 582)
   SendStateMatrix(sma); % Send state machine to the Bpod state machine device
Error in run (line 91)
evalin('caller', strcat(script, ';'));
Error in NewLaunchManager>LaunchProtocol (line 707)
run(ProtocolPath);
Â
Error while evaluating DestroyedObject Callback.
I am not very sure what is going on here. It looks like the state matrix itself is having a problem with the states I'm having, even though they've been used in a similar protocol with similar formatting. What could cause this issue, and how might I solve it?
~Nick
After checking all my lines individually in the code, I found that the line responsible for increasing the size of the matrix in question from 102 to 159 was this:
if RewardType == 0
           sma = EditState(sma, 'SuccessSignal6', 'StateChangeConditions', {'Tup', 'RewardAFail'});
       elseif RewardType == 1
           sma = EditState(sma, 'SuccessSignalF', 'StateChangeConditions', {'Tup', 'RewardBFail'});
       end
Something about the EditState function here caused this problem apparently? These lines of code are new to this program but I've used this function before without issue. I'm not certain what here would have caused this error.