Skip to content

Commit b9cb79a

Browse files
committed
update jupyter notebook
1 parent 0f49805 commit b9cb79a

File tree

2 files changed

+245
-3
lines changed

2 files changed

+245
-3
lines changed

notebooks/saving_stim_files.ipynb

Lines changed: 242 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,250 @@
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": null,
12+
"execution_count": 8,
1313
"metadata": {},
1414
"outputs": [],
15-
"source": []
15+
"source": [
16+
"% add the relevant functions from the source and library folder\n",
17+
"addpath(genpath(fullfile(pwd, '..', 'src')))\n",
18+
"addpath(genpath(fullfile(pwd, '..', 'lib')))"
19+
]
20+
},
21+
{
22+
"cell_type": "markdown",
23+
"metadata": {},
24+
"source": [
25+
"## Set Up"
26+
]
27+
},
28+
{
29+
"cell_type": "code",
30+
"execution_count": 9,
31+
"metadata": {},
32+
"outputs": [
33+
{
34+
"name": "stdout",
35+
"output_type": "stream",
36+
"text": [
37+
"\r\n",
38+
"\r\n",
39+
"___________________________________________________\r\n",
40+
"___________________________________________________\r\n",
41+
" \r\n",
42+
" ___ ___ ___ ___ ___ ___ ___ \r\n",
43+
" / __| _ \\ _ \\ | _ )_ _| \\/ __|\r\n",
44+
" | (__| _/ _/ | _ \\| || |) \\__ \\\r\n",
45+
" \\___|_| |_| |___/___|___/|___/\r\n",
46+
" \r\n",
47+
"Thank you for using the CPP BIDS - version v2.0.0. \r\n",
48+
"\r\n",
49+
"Current list of contributors includes:\r\n",
50+
" Remi Gau\r\n",
51+
" Marco Barilari\r\n",
52+
" Ceren Battal\r\n",
53+
" Tomas Lenc\r\n",
54+
"\b\r\n",
55+
"\r\n",
56+
"Please cite using the following DOI: \r\n",
57+
" https://doi.org/10.5281/zenodo.4007674\r\n",
58+
"\r\n",
59+
"For bug report, suggestions or contributions see: \r\n",
60+
" https://github.com/cpp-lln-lab/CPP_BIDS\r\n",
61+
"\r\n",
62+
"___________________________________________________\r\n",
63+
"___________________________________________________\r\n",
64+
"\r\n",
65+
"\r\n",
66+
"\r\n",
67+
"Data will be saved in this directory:\r\n",
68+
"\t/home/remi/github/CPP_BIDS/notebooks/output/source/sub-001/ses-001/func\r\n",
69+
"\r\n",
70+
"Data will be saved in this file:\r\n",
71+
"\tsub-001_ses-001_task-testTask_run-001_events_date-202012250913.tsv\r\n"
72+
]
73+
}
74+
],
75+
"source": [
76+
"cfg.dir.output = fullfile(pwd, 'output');\n",
77+
"\n",
78+
"cfg.verbose = 2;\n",
79+
"\n",
80+
"cfg.subject.subjectNb = 1;\n",
81+
"cfg.subject.runNb = 1;\n",
82+
"\n",
83+
"cfg.task.name = 'test task';\n",
84+
"\n",
85+
"cfg.testingDevice = 'mri';\n",
86+
"\n",
87+
"cfg = createFilename(cfg);"
88+
]
89+
},
90+
{
91+
"cell_type": "markdown",
92+
"metadata": {},
93+
"source": [
94+
"## Define the columns of the stim.tsv"
95+
]
96+
},
97+
{
98+
"cell_type": "code",
99+
"execution_count": 10,
100+
"metadata": {},
101+
"outputs": [],
102+
"source": [
103+
"logFile.extraColumns = {'Speed', 'LHL24', 'is_Fixation'};\n",
104+
"\n",
105+
"logFile = saveEventsFile('init_stim', cfg, logFile);\n",
106+
"\n",
107+
"logFile.extraColumns.Speed.length = 1;\n",
108+
"logFile.extraColumns.LHL24.length = 3;\n",
109+
"logFile.extraColumns.is_Fixation.length = 1;"
110+
]
111+
},
112+
{
113+
"cell_type": "code",
114+
"execution_count": 11,
115+
"metadata": {},
116+
"outputs": [
117+
{
118+
"name": "stdout",
119+
"output_type": "stream",
120+
"text": [
121+
"\n",
122+
" scalar structure containing the fields:\n",
123+
"\n",
124+
" extraColumns =\n",
125+
"\n",
126+
" scalar structure containing the fields:\n",
127+
"\n",
128+
" Speed =\n",
129+
"\n",
130+
" scalar structure containing the fields:\n",
131+
"\n",
132+
" bids: 1x1 scalar struct\n",
133+
" length: 1x1 scalar\n",
134+
"\n",
135+
" LHL24 =\n",
136+
"\n",
137+
" scalar structure containing the fields:\n",
138+
"\n",
139+
" bids: 1x1 scalar struct\n",
140+
" length: 1x1 scalar\n",
141+
"\n",
142+
" is_Fixation =\n",
143+
"\n",
144+
" scalar structure containing the fields:\n",
145+
"\n",
146+
" bids: 1x1 scalar struct\n",
147+
" length: 1x1 scalar\n",
148+
"\n",
149+
"\n",
150+
" onset = 55\n",
151+
" trial_type = motion_up\n",
152+
" duration = 66\n",
153+
" isStim = 1\n",
154+
" filename = sub-001_ses-001_task-testTask_run-001_stim_date-202012250913.tsv\n",
155+
" fileID = 3\n",
156+
" Speed = 2\n",
157+
" LHL24 =\n",
158+
"\n",
159+
" 1 2 3\n",
160+
"\n",
161+
" is_Fixation = 1\n",
162+
"\n",
163+
" scalar structure containing the fields:\n",
164+
"\n",
165+
" extraColumns =\n",
166+
"\n",
167+
" scalar structure containing the fields:\n",
168+
"\n",
169+
" Speed =\n",
170+
"\n",
171+
" scalar structure containing the fields:\n",
172+
"\n",
173+
" bids: 1x1 scalar struct\n",
174+
" length: 1x1 scalar\n",
175+
"\n",
176+
" LHL24 =\n",
177+
"\n",
178+
" scalar structure containing the fields:\n",
179+
"\n",
180+
" bids: 1x1 scalar struct\n",
181+
" length: 1x1 scalar\n",
182+
"\n",
183+
" is_Fixation =\n",
184+
"\n",
185+
" scalar structure containing the fields:\n",
186+
"\n",
187+
" bids: 1x1 scalar struct\n",
188+
" length: 1x1 scalar\n",
189+
"\n",
190+
"\n",
191+
" onset = 55\n",
192+
" trial_type = motion_up\n",
193+
" duration = 66\n",
194+
" isStim = 1\n",
195+
" filename = sub-001_ses-001_task-testTask_run-001_stim_date-202012250913.tsv\n",
196+
" fileID = 3\n",
197+
" Speed = 2\n",
198+
" LHL24 =\n",
199+
"\n",
200+
" 1 2 3\n",
201+
"\n",
202+
" is_Fixation = 1\n",
203+
"2.000000\t1.000000\t2.000000\t3.000000\ttrue\t\n",
204+
"\n",
205+
"Data were saved in this file:\n",
206+
"\n",
207+
"/home/remi/github/CPP_BIDS/notebooks/output/source/sub-001/ses-001/func/sub-001_ses-001_task-testTask_run-001_stim_date-202012250913.tsv\n",
208+
"\n"
209+
]
210+
}
211+
],
212+
"source": [
213+
"% create the events file and header\n",
214+
"logFile = saveEventsFile('open', cfg, logFile);\n",
215+
"\n",
216+
"% ROW 1\n",
217+
"logFile(1, 1).onset = 55;\n",
218+
"logFile(end, 1).trial_type = 'motion_up';\n",
219+
"logFile(end, 1).duration = 66;\n",
220+
"logFile(end, 1).Speed = 2;\n",
221+
"logFile(end, 1).LHL24 = 1:3;\n",
222+
"logFile(end, 1).is_Fixation = true;\n",
223+
"\n",
224+
"logFile = saveEventsFile('save', cfg, logFile);\n",
225+
"\n",
226+
"% close the file\n",
227+
"saveEventsFile('close', cfg, logFile);"
228+
]
229+
},
230+
{
231+
"cell_type": "markdown",
232+
"metadata": {},
233+
"source": [
234+
"## Inspect the content of the stim.tsv file\n",
235+
" \n",
236+
"The `onset`, `duration` and `trial_type` are ignored because they were note spcified in the `extraColumns` field.\n"
237+
]
238+
},
239+
{
240+
"cell_type": "code",
241+
"execution_count": 13,
242+
"metadata": {},
243+
"outputs": [
244+
{
245+
"name": "stdout",
246+
"output_type": "stream",
247+
"text": [
248+
"2.000000\t1.000000\t2.000000\t3.000000\ttrue\t\r\n",
249+
"\n"
250+
]
251+
}
252+
],
253+
"source": [
254+
"!cat output/source/sub-001/ses-001/func/sub-001_ses-001_task-testTask_run-001_stim_date-*.tsv "
255+
]
16256
}
17257
],
18258
"metadata": {

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ Sphinx
22
sphinxcontrib-matlabdomain
33
sphinxcontrib-napoleon
44
sphinx_rtd_theme
5-
miss_hit==0.9.15
5+
miss_hit==0.9.15
6+
notebook
7+
octave_kernel

0 commit comments

Comments
 (0)