Skip to content

Commit 14c2cf7

Browse files
committed
update 1 task template; 2. cn_md tutorials
1 parent f1bc97c commit 14c2cf7

13 files changed

Lines changed: 296 additions & 363 deletions

File tree

docs/tutorials/build_stimunit_cn.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,6 @@ fb.set_state(prefix='special', hit=True)
749749

750750
现在您已经了解了如何使用 `StimUnit`,您可以:
751751

752-
- 探索 [BlockUnit 教程](build_blocks.md) 来将试次组织成组块
753-
- 了解 [StimBank](build_stimulus.md) 以进行灵活的刺激管理
754-
- 查看 [发送触发器](send_trigger.md) 以用于 EEG/MEG 实验
752+
- 探索 [BlockUnit 教程](build_blocks_cn.md) 来将试次组织成组块
753+
- 了解 [StimBank](build_stimulus_cn.md) 以进行灵活的刺激管理
754+
- 查看 [发送触发器](send_trigger_cn.md) 以用于 EEG/MEG 实验

docs/tutorials/cli_usage_cn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,5 @@ psyflow-init
7373

7474
现在您知道如何初始化项目,您已准备好开始构建您的实验:
7575

76-
- **入门**:按照[入门教程](getting_started.md)从头开始构建一个简单的任务。
77-
- **学习核心概念**:深入了解[StimBank](build_stimulus.md)[StimUnit](build_stimunit.md)[BlockUnit](build_blocks.md)教程,以了解 PsyFlow 的关键组件。
76+
- **入门**:按照[入门教程](getting_started_cn.md)从头开始构建一个简单的任务。
77+
- **学习核心概念**:深入了解[StimBank](build_stimulus_cn.md)[StimUnit](build_stimunit_cn.md)[BlockUnit](build_blocks_cn.md)教程,以了解 PsyFlow 的关键组件。

docs/tutorials/llm_client_cn.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,6 @@ print("保存到 ./config/config.es.yaml")
157157

158158
现在您已经了解了如何在 PsyFlow 中使用 LLM,您可能对以下内容感兴趣:
159159

160-
- **入门**:如果您是 PsyFlow 的新手,请查看[入门教程](getting_started.md)
161-
- **发送触发器**:在[TriggerSender 教程](send_trigger.md)中了解如何发送硬件触发器。
162-
- **构建试验**:在[StimUnit 教程](build_stimunit.md)中了解如何构建复杂的试验。
160+
- **入门**:如果您是 PsyFlow 的新手,请查看[入门教程](getting_started_cn.md)
161+
- **发送触发器**:在[TriggerSender 教程](send_trigger_cn.md)中了解如何发送硬件触发器。
162+
- **构建试验**:在[StimUnit 教程](build_stimunit_cn.md)中了解如何构建复杂的试验。

docs/tutorials/send_trigger_cn.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,6 @@ def run_trial(win, kb, settings, condition, stim_bank, controller, trigger_sende
345345

346346
现在您知道如何发送触发器,您可以探索 PsyFlow 的其他部分:
347347

348-
- **入门**:如果您是 PsyFlow 的新手,请查看[入门教程](getting_started.md)
349-
- **构建试验**:在[StimUnit 教程](build_stimunit.md)中了解如何构建复杂的试验。
350-
- **组织模块**:在[BlockUnit 教程](build_blocks.md)中了解如何将试验组织成模块。
348+
- **入门**:如果您是 PsyFlow 的新手,请查看[入门教程](getting_started_cn.md)
349+
- **构建试验**:在[StimUnit 教程](build_stimunit_cn.md)中了解如何构建复杂的试验。
350+
- **组织模块**:在[BlockUnit 教程](build_blocks_cn.md)中了解如何将试验组织成模块。
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
{
2-
"project_name": "my_task",
3-
"psychopy_version": "2023.2.1",
4-
"psyflow_version": "0.1.0"
2+
"project_name": "my_task"
53
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore subject data files
2+
/data/
3+
src/__pycache__/
Lines changed: 165 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,168 @@
1-
This project was generated with **psyflow-init**.
1+
# Monetary Incentive Delay (MID) Task
22

3-
## Usage
3+
| Field | Value |
4+
|----------------------|------------------------------|
5+
| Name | Monetary Incentive Delay (MID) Task |
6+
| Version | main (1.0) |
7+
| URL / Repository |https://github.com/TaskBeacon/MID |
8+
| Short Description | A task measuring reward anticipation and feedback processing using adaptive timing |
9+
| Created By |Zhipeng Cao (zhipeng30@foxmail.com) |
10+
| Date Updated |2025/06/21 |
11+
| PsyFlow Version |0.1.0 |
12+
| PsychoPy Version |2025.1.1 |
13+
| Modality |Behavior/EEG |
414

5-
1. Edit the configuration files under `config/` to define your
6-
stimuli, trigger codes and general task settings.
7-
2. Run `python main.py` to launch the experiment.
815

9-
For full documentation on psyflow and how to customise this template,
10-
visit the [GitHub Pages site](https://taskbeacon.github.io/psyflow/).
16+
## 1. Task Overview
17+
18+
The Monetary Incentive Delay (MID) Task is designed to assess reward processing and motivational control. Participants respond to brief target stimuli that follow cues indicating potential monetary gain, loss, or neutral outcomes. By analyzing reaction times and success rates, the task evaluates anticipatory and feedback-related cognitive processes. An adaptive timing algorithm adjusts target durations based on participant performance, maintaining consistent task difficulty.
19+
20+
## 2. Task Flow
21+
22+
### Block-Level Flow
23+
24+
| Step | Description |
25+
|----------------------------|-----------------------------------------------------------------------------|
26+
| Load Config | Load task configuration and subject form |
27+
| Collect Subject Info | Collect demographic/subject info using `SubInfo` form |
28+
| Setup Triggers | Initialize trigger sender using serial port (COM3) |
29+
| Initialize Window/Input | Create PsychoPy window and keyboard handler |
30+
| Load Stimuli | Load all stimuli via `StimBank`, convert instructions to voice, preload |
31+
| Setup Controller | Create adaptive controller from config |
32+
| Show Instructions | Present text and voice instruction before starting |
33+
| Loop Over Blocks | For each block: countdown, run 60 trials, compute and show block feedback |
34+
| Show Goodbye | Present final feedback with total score |
35+
| Save Data | Save all trial data to CSV |
36+
| Close | Close serial port and quit PsychoPy |
37+
38+
### Trial-Level Flow
39+
40+
| Step | Description |
41+
|---------------------|-----------------------------------------------------------------------------|
42+
| Cue | Show condition-specific cue (win/lose/neutral) with trigger |
43+
| Anticipation | Display fixation; allow response (early keypress logged) |
44+
| Target | Show target with adaptive duration; record response |
45+
| Pre-feedback Fixation | Display fixation before feedback |
46+
| Feedback | Present hit/miss feedback based on performance |
47+
| Adaptive Update | Update target duration based on hit/miss outcome |
48+
49+
### Controller Logic
50+
51+
| Feature | Description |
52+
|---------------------|-----------------------------------------------------------------------------|
53+
| Adaptive Duration | Target duration adjusts between 0.04 and 0.37 seconds |
54+
| Step Size | ±0.03 seconds |
55+
| Accuracy Target | 66% accuracy threshold |
56+
| Condition Specific | Tracks performance separately by condition (win/lose/neutral) |
57+
| Logging | Performance logs are printed to PsychoPy console |
58+
59+
## 3. Configuration Summary
60+
61+
### a. Subject Info
62+
63+
| Field | Meaning |
64+
|-------------|----------------------------|
65+
| subject_id | Unique participant number (101–999, 3 digits) |
66+
| subname | Participant name (pinyin) |
67+
| age | Participant age (5–60) |
68+
| gender | Participant gender (Male/Female) |
69+
70+
### b. Window Settings
71+
72+
| Parameter | Value |
73+
|-----------------------|-------------|
74+
| size | [1920, 1080]|
75+
| units | deg |
76+
| screen | 1 |
77+
| bg_color | gray |
78+
| fullscreen | True |
79+
| monitor_width_cm | 60 |
80+
| monitor_distance_cm | 72 |
81+
82+
### c. Stimuli
83+
84+
| Name | Type | Description |
85+
|--------------------------|-----------|-------------------------------------------------------|
86+
| fixation | text | Central cross "+" |
87+
| win_cue | circle | Magenta circle (reward) |
88+
| lose_cue | rect | Yellow square (punishment) |
89+
| neut_cue | triangle | Cyan triangle (neutral) |
90+
| win_target | circle | Black circle target |
91+
| lose_target | rect | Black square target |
92+
| neut_target | triangle | Black triangle target |
93+
| win_hit_feedback | textbox | “击中 +10 分” (black text, SimHei) |
94+
| win_miss_feedback | textbox | “未击中 +0 分” |
95+
| lose_hit_feedback | textbox | “击中 -0 分” |
96+
| lose_miss_feedback | textbox | “未击中 -10 分” |
97+
| neut_hit_feedback | textbox | “击中 +0 分” |
98+
| neut_miss_feedback | textbox | “未击中 -0 分” |
99+
| instruction_text | textbox | Multi-line Chinese instructions (includes scoring rules) |
100+
| block_break | text | Inter-block message showing block, accuracy, and score |
101+
| good_bye | text | End screen showing final score |
102+
103+
### d. Timing
104+
105+
| Phase | Duration (s) |
106+
|------------------------|--------------------|
107+
| cue | 0.3 |
108+
| anticipation | random 1.0–1.2 |
109+
| target | adaptive (0.04–0.37)|
110+
| prefeedback fixation | random 0.6–0.8 |
111+
| feedback | 1.0 |
112+
113+
### e. Triggers
114+
115+
| Event | Code |
116+
|--------------------------|-------|
117+
| exp_onset | 98 |
118+
| exp_end | 99 |
119+
| block_onset | 100 |
120+
| block_end | 101 |
121+
| win_cue_onset | 10 |
122+
| win_anti_onset | 11 |
123+
| win_target_onset | 12 |
124+
| win_hit_fb_onset | 13 |
125+
| win_miss_fb_onset | 14 |
126+
| win_key_press | 15 |
127+
| win_no_response | 16 |
128+
| lose_cue_onset | 20 |
129+
| lose_anti_onset | 21 |
130+
| lose_target_onset | 22 |
131+
| lose_hit_fb_onset | 23 |
132+
| lose_miss_fb_onset | 24 |
133+
| lose_key_press | 25 |
134+
| lose_no_response | 26 |
135+
| neut_cue_onset | 30 |
136+
| neut_anti_onset | 31 |
137+
| neut_target_onset | 32 |
138+
| neut_hit_fb_onset | 33 |
139+
| neut_miss_fb_onset | 34 |
140+
| neut_key_press | 35 |
141+
| neut_no_response | 36 |
142+
| fixation_onset | 1 |
143+
144+
### f. Adaptive Controller
145+
146+
| Parameter | Value |
147+
|--------------------|----------|
148+
| initial_duration | 0.2 |
149+
| min_duration | 0.04 |
150+
| max_duration | 0.37 |
151+
| step | 0.03 |
152+
| target_accuracy | 0.66 |
153+
| condition_specific | true |
154+
155+
## 4. Methods
156+
157+
Participants performed a computerized Monetary Incentive Delay (MID) task to assess motivational processing under different reward contingencies. The task consisted of **3 blocks**, each comprising **60 trials**, totaling **180 trials**. Each trial began with a cue, a colored shape (circle, square, or triangle), signaling whether the trial was a reward, punishment, or neutral condition. Following a variable anticipation phase (1.0–1.2 s), a black target appeared briefly. Participants were instructed to press the spacebar as quickly as possible upon target onset.
158+
159+
The target's presentation duration was controlled by an adaptive algorithm that updated the duration after each trial based on performance. Initial target duration was set to 0.2 s and was adjusted between 0.04 and 0.37 s using ±0.03 s increments to stabilize performance at a target accuracy of 66%, tracked separately by condition.
160+
161+
Feedback followed the target phase, based on whether participants responded within the target duration. “击中” (“hit”) and “未击中” (“miss”) messages were shown with point gain/loss specific to the cue type. After each block, a break screen summarized the participant's accuracy and cumulative score. The task began with audio-visual instructions and ended with a final message displaying total score.
162+
163+
## 5. References
164+
The task is originally developed by Knutson 2000:
165+
>Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary incentive delay task. Neuroimage, 12(1), 20-27.
166+
167+
Here, we adopted the ABCD Study design of the task:
168+
>Casey, B. J., Cannonier, T., Conley, M. I., Cohen, A. O., Barch, D. M., Heitzeg, M. M., ... & Dale, A. M. (2018). The adolescent brain cognitive development (ABCD) study: imaging acquisition across 21 sites. Developmental cognitive neuroscience, 32, 43-54.

psyflow/templates/cookiecutter-psyflow/{{cookiecutter.project_name}}/config/config.yaml

Lines changed: 0 additions & 168 deletions
This file was deleted.

0 commit comments

Comments
 (0)