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
+66-2Lines changed: 66 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -144,6 +144,9 @@ In order to translate our simple reaction time task in the previous exercises in
144
144
- Insert a [`SelectMany`] operator after `StimOn`, and set its `Name` property to `Response`.
145
145
- Double-click on the [`SelectMany`] node to open up its internal specification.
146
146
147
+
> [!Note]
148
+
> The `SelectMany` operator is used here to create a new state for every input event. `Source1` represents the input event that created the state, and `WorkflowOutput` will be used to report the end result from the state (e.g. whether the response was a success or failure).
@@ -158,15 +161,17 @@ In order to translate our simple reaction time task in the previous exercises in
158
161
- Run the workflow a couple of times and validate the state machine is responding to the button press.
159
162
160
163
> [!Note]
161
-
> The [`Condition`] operator allows you to specify arbitrary rules for accepting or rejecting inputs. Only inputs which pass the filter specified inside the [`Condition`] are allowed to proceed. Using an [`Equal`] operator allows us to filter only messages from that pin. It 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`).
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`).
162
165
163
166
### Exercise 5: Timeout and choice
164
167
168
+
We will modify our previous workflow to include a timeout during which the responder must make a choice.
- Insert a [`Condition`] operator after the `StimOff` node, and set its `Name` property to `Success`.
192
+
- In a new branch from `StimOff`, insert another [`Condition`], and set its `Name` property to `Miss`.
193
+
- Insert a [`SelectMany`] operator after the `Success` condition and change its `Name` property to `Reward`.
194
+
- Insert a [`SelectMany`] operator after the `Miss` condition and change its `Name` property to `Fail`.
195
+
196
+
We will now implement the task logic inside our nodes.
197
+
198
+
**`Miss`**:
199
+
:::workflow
200
+

201
+
:::
202
+
203
+
- Double-click on the `Miss` node to open up its internal specification.
204
+
- Insert a [`BitwiseNot`] operator after `Source1`.
205
+
206
+
_Why did we need to specify something for the `Miss` condition?_
207
+
_Why did we not need to specify anything for the `Success` condition?_
208
+
209
+
> [!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.
211
+
212
+
Inside the `Reward` and `Fail` node you can specify your own logic to signal the state of the trial.
213
+
For example, to make the LED blink three times in rapid succession for the `Reward` node:
214
+
215
+
**`Reward`**:
216
+
:::workflow
217
+

218
+
:::
219
+
220
+
- Delete the `Source1` operator.
221
+
- Copy the fixed-interval blinking LED from [Exercise 1](#exercise-1-generating-a-fixed-interval-stimulus).
222
+
- In the [`Timer`] node, set both the `DueTime` and the `Period` properties to 100ms.
223
+
- In the [`Delay`] node, set the `DueTime` properties to 100ms.
224
+
- Delete the [`Repeat`] node.
225
+
- Insert a [`RepeatCount`], set the `Count` property to 3.
226
+
- Insert the [`Last`] operator, and connect it to `WorkflowOutput`.
227
+
228
+
_Try out your state machine and check whether you understand the behavior of the reward signal._
229
+
230
+
- Copy the workflow in the `Reward` node and paste it into the `Miss` condition.
231
+
-**Optional**: Modify the `Fail` state in some way to signal a different trial outcome (e.g. make the LED blink more times, or move a motor).
232
+
233
+
- In the top-level workflow, insert a [`Merge`] operator and connect to it the outputs of both conditional branches and before the [`Repeat`] node.
234
+
235
+
_Try out your state machine and introduce variations to the task behavior and conditions._
0 commit comments