Skip to content

Commit c40bbd9

Browse files
committed
minor cleanup xdf
1 parent 026f6f8 commit c40bbd9

6 files changed

Lines changed: 1046 additions & 1196 deletions

File tree

0 Bytes
Binary file not shown.

hypyp/xdf/xdf_stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Markers():
1414
1515
Parameters:
1616
timestamps (1D np.array): The time of markers
17-
descriptions (List[str]): The string valu for every marker. Must have the same length as timestamps
17+
descriptions (List[str]): The string value for every marker. Must have the same length as timestamps
1818
"""
1919
timestamps: np.array
2020
descriptions: List[str]

poetry.lock

Lines changed: 980 additions & 973 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/test_xdf.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,26 @@
44
from hypyp.xdf import XDFImport, XDFStream
55
import mne
66

7-
#file_path = 'data/dyad-example.xdf'
8-
#file_path = 'data/ExampleWorkshopData/FingerTappingExample4.xdf'
9-
107
file_path = 'data/XDF/dyad-example-noise.xdf'
118
file_path_with_markers = 'data/XDF/dyad-example-with-markers.xdf'
129

13-
# These have been extracted with print(xdf)
14-
#Stream id 3 of type 'Markers' with name 'LSLOutletHS1-Markers'
15-
#Stream id 1 of type 'Accelerometer' with name 'LSLOutletHS1-Accelerometer'
16-
#Stream id 8 of type 'Quality' with name 'LSLOutletHS1-Quality'
17-
#Stream id 2 of type 'EEG' with name 'LSLOutletHS1-EEG'
18-
#Stream id 4 of type 'Markers' with name 'LSLOutletHS2-Markers'
19-
#Stream id 6 of type 'Accelerometer' with name 'LSLOutletHS2-Accelerometer'
20-
#Stream id 5 of type 'Quality' with name 'LSLOutletHS2-Quality'
21-
#Stream id 7 of type 'EEG' with name 'LSLOutletHS2-EEG'
22-
STREAM_ID_MARKERS_1 = 3
10+
## These have been extracted with print(xdf), and are used for testing select_match by stream id and mapping
11+
# Stream id 1 of type 'Accelerometer' with name 'LSLOutletHS1-Accelerometer'
12+
# Stream id 2 of type 'EEG' with name 'LSLOutletHS1-EEG'
13+
# Stream id 3 of type 'Markers' with name 'LSLOutletHS1-Markers'
14+
# Stream id 4 of type 'Markers' with name 'LSLOutletHS2-Markers'
15+
# Stream id 5 of type 'Quality' with name 'LSLOutletHS2-Quality'
16+
# Stream id 6 of type 'Accelerometer' with name 'LSLOutletHS2-Accelerometer'
17+
# Stream id 7 of type 'EEG' with name 'LSLOutletHS2-EEG'
18+
# Stream id 8 of type 'Quality' with name 'LSLOutletHS1-Quality'
2319
STREAM_ID_ACC_1 = 1
24-
STREAM_ID_QUALITY_1 = 8
2520
STREAM_ID_EEG_1 = 2
21+
STREAM_ID_MARKERS_1 = 3
2622
STREAM_ID_MARKERS_2 = 4
27-
STREAM_ID_ACC_2 = 6
2823
STREAM_ID_QUALITY_2 = 5
24+
STREAM_ID_ACC_2 = 6
2925
STREAM_ID_EEG_2 = 7
26+
STREAM_ID_QUALITY_1 = 8
3027

3128
def test_instanciate():
3229
xdf = XDFImport(file_path)
@@ -42,7 +39,6 @@ def test_instanciate():
4239
assert xdf.available_streams[6].name == 'LSLOutletHS2-Quality'
4340
assert xdf.available_streams[7].name == 'LSLOutletHS2-EEG'
4441

45-
4642
assert xdf.available_streams[0].type == 'Markers'
4743
assert xdf.available_streams[1].type == 'Accelerometer'
4844
assert xdf.available_streams[2].type == 'Quality'
@@ -186,7 +182,6 @@ def test_subject_unique_name():
186182
assert xdf.selected_streams[0].get_unique_name() == 'LSLOutletHS1-Accelerometer'
187183
assert xdf.selected_streams[0].get_unique_name(append_stream_id=True) == 'LSLOutletHS1-Accelerometer-1'
188184

189-
190185
def test_markers():
191186
xdf = XDFImport(file_path_with_markers)
192187
keys = list(xdf.markers_dict)

tutorial/import_from_xdf.ipynb

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"# Importing XDF files in HyPyP\n",
99
"@Author : [@jonasmago](https://github.com/jonasmago) & [@FranckPrts](https://github.com/FranckPrts).\n",
1010
"\n",
11-
"Updated by : Patrice Fortin\n",
11+
"Updated by : [@patricefortin](https://github.com/patricefortin) \n",
1212
"\n",
13-
"Last updated: \n",
13+
"Last updated: 2025/6/6\n",
1414
"\n",
1515
"This tutorial guides you in using the `XDFImport` class provided by [HyPyP](https://github.com/ppsp-team/HyPyP/blob/master/hypyp/xdf/).\n",
1616
"\n",
@@ -28,13 +28,17 @@
2828
},
2929
{
3030
"cell_type": "code",
31-
"execution_count": 1,
31+
"execution_count": null,
3232
"metadata": {},
3333
"outputs": [],
3434
"source": [
3535
"from hypyp.xdf import XDFImport\n",
3636
"\n",
37+
"# This file has been generated using 2 starstim-32 and recorded by LabRecorder.\n",
38+
"# No participant were wearing the starstim so we only have noise\n",
3739
"path_xdf = \"../data/XDF/dyad-example-noise.xdf\"\n",
40+
"\n",
41+
"# This file has been generated from synthetic noise\n",
3842
"path_xdf_with_markers = \"../data/XDF/dyad-example-with-markers.xdf\""
3943
]
4044
},
@@ -171,6 +175,20 @@
171175
"execution_count": 4,
172176
"metadata": {},
173177
"outputs": [
178+
{
179+
"name": "stderr",
180+
"output_type": "stream",
181+
"text": [
182+
"Error reading chunk length\n",
183+
"Traceback (most recent call last):\n",
184+
" File \"/home/patrice/.cache/pypoetry/virtualenvs/hypyp-9w4TS9uv-py3.12/lib/python3.12/site-packages/pyxdf/pyxdf.py\", line 230, in load_xdf\n",
185+
" chunklen = _read_varlen_int(f)\n",
186+
" ^^^^^^^^^^^^^^^^^^^\n",
187+
" File \"/home/patrice/.cache/pypoetry/virtualenvs/hypyp-9w4TS9uv-py3.12/lib/python3.12/site-packages/pyxdf/pyxdf.py\", line 489, in _read_varlen_int\n",
188+
" raise RuntimeError(\"invalid variable-length integer encountered.\")\n",
189+
"RuntimeError: invalid variable-length integer encountered.\n"
190+
]
191+
},
174192
{
175193
"name": "stdout",
176194
"output_type": "stream",
@@ -189,11 +207,11 @@
189207
" Channel types: [stim]\n",
190208
" Stream id 3 of type 'EEG' with name 'EEG_subject_1'\n",
191209
" Sampling Rate: 1000.0\n",
192-
" Channel names: [foo,bar,baz]\n",
210+
" Channel names: [Ch1,Ch2,Ch3]\n",
193211
" Channel types: [eeg,eeg,eeg]\n",
194212
" Stream id 1 of type 'EEG' with name 'EEG_subject_2'\n",
195213
" Sampling Rate: 1000.0\n",
196-
" Channel names: [foo,bar,baz]\n",
214+
" Channel names: [Ch1,Ch2,Ch3]\n",
197215
" Channel types: [eeg,eeg,eeg]\n",
198216
"Selected streams: [RandomStrStream,EEG_subject_1,EEG_subject_2]\n",
199217
"\n",
@@ -538,13 +556,13 @@
538556
"name": "stdout",
539557
"output_type": "stream",
540558
"text": [
541-
"Writing /tmp/tmpnbmrtr9u/LSLOutletHS1-EEG_raw.fif\n",
542-
"Closing /tmp/tmpnbmrtr9u/LSLOutletHS1-EEG_raw.fif\n",
559+
"Writing /tmp/tmp0k1yas12/LSLOutletHS1-EEG_raw.fif\n",
560+
"Closing /tmp/tmp0k1yas12/LSLOutletHS1-EEG_raw.fif\n",
543561
"[done]\n",
544-
"Writing /tmp/tmpnbmrtr9u/LSLOutletHS2-EEG_raw.fif\n",
545-
"Closing /tmp/tmpnbmrtr9u/LSLOutletHS2-EEG_raw.fif\n",
562+
"Writing /tmp/tmp0k1yas12/LSLOutletHS2-EEG_raw.fif\n",
563+
"Closing /tmp/tmp0k1yas12/LSLOutletHS2-EEG_raw.fif\n",
546564
"[done]\n",
547-
"Files: ['/tmp/tmpnbmrtr9u/LSLOutletHS1-EEG_raw.fif', '/tmp/tmpnbmrtr9u/LSLOutletHS2-EEG_raw.fif']\n"
565+
"Files: ['/tmp/tmp0k1yas12/LSLOutletHS1-EEG_raw.fif', '/tmp/tmp0k1yas12/LSLOutletHS2-EEG_raw.fif']\n"
548566
]
549567
}
550568
],
@@ -624,7 +642,7 @@
624642
},
625643
{
626644
"cell_type": "code",
627-
"execution_count": 18,
645+
"execution_count": 17,
628646
"metadata": {},
629647
"outputs": [
630648
{
@@ -730,15 +748,6 @@
730748
"\n",
731749
"xdf_misc.mne_raws[0].plot(duration=1, start=14)"
732750
]
733-
},
734-
{
735-
"cell_type": "code",
736-
"execution_count": null,
737-
"metadata": {},
738-
"outputs": [],
739-
"source": [
740-
"\n"
741-
]
742751
}
743752
],
744753
"metadata": {

tutorial/simulations.ipynb

Lines changed: 24 additions & 185 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)