-
Notifications
You must be signed in to change notification settings - Fork 85
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
read_raw_bids does not use value column from events file #223
Comments
Thanks for reporting! I assume you are using mne_bids with version First of all: I agree with you, in your case That said, Instead of returning However, this If you want It'll look a bit like this: import mne
from mne_bids import read_raw_bids
raw = read_raw_bids('./my_bids_fname', './my_bids_root')
events, event_id = mne.events_from_annotations(raw)
# note, events_id is NOT as in events.tsv
# rather, event_id will be consecutive numbers, see the docstring of events_from_annotations ... no where does that leave us with MNE-BIDS being capable to transfer your values from the Some options:
import mne
from mne_bids import read_raw_bids
raw, events_id = read_raw_bids('./my_bids_fname', './my_bids_root')
# events_id is according to events.tsv!
events, _ = mne.events_from_annotations(raw)
# use the _ ... because otherwise we would get an events_id that we already have What are your opinions? Are there more options that I did not mention? |
I thought |
no, you are right ... but there is a different column in MNE will give each description (key in |
Hmm, I'm not sure I follow the bit about annotations - does that mean when writing the BIDS data event files will be written directly in the raw data? If not, we would still need separate event files and load them when reading in the raw data, attaching them as annotations as new MNE would expect, no? I used the development version actually, because |
no, but I agree this is confusing. The confusion arises from the fact that |
I would expect that read_raw_bids gives me everything I need to build
epochs.
As events in bids can have durations AFAIK they should be stored as
annotations.
I also don't expect users to know that events.tsv was read when doing
read_raw_bids
as this should just work.
my 2c
… |
what's the consensus here? Do we still have an issue? |
it works on my side
|
@hstojic do you agree? Closing issue, feel free to reopen if you disagree |
Suppose I have my own coding scheme for triggers, put them in value column, and rely on them, not event names - in the scripts then if you use event values programmatically when loading various tasks that have some overlap in triggers, you would get errors or worse, accidentally it would find those values but it wouldn't be what you think it is. Probably it's not going to be many such cases, but to be on the safe side ti does't hurt to use the value column numbers - there is no downside to it, right? Defensive programming |
I agree @hstojic. When reading a BIDS |
I just ran into this issue while playing with the new # %%
from pathlib import Path
import numpy as np
import mne
import mne_bids
sample_dir = Path(mne.datasets.sample.data_path())
sample_fname = sample_dir / 'MEG' / 'sample' / 'sample_audvis_raw.fif'
raw = mne.io.read_raw_fif(sample_fname)
events = mne.find_events(raw, stim_channel='STI 014')
event_id = {'visual/left': 3, 'visual/right': 4, 'face': 5, 'buttonpress': 32}
# Drop unused events
events = events[np.in1d(events[:, -1], list(event_id.values()))]
bp = mne_bids.BIDSPath(
subject='foo', task='av', suffix='meg', extension='.fif', datatype='meg',
root=Path('/tmp/bids-root')
)
mne_bids.write_raw_bids(
raw=raw,
bids_path=bp,
events_data=events,
event_id=event_id,
overwrite=True
)
raw_read = mne_bids.read_raw_bids(bids_path=bp)
events_read, event_id_read = mne.events_from_annotations(raw=raw_read)
# %%
print('Original event_id:\n', event_id)
print('Round-tripped event_id:\n', event_id_read) Produces:
I'm afraid the only way to fix this is to allow |
Or we add this to
(both as And it does the right thing? |
Previously, anonymization would cause a new assignment of trigger codes, which could lead to confusion and inconsistencies across participants – or even within participants across runs. We now simply overwrite the trigger codes in the anonymized *_events.tsv files with the original codes. This problem is directly related to mne-tools#223, and the solution implemented here is merely a workaround (which is good enough for now)
Previously, anonymization would cause a new assignment of trigger codes, which could lead to confusion and inconsistencies across participants – or even within participants across runs. We now simply overwrite the trigger codes in the anonymized *_events.tsv files with the original codes. This problem is directly related to #223, and the solution implemented here is merely a workaround (which is good enough for now)
read_raw_bids
seems to define its own values for events.For example, in the event file I have a value column with events specified as 1,2 and 4 with trial_type defining the names, but then when data is read in they are redefined as 1,2,3 in alphabetical order.
If the (optional) value column is present the reader should use those values instead of imposing generic ones.
The text was updated successfully, but these errors were encountered: