Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sending state at end of protocol
Hi Josh,
Is there a way to have Bpod send a final state when a protocol is ended? Currently, a single trial in our protocol is made up of several states (pretrial-> lick-> reward-> ITI). If we were to accidentally end the protocol on the lick state, is there a way to have Bpod run the reward and ITI states before actually shutting off? Let me know if I need to clarify anything, and thanks for the help.
Best, Blake
Not Josh, but I can say that I've made it a habit to stop a protocol by first using the Pause button and then only hitting Stop when the state matrix has been completed. 

Hitting the Stop button sends a force-exit message to the state machine. But if you've got a real habit for accidentally hitting Stop then you could modify Functions/Launch manager/RunProtocol.m which handles the button presses. At Line 138 there's the Stop button case, so you could add an additional confirmation:
case 'Stop' % Line 138 in Functions/Launch manager/RunProtocol.m
answer = input('Stop protocol Y/N? ','s'); % require user to input text into Command Window
   if ~strcmp(lower(answer),'y')
       return % if unconfirmed then exit out of this function and return control to the protocol script
% otherwise continue with shutting down the session

With this addition, while MATLAB is waiting for your input the state matrix can finish in the background.
As George mentioned, you can stop with the 'Pause' button. This will schedule a pause after the current trial completes, and halt MATLAB until pause is released. From the pause state, you can press 'Stop' to end the session.
Josh and George, 

Thanks for your prompt response.  Emily here, working with Blake who posted the original question.  One follow-up:  we are using the digital out (DIO1) and a teensyduino to control a laser.  We stim across trials in a block structure, so one issue we have is that if we stop bpod between trials in the middle of the block, the teensyduino pins are still set to high and the laser remains on.  What is the easiest way to set all the pins back to low when stopping bpod?  George, could we just add that to RunProtocol.m like you suggested for stopping after the current trial?  


Forum Jump: