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

Make it work for "inconsistent runs" (using ds001971) #41

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions .circleci/config.yml
Expand Up @@ -100,6 +100,15 @@ jobs:
export MNE_BIDS_STUDY_CONFIG=config_matchingpennies
make sensor

- run:
name: test ds001971
command: |
export DATASET=ds001971
make fetch
export BIDS_ROOT=$DATA_DIR/ds001971
export MNE_BIDS_STUDY_CONFIG=config_ds001971
make sensor

- run:
name: test somato data
command: |
Expand Down
8 changes: 8 additions & 0 deletions 04-make_epochs.py
Expand Up @@ -10,8 +10,10 @@
To save space, the epoch data can be decimated.
"""

import numpy as np
import os.path as op
import itertools
import warnings

import mne
from mne.parallel import parallel_func
Expand Down Expand Up @@ -70,6 +72,12 @@ def run_epochs(subject, session=None):
raw = mne.concatenate_raws(raw_list)

events, event_id = mne.events_from_annotations(raw)

if len(np.unique(events[:, 0])) != len(events):
warnings.warn('Events are not unique. Uniqifying them')
_, idx = np.unique(events[:, 0], return_index=True)
events = events[idx]
sappelhoff marked this conversation as resolved.
Show resolved Hide resolved

if "eeg" in config.ch_types:
raw.set_eeg_reference(projection=True)

Expand Down
8 changes: 8 additions & 0 deletions 05a-run_ica.py
Expand Up @@ -11,6 +11,9 @@

import os.path as op
import itertools
import warnings

import numpy as np

import mne
from mne.report import Report
Expand Down Expand Up @@ -74,6 +77,11 @@ def run_ica(subject, session=None):

events, event_id = mne.events_from_annotations(raw)

if len(np.unique(events[:, 0])) != len(events):
warnings.warn('Events are not unique. Uniqifying them')
_, idx = np.unique(events[:, 0], return_index=True)
events = events[idx]

Copy link
Member

Choose a reason for hiding this comment

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

with mne-tools/mne-python#6688 being merged, we can outsource handling of non-unique events to MNE-Python and remove this code in the study template

if "eeg" in config.ch_types or config.kind == 'eeg':
raw.set_eeg_reference(projection=True)
del raw_list
Expand Down
1 change: 0 additions & 1 deletion config.py
Expand Up @@ -36,7 +36,6 @@
# If running the scripts from a notebook or spyder
# run %matplotlib qt in the command line to get the plots in extra windows

plot = True
plot = False

# ``crop``: tuple or None
Expand Down
16 changes: 6 additions & 10 deletions tests/configs/config_ds001971.py
Expand Up @@ -14,15 +14,11 @@

study_name = 'ds001971'
task = 'AudioCueWalkingStudy'
kind = 'eeg'
plot = False
reject = {'eeg': 150e-6}
conditions = ['left', 'right']
decoding_conditions = [('left', 'right')]
reject = {'eeg': 350e-6}
conditions = ['UncuedWalking', 'PreferredCadence', 'AdvanceTempo',
'DelayTempo']
decoding_conditions = [['AdvanceTempo', 'DelayTempo']]
use_ssp = False
use_ica = False


subjects_list = ['001']

runs = ['01']
subjects_list = ['001', '002']
runs = ['01', '02']
16 changes: 16 additions & 0 deletions tests/download_test_data.py
Expand Up @@ -52,6 +52,22 @@ def _provide_get_dict(dataset=None):
'sub-001/eeg/sub-001_task-AudioCueWalkingStudy_run-01_electrodes.tsv', # noqa: E501
'sub-001/eeg/sub-001_task-AudioCueWalkingStudy_run-01_coordsystem.json', # noqa: E501
'sub-001/eeg/sub-001_task-AudioCueWalkingStudy_run-01_channels.tsv', # noqa: E501

'sub-002/eeg/sub-002_task-AudioCueWalkingStudy_run-01_events.tsv', # noqa: E501
'sub-002/eeg/sub-002_task-AudioCueWalkingStudy_run-01_eeg.set', # noqa: E501
'sub-002/eeg/sub-002_task-AudioCueWalkingStudy_run-01_eeg.fdt', # noqa: E501
'sub-002/eeg/sub-002_task-AudioCueWalkingStudy_run-01_eeg.json', # noqa: E501
'sub-002/eeg/sub-002_task-AudioCueWalkingStudy_run-01_electrodes.tsv', # noqa: E501
'sub-002/eeg/sub-002_task-AudioCueWalkingStudy_run-01_coordsystem.json', # noqa: E501
'sub-002/eeg/sub-002_task-AudioCueWalkingStudy_run-01_channels.tsv', # noqa: E501

'sub-002/eeg/sub-002_task-AudioCueWalkingStudy_run-02_events.tsv', # noqa: E501
'sub-002/eeg/sub-002_task-AudioCueWalkingStudy_run-02_eeg.set', # noqa: E501
'sub-002/eeg/sub-002_task-AudioCueWalkingStudy_run-02_eeg.fdt', # noqa: E501
'sub-002/eeg/sub-002_task-AudioCueWalkingStudy_run-02_eeg.json', # noqa: E501
'sub-002/eeg/sub-002_task-AudioCueWalkingStudy_run-02_electrodes.tsv', # noqa: E501
'sub-002/eeg/sub-002_task-AudioCueWalkingStudy_run-02_coordsystem.json', # noqa: E501
'sub-002/eeg/sub-002_task-AudioCueWalkingStudy_run-02_channels.tsv', # noqa: E501 ],
],
}
if dataset is None:
Expand Down