Skip to content

Commit f91d00b

Browse files
committed
Copy 5th exercise on CPP from state machine tutorial
1 parent 1c28bb4 commit f91d00b

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

tutorials/hobgoblin-closeloop.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ To better understand what each parameter controls, try the following modificatio
122122
> **Optional** Verify the pulse train by connecting the output to a digital input pin.
123123
124124
>[!TIP]
125-
> If your cameras support external triggering, you can use pulse trains to trigger frame capture. Recording the same pulse train on a digital input with the `Hobgoblin` allows you to have hardware timestamped images that are automatically aligned with other acquired data.
125+
> If your camera supports external triggering, you can use pulse trains to trigger frame capture. Recording the same pulse train on a digital input with the `Hobgoblin` allows you to have hardware timestamped images that are automatically aligned with other acquired data.
126126
127127
### Exercise 4: Triggering a digital line based on region of interest activity
128128

@@ -144,8 +144,24 @@ To better understand what each parameter controls, try the following modificatio
144144
> [!Note]
145145
> The [`CropPolygon`] operator uses the `Regions` property to define multiple, possibly non-rectangular regions. The visual editor is similar to [`Crop`], where you draw a rectangular box. However, in [`CropPolygon`] you can move the corners of the box by right-clicking _inside_ the box and dragging the cursor to the new position. You can add new points by double-clicking with the left mouse button, and delete points by double-clicking with the right mouse button. You can delete regions by pressing the `Del` key and cycle through selected regions by pressing the `Tab` key.
146146
147+
### Exercise 5: Conditioned place preference
148+
149+
Implement the following trial structure for conditioned place preference. `enter` and `leave` events should be triggered in real-time from the camera, by tracking an object moving in or out of a region of interest (ROI). `Reward` should be triggered once upon entering the ROI, and not repeat again until the object exits the ROI and the ITI has elapsed.
150+
151+
```mermaid
152+
stateDiagram-v2
153+
direction LR
154+
ITI --> Ready: elapsed
155+
Ready --> Reward: enter
156+
Reward --> ITI: leave
157+
```
158+
159+
> [!Tip]
160+
> There are several ways to implement ROI activation, so feel free to explore different ideas. Consider using either [`Crop`], [`RoiActivity`], or [`ContainsPoint`] as part of different strategies to implement the `enter` and `leave` events.
161+
147162
<!--Reference Style Links -->
148163
[`BitwiseNot`]: xref:Bonsai.Expressions.BitwiseNotBuilder
164+
[`ContainsPoint`]: xref:Bonsai.Vision.ContainsPoint
149165
[`CreateMessage`]: xref:Harp.Hobgoblin.CreateMessage
150166
[`Crop`]: xref:Bonsai.Vision.Crop
151167
[`CropPolygon`]: xref:Bonsai.Vision.CropPolygon
@@ -156,24 +172,17 @@ To better understand what each parameter controls, try the following modificatio
156172
[`DistinctUntilChanged`]: xref:Bonsai.Reactive.DistinctUntilChanged
157173
[`DigitalOutputSet`]: xref:Harp.Hobgoblin.DigitalOutputSet
158174
[`DigitalOutputClear`]: xref:Harp.Hobgoblin.DigitalOutputClear
159-
<!-- [`DigitalOutputClearPayload`]: xref:Harp.Hobgoblin.CreateDigitalOutputSetPayload -->
160175
[`DigitalOutputSetPayload`]: xref:Harp.Hobgoblin.CreateDigitalOutputClearPayload
161176
[`GreaterThan`]: xref:Bonsai.Expressions.GreaterThanBuilder
162177
[`Grayscale`]: xref:Bonsai.Vision.Grayscale
163-
<!-- [`HarpMessage`]: xref:Bonsai.Harp.HarpMessage -->
164178
[`KeyDown`]: xref:Bonsai.Windows.Input.KeyDown
165-
<!-- [`Merge`]: xref:Bonsai.Reactive.Merge -->
166179
[`MulticastSubject`]: xref:Bonsai.Expressions.MulticastSubject
167180
[`Parse`]: xref:Harp.Hobgoblin.Parse
168-
<!-- [`PublishSubject`]: xref:Bonsai.Reactive.PublishSubject -->
169-
<!-- [`RollingGraph`]: xref:Bonsai.Gui.ZedGraph.RollingGraphBuilder -->
181+
[`RoiActivity`]: xref:Bonsai.Vision.RoiActivity
170182
[`StartPulseTrainPayload`]: xref:Harp.Hobgoblin.CreateStartPulseTrainPayload
171183
[`StopPulseTrainPayload`]: xref:Harp.Hobgoblin.CreateStopPulseTrainPayload
172184
[`SubscribeSubject`]: xref:Bonsai.Expressions.SubscribeSubject
173185
[`Sum`]: xref:Bonsai.Dsp.Sum
174186
[`Threshold`]: xref:Bonsai.Vision.Threshold
175187
[`TimestampedDigitalOutputTogglePayload`]: xref:Harp.Hobgoblin.TimestampedDigitalOutputToggle
176-
<!-- [`TimestampedDigitalOutputSet`]: xref:Harp.Hobgoblin.TimestampedDigitalOutputSet -->
177-
<!-- [`TimestampedDigitalOutputClear`]: xref:Harp.Hobgoblin.TimestampedDigitalOutputClear -->
178-
[`VideoCaptureDevice`]: xref:Bonsai.Video.VideoCaptureDevice
179-
<!-- [`Zip`]: xref:Bonsai.Reactive.Zip -->
188+
[`VideoCaptureDevice`]: xref:Bonsai.Video.VideoCaptureDevice

0 commit comments

Comments
 (0)