Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG]: Add support for reading curry EEG files #1072

Merged
merged 9 commits into from
Oct 1, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions mne_bids/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
'.lay': 'Persyst', '.dat': 'Persyst',
'.EEG': 'Nihon Kohden',
'.cnt': 'Neuroscan', '.CNT': 'Neuroscan',
'.bin': 'EGI'}
'.bin': 'EGI',
'.cdt': 'n/a'}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not "Curry"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my understanding Curry is used by different amps / manufacturers

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah sorry. got confused. yes we could do "curry" for the fileformat


ieeg_manufacturers = {'.vhdr': 'Brain Products', '.eeg': 'Brain Products',
'.edf': 'n/a', '.EDF': 'n/a', '.set': 'n/a',
Expand All @@ -79,7 +80,8 @@
'.EEG': io.read_raw_nihon,
'.cnt': io.read_raw_cnt, '.CNT': io.read_raw_cnt,
'.bin': io.read_raw_egi,
'.snirf': io.read_raw_snirf}
'.snirf': io.read_raw_snirf,
'.cdt': io.read_raw_curry}


# Merge the manufacturer dictionaries in a python2 / python3 compatible way
Expand Down Expand Up @@ -130,7 +132,7 @@
ALLOWED_INPUT_EXTENSIONS = \
allowed_extensions_meg + allowed_extensions_eeg + \
allowed_extensions_ieeg + allowed_extensions_nirs + \
['.lay', '.EEG', '.cnt', '.CNT', '.bin']
['.lay', '.EEG', '.cnt', '.CNT', '.bin', '.cdt']

# allowed suffixes (i.e. last "_" delimiter in the BIDS filenames before
# the extension)
Expand Down
3 changes: 2 additions & 1 deletion mne_bids/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def _read_raw(raw_path, electrode=None, hsp=None, hpi=None,
elif ext == '.fif':
raw = reader[ext](raw_path, allow_maxshield, **kwargs)

elif ext in ['.ds', '.vhdr', '.set', '.edf', '.bdf', '.EDF', '.snirf']:
elif ext in ['.ds', '.vhdr', '.set', '.edf', '.bdf', '.EDF', '.snirf',
'.cdt']:
raw_path = Path(raw_path)
raw = reader[ext](raw_path, **kwargs)

Expand Down
57 changes: 56 additions & 1 deletion mne_bids/tests/test_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def fn(fname, *args, **kwargs):
_read_raw_cnt = _wrap_read_raw(mne.io.read_raw_cnt)
_read_raw_snirf = _wrap_read_raw(mne.io.read_raw_snirf)
_read_raw_egi = _wrap_read_raw(mne.io.read_raw_egi)
_read_raw_curry = _wrap_read_raw(mne.io.read_raw_curry)

# parametrized directory, filename and reader for EEG/iEEG data formats
test_eegieeg_data = [
Expand All @@ -120,6 +121,7 @@ def fn(fname, *args, **kwargs):
('NihonKohden', 'MB0400FU.EEG', _read_raw_nihon),
('CNT', 'scan41_short.cnt', _read_raw_cnt),
('EGI', 'test_egi.mff', _read_raw_egi),
('curry', 'test_bdf_stim_channel Curry 8.cdt', _read_raw_curry),
]
test_convert_data = test_eegieeg_data.copy()
test_convert_data.append(('CTF', 'testdata_ctf.ds', _read_raw_ctf))
Expand All @@ -135,9 +137,11 @@ def fn(fname, *args, **kwargs):
('Persyst', 'BrainVision', 'sub-pt1_ses-02_task-monitor_acq-ecog_run-01_clip2.lay', _read_raw_persyst), # noqa
('NihonKohden', 'BrainVision', 'MB0400FU.EEG', _read_raw_nihon),
('CNT', 'BrainVision', 'scan41_short.cnt', _read_raw_cnt),
('curry', 'BrainVision', 'test_bdf_stim_channel Curry 8.cdt', _read_raw_curry), # noqa
('Persyst', 'EDF', 'sub-pt1_ses-02_task-monitor_acq-ecog_run-01_clip2.lay', _read_raw_persyst), # noqa
('NihonKohden', 'EDF', 'MB0400FU.EEG', _read_raw_nihon),
('CNT', 'EDF', 'scan41_short.cnt', _read_raw_cnt)
('CNT', 'EDF', 'scan41_short.cnt', _read_raw_cnt),
('curry', 'EDF', 'test_bdf_stim_channel Curry 8.cdt', _read_raw_curry)
]

data_path = testing.data_path(download=False)
Expand Down Expand Up @@ -1239,6 +1243,11 @@ def test_eegieeg(dir_name, fname, reader, _bids_validate, tmp_path):
kwargs = dict(raw=raw, bids_path=bids_path, overwrite=True)
if dir_name == 'EDF':
bids_output_path = write_raw_bids(**kwargs)
elif dir_name == 'curry':
with pytest.warns(RuntimeWarning,
match='Encountered data in "int" format. '
'Converting to float32.'):
bids_output_path = write_raw_bids(**kwargs)
elif dir_name == 'NihonKohden':
with pytest.warns(RuntimeWarning,
match='Encountered data in "short" format'):
Expand Down Expand Up @@ -1297,6 +1306,11 @@ def test_eegieeg(dir_name, fname, reader, _bids_validate, tmp_path):
kwargs = dict(raw=raw, bids_path=bids_path, overwrite=True)
if dir_name == 'EDF':
write_raw_bids(**kwargs)
elif dir_name == 'curry':
with pytest.warns(RuntimeWarning,
match='Encountered data in "int" format. '
'Converting to float32.'):
write_raw_bids(**kwargs)
elif dir_name == 'NihonKohden':
with pytest.warns(RuntimeWarning,
match='Encountered data in "short" format'):
Expand Down Expand Up @@ -1336,6 +1350,11 @@ def test_eegieeg(dir_name, fname, reader, _bids_validate, tmp_path):
kwargs = dict(raw=raw, bids_path=bids_path, overwrite=True)
if dir_name == 'EDF':
write_raw_bids(**kwargs)
elif dir_name == 'curry':
with pytest.warns(RuntimeWarning,
match='Encountered data in "int" format. '
'Converting to float32.'):
write_raw_bids(**kwargs)
elif dir_name == 'NihonKohden':
with pytest.warns(RuntimeWarning,
match='Encountered data in "short" format'):
Expand Down Expand Up @@ -1412,6 +1431,11 @@ def test_eegieeg(dir_name, fname, reader, _bids_validate, tmp_path):
kwargs = dict(raw=raw, bids_path=bids_path, overwrite=True)
if dir_name == 'EDF':
write_raw_bids(**kwargs)
elif dir_name == 'curry':
with pytest.warns(RuntimeWarning,
match='Encountered data in "int" format. '
'Converting to float32.'):
write_raw_bids(**kwargs)
elif dir_name == 'NihonKohden':
with pytest.warns(RuntimeWarning,
match='Encountered data in "short" format'):
Expand Down Expand Up @@ -1473,6 +1497,11 @@ def test_eegieeg(dir_name, fname, reader, _bids_validate, tmp_path):
match = r"^EDF\/EDF\+\/BDF files contain two fields .*"
with pytest.warns(RuntimeWarning, match=match):
write_raw_bids(**kwargs)
elif dir_name == 'curry':
with pytest.warns(RuntimeWarning,
match='Encountered data in "int" format. '
'Converting to float32.'):
write_raw_bids(**kwargs)
elif dir_name == 'Persyst':
with pytest.warns(RuntimeWarning,
match='Encountered data in "double" format'):
Expand Down Expand Up @@ -1520,6 +1549,11 @@ def test_eegieeg(dir_name, fname, reader, _bids_validate, tmp_path):
kwargs = dict(raw=ieeg_raw, bids_path=bids_path, overwrite=True)
if dir_name == 'EDF':
write_raw_bids(**kwargs)
elif dir_name == 'curry':
with pytest.warns(RuntimeWarning,
match='Encountered data in "int" format. '
'Converting to float32.'):
write_raw_bids(**kwargs)
elif dir_name == 'NihonKohden':
with pytest.warns(RuntimeWarning,
match='Encountered data in "short" format'):
Expand Down Expand Up @@ -1572,6 +1606,11 @@ def test_eegieeg(dir_name, fname, reader, _bids_validate, tmp_path):
kwargs = dict(raw=ieeg_raw, bids_path=bids_path, overwrite=True)
if dir_name == 'EDF':
write_raw_bids(**kwargs)
elif dir_name == 'curry':
with pytest.warns(RuntimeWarning,
match='Encountered data in "int" format. '
'Converting to float32.'):
write_raw_bids(**kwargs)
elif dir_name == 'NihonKohden':
with pytest.warns(RuntimeWarning,
match='Encountered data in "short" format'):
Expand Down Expand Up @@ -1635,6 +1674,11 @@ def test_eegieeg(dir_name, fname, reader, _bids_validate, tmp_path):
kwargs.update(montage=ecog_montage, acpc_aligned=True)
if dir_name == 'EDF':
write_raw_bids(**kwargs)
elif dir_name == 'curry':
with pytest.warns(RuntimeWarning,
match='Encountered data in "int" format. '
'Converting to float32.'):
write_raw_bids(**kwargs)
elif dir_name == 'NihonKohden':
with pytest.warns(RuntimeWarning,
match='Encountered data in "short" format'):
Expand Down Expand Up @@ -1726,6 +1770,12 @@ def test_eegieeg(dir_name, fname, reader, _bids_validate, tmp_path):
output_path = _test_anonymize(
tmp_path / 'd', raw, bids_path
)
elif dir_name == 'curry':
with pytest.warns(RuntimeWarning,
match='Encountered data in "int" format. '
'Converting to float32.'):
write_raw_bids(**kwargs)
output_path = _test_anonymize(tmp_path / 'd', raw, bids_path)
else:
with pytest.warns(RuntimeWarning,
match='Encountered data in "double" format'):
Expand Down Expand Up @@ -3091,6 +3141,11 @@ def test_convert_eeg_formats(dir_name, format, fname, reader, tmp_path):
match='Encountered data in "int" format. '
'Converting to float32.'):
bids_output_path = write_raw_bids(**kwargs)
elif dir_name == 'curry':
with pytest.warns(RuntimeWarning,
match='Encountered data in "int" format. '
'Converting to float32.'):
bids_output_path = write_raw_bids(**kwargs)
else:
with pytest.warns(RuntimeWarning,
match='Encountered data in "double" format'):
Expand Down