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

Find Breaks Workflow Requires Annotation Structure in Raw #99

Open
Andesha opened this issue Apr 18, 2023 · 1 comment
Open

Find Breaks Workflow Requires Annotation Structure in Raw #99

Andesha opened this issue Apr 18, 2023 · 1 comment
Milestone

Comments

@Andesha
Copy link
Contributor

Andesha commented Apr 18, 2023

When passing find_breaks to the pipeline like the following:

config['find_breaks'] = {}
config['find_breaks']['min_break_duration'] = 10
config['find_breaks']['t_start_after_previous'] = 3
config['find_breaks']['t_stop_before_next'] = 0
config['find_breaks']['ignore'] = ['boundary', 'e-255']

The pipeline crashes if there is not an annotation structure already created in the data. Error here:

  File "/scratch/tk11br/TRI-pipeline/env/lib/python3.10/site-packages/mne/preprocessing/artifact_detection.py", line 471, in annotate_break
    raise ValueError('Could not find (or generate) any annotations in '
ValueError: Could not find (or generate) any annotations in your data.

I fixed this personally by doing this:

annos = mne.annotations_from_events(events=mne.find_events(raw, initial_event=True),
                                    sfreq=raw.info['sfreq'],
                                    orig_time=raw.info['meas_date'])
raw.set_annotations(annos)

Likely needs to be fixed before the initial release.

@scott-huberty
Copy link
Member

I see.

You should also be able to pass config['find_breaks'] = False to skip this step.

I made the find_breaks behavior True by default because when I used MATLAB Lossless, finding breaks was not done by default, and this is something I always needed to do (but often forgot) which resulted in having to re-run the pipeline.

The default for annotate_break is to look for annotations, alternatively, you can pass in an event array (or set your annotations from your stim channel as you did).

But I agree that we might want to handle a situation like yours more gracefully.

@scott-huberty scott-huberty added this to the 0.02 milestone May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants