You can create several kinds of run-time widgets and read/ write the values of the widget during the experiment. Controls will issue a trigger when their value is changed. This event is captured in the Pynapse event loop. You can also read the value of the controls inside any Python method.
|Runtime Tab Showing Example Controls|
You can add up to 50 custom controls. Right-click on the 'Main' page to add new controls. Drag and drop the controls in the tree to set the order they are displayed at runtime. Right-click on 'Main' to add a new page of controls. Controls will be organized into tabs at runtime.
|Runtime Control Tab Example|
User-adjustable controls (Toggle Switch, Spin Control, Slider Control, and Combo Box) can be assigned preset values for different phases of the experiment, so you can quickly change several controls with the click of a button. When combined with Session Controls you can tell the Pynapse scheduler how many trials / blocks of each phase you want to run and it automatically handles it for you. The Session Scheduler takes this one step further and allows you to schedule the sequence of phase preset conditions to run in order.
Check the Phase Presets box to enable this feature and make a comma-separated list with your own custom phase name. Check the Preset Controlled option on any control you want to add to the presets.
|Assign controls to phases|
At run-time, the phase presets appear as buttons. Setup the control values that you want, then right-click on one of the phase buttons and select 'Store To Preset' to assign those values to that button. The button text changes to black to indicate preset values have been assigned, and the button outline changes to blue to indicate it is currently selected.
|Phase buttons: assigned, selected, and undefined|
Right-click on a phase button for more options:
Choose when to lock controls during the experiment.
The Lock icon next to the icon at runtime must be locked in order for this setting
to take effect. The Lock icon is unlocked by default in
Preview mode, and locked
by default in
|Slider control in unlocked and locked state|
Slot Methods for Responding to Control Changes
This control slot method captures status information about the controls. It is available as method definitions inside Pynapse states for each control. Write a method with this name to react to the corresponding event.
All custom control slot methods
def s_ in the
Pynapse Code Editor and let the code completion do the work for you.
Print a slider value when it is changed at runtime.
class Always: # StateID = 0 # capture any control value change with this def s_MyControl_change(value): print('new control value', value)
All control methods have the form
p_ in the Pynapse Code Editor
and let the code completion do the work for you.
value = p_Control.MyControl.read()
Read the current value of the control. For combo box controls, the value is the index into the list of items in the combo box.
Set the next stimulation based on a slider value controlled by the user at runtime.
class PrepStim: #StateID = 0 def s_State_enter(): # get next stim ready wave_freq = p_Control.MyControl.read() p_Param.p_Param.WaveFreq_write(wave_freq)
Write a new value to the control. For combo box controls, the value is the index into the list of items in the combo box. For Led Indicators, the value is the index into the list of colors.
Increment a progress bar.
class EndTrial: #StateID = 0 def s_State_enter(): # increment completed trials counter p_Metric.completed_trials.inc() # update progress bar progress = 100 * p_Metric.completed_trials.read() / p_Metric.desired_trials.read() p_Control.MyProgressBar.write(progress)
Lock the control to prevent modification.
Lock control during a portion of the experiment
class StartTrial: #StateID = 0 def s_State_enter(): p_Control.MyControl.lock()
Unlock the control to allow modification.
Unlock control during a portion of the experiment
class EndTrial: #StateID = 0 def s_State_enter(): p_Metric.completed_trials.inc() p_Control.MyControl.unlock()
Set the value range of the control between minv and maxv. This is only valid for Spin Control, Slider Control, and Progress Bar controls.
Sets the text label of the control.
Hides the control on the user interface.
Shows the control on the user interface.