You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/hobgoblin-reaction.md
+11-6Lines changed: 11 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,10 @@ stateDiagram-v2
19
19
20
20
The task begins with an inter-trial interval (`ITI`), followed by stimulus presentation (`ON`). After stimulus onset, advancement to the next state can happen only when the subject presses the button (`success`) or a timeout elapses (`miss`). Depending on which event is triggered first, the task advances either to the `Reward` state, or `Fail` state. At the end, the task goes back to the beginning of the ITI state for the next trial.
21
21
22
+
## Prerequisites
23
+
24
+
- Install the [`Bonsai.Numerics`](https://bonsai-rx.org/numerics/) package from the [Bonsai package manager](https://bonsai-rx.org/docs/articles/packages.html).
25
+
22
26
### Exercise 1: Generating a fixed-interval stimulus
23
27
24
28
In this first exercise, you will assemble the basic hardware and software components required to implement the reaction time task. Connect the LED to digital output channel `GP15` on the `Hobgoblin`. Connect the push button to digital input channel `GP2` on the `Hobgoblin`.
### Exercise 4: Driving state transitions with external behaviour events
@@ -155,13 +159,13 @@ In order to translate our simple reaction time task in the previous exercises in
155
159
- Insert a [`SubscribeSubject`] operator. Configure the `Name` property to `Hobgoblin Events`.
156
160
- Insert a [`Parse`] operator after `Hobgoblin Events`. Configure the `Register` property to [`DigitalInputState`].
157
161
- Insert a [`Condition`] operator after the [`Parse`] operator.
158
-
- Double-click on the [`Condition`] operator and add an[`Equal`] operator after the `Source1` operator. Set the `Value` property to `GP2`.
162
+
- Double-click on the [`Condition`] operator and add a[`HasFlag`] operator after the `Source1` operator. Set the `Value` property to `GP2`.
159
163
- Insert a [`Take`] operator and set its `Count` property to 1.
160
164
- Connect the [`Take`] operator to `WorkflowOutput`.
161
165
- Run the workflow a couple of times and validate the state machine is responding to the button press.
162
166
163
167
> [!Note]
164
-
> The [`Condition`] operator allows you to specify arbitrary rules for accepting or rejecting inputs. The `WorkflowOutput` node always needs to be specified with a `bool` input, the result of whether the input is accepted (`True`) or rejected (`False`). Only inputs which pass the filter specified inside the [`Condition`] are allowed to proceed. Using an[`Equal`] operator here allows us to filter only messages from that pin and also has the beneficial side effect of only detecting a button press (when the value changes fron `None` > `GP2`) instead of a button release (`GP2`>`None`).
168
+
> The [`Condition`] operator allows you to specify arbitrary rules for accepting or rejecting inputs. The `WorkflowOutput` node always needs to be specified with a `bool` input, the result of whether the input is accepted (`True`) or rejected (`False`). Only inputs which pass the filter specified inside the [`Condition`] are allowed to proceed. Using a[`HasFlag`] operator here allows us to filter only messages from that pin and also has the beneficial side effect of only detecting a button press (when the value changes fron `None` > `GP2`) instead of a button release (`GP2`>`None`).
165
169
166
170
### Exercise 5: Timeout and choice
167
171
@@ -207,7 +211,7 @@ _Why did we need to specify something for the `Miss` condition?_
207
211
_Why did we not need to specify anything for the `Success` condition?_
208
212
209
213
> [!Note]
210
-
> The [`Condition`] operator is often used to represent choice points in the task. Other than [`Equal`], you can use operators such as [`NotEqual`], [`GreaterThan`], etc for specifying such tests.
214
+
> The [`Condition`] operator is often used to represent choice points in the task. You can use operators such as[`Equal`],[`NotEqual`], [`GreaterThan`], etc for specifying such tests.
211
215
212
216
Inside the `Reward` and `Fail` node you can specify your own logic to signal the state of the trial.
213
217
For example, to make the LED blink three times in rapid succession for the `Reward` node:
@@ -253,7 +257,7 @@ stateDiagram-v2
253
257
NoGo --> CorrectReject
254
258
```
255
259
256
-
- Trials should be sampled from a uniform distribution using the `Numerics` package (install from `Tools` > `Manage Packages`).
260
+
- Trials should be sampled from a uniform distribution using the `Bonsai.Numerics` package.
257
261
- Response events should be based on a button press, and reject events on a timeout.
258
262
- Make sure to implement different visual or auditory feedback for either the cue or reward/failure states.
0 commit comments