-
Notifications
You must be signed in to change notification settings - Fork 92
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: Enforce specification of all annotation descriptions in event_id if event_id is passed to write_raw_bids() #1086
MRG: Enforce specification of all annotation descriptions in event_id if event_id is passed to write_raw_bids() #1086
Conversation
New logic:
|
Codecov Report
@@ Coverage Diff @@
## main #1086 +/- ##
==========================================
- Coverage 95.20% 94.87% -0.34%
==========================================
Files 24 24
Lines 3859 3860 +1
==========================================
- Hits 3674 3662 -12
- Misses 185 198 +13
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
If we want to go a different route and allow for incomplete |
MWE: # %%
import pandas as pd
import mne
import mne_bids
sample_dir = mne.datasets.sample.data_path()
sample_fname = sample_dir / 'MEG' / 'sample' / 'sample_audvis_raw.fif'
raw = mne.io.read_raw_fif(sample_fname)
raw_concat = mne.concatenate_raws([raw.copy(), raw])
events = mne.find_events(raw_concat)
event_id = {
'Auditory/Left': 1,
'Auditory/Right': 2,
'Visual/Left': 3,
'Visual/Right': 4,
'Smiley': 5,
'Button': 32,
'BAD boundary': 9999,
'EDGE boundary': 10000,
}
# %%
bp = mne_bids.BIDSPath(
subject='sample',
task='sample',
suffix='meg',
extension='.fif',
datatype='meg',
root='/tmp/bids-root'
)
mne_bids.write_raw_bids(
raw_concat,
bids_path=bp,
events=events,
event_id=event_id,
overwrite=True,
allow_preload=True,
format='FIF'
)
# %%
events_tsv_path = (
bp
.copy()
.update(suffix='events', extension='.tsv')
)
events_tsv = pd.read_csv(events_tsv_path, sep='\t')
print(events_tsv['trial_type'].unique()) produces:
|
I know this is complex stuff, but @sappelhoff if you have 20 min to review, it would be great :) because it's actually an annoying bug that ideally should get fixed soon |
I'll try to do it soon! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I like the new behavior! Thanks @hoechenberger!
I added a versioning section and patch release section to the release wiki: https://github.com/mne-tools/mne-bids/wiki/How-to-make-a-release and I'll look into filling up some more information there and making a patch release soon @hoechenberger |
… if event_id is passed to write_raw_bids() (mne-tools#1086) * Write all annotations even if event_id was passed * Implement new logic * Update changelog * Fix tests * Style
* avoid creating many Annotations objects in for loop (#1079) * ENH: Better error message (#1080) * ENH: Better error message * FIX: Beautiful infrastructure * FIX: Spacing * ENH: Improve error message (#1081) * ENH: Improve error message * FIX: Use working openneuro-py * FIX: Install * FIX: Name * ENH: Make suggestion (#1087) * MRG: Enforce specification of all annotation descriptions in event_id if event_id is passed to write_raw_bids() (#1086) * Write all annotations even if event_id was passed * Implement new logic * Update changelog * Fix tests * Style * REL: v0.11.1 Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Eric Larson <larson.eric.d@gmail.com> Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com>
Fixes #1084
Merge checklist
Maintainer, please confirm the following before merging.
If applicable: