Additional metadata from BIDS events.tsv#744
Additional metadata from BIDS events.tsv#744bruAristimunha merged 14 commits intoNeuroTechX:developfrom
Conversation
|
Dreyer dataset would be an super use case here.
…On Wed, 2 Apr 2025, 19:15 Pierre Guetschel, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In moabb/paradigms/base.py
<#744 (comment)>:
> + dm = load_bids_event_metadata(
+ dataset, subject=subject, session=session, run=run
+ )
After discussion in the MOABB meeting, we think it would be useful in
other datasets to have the option to get additional metadata columns (ex:
ERPCore). So instead of having a special case for BaseBIDSDataset, the
idea would be to have a method in BaseDataset:
class BaseDataset:
def get_additional_metadata(self, subject, session, run) -> None | pd.DataFrame:
return None
that would be overwritten by the datasets that have additional metadata to
pass
—
Reply to this email directly, view it on GitHub
<#744 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKFZNAT6UY33KDDSCZB3SST2XQLJZAVCNFSM6AAAAAB2JHDKBGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDOMZXGAZDINJQGQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
|
Thanks @matthiasdold for starting this PR. There is one blocker with the current implementation: if we don't use all the events, the paradigm object will filter the epochs and the rows in the additional metadata will not match anymore the events used to create the epochs. |
I think the proper way would be to use the |
|
Also given the fails for the tests on |
@bruAristimunha - thanks for pointing this out. I will add this to my local testing and see if it would make sense to include a similar mockup for the unit testing |
You can use |
But then every new dataset implementing additional metadata columns would also have to implement the events filtering. This seems redundant and prone to bugs... |
As discussed this morning, we would have potential filtering of metadata on two levels: on the See this pull request. @PierreGtch - how shall we deal with this? Wait for the PR to be merge and fix here afterwards, or replicate the proposed _events_file_to_annotation_kwargs here? |
|
I think waiting to be merged is the best way. I would recommend going to mne office hour to make things easier, it's Friday on discord. |
|
Edit: after thinking about it, I now agree with @matthiasdold. The problem is not only that it will take time before the feature makes it into a release of mne-bids, it's also that it will force us to depend on the latest mne-bids version. |
|
Hey guys @matthiasdold and @PierreGtch, Should we upgrade mne version? |
|
Hi @bruAristimunha, I talked with @PierreGtch and he is optimistic that mne-tools/mne-python#13228 would soon be ready to merge. Once that is in |
Signed-off-by: Bru <b.aristimunha@gmail.com>
Replace manual CSV parsing and n/a filtering with the public events_file_to_annotation_kwargs() API (mne-bids >= 0.17) and BIDSPath.find_matching_sidecar() instead of private _find_matching_sidecar.
SetRawAnnotations.transform() recreates annotations via mne.annotations_from_events(), which produces empty extras and silently discards the per-annotation metadata that mne-bids populates from events.tsv columns. Fix by capturing original extras keyed by sample position before event extraction, then transferring them back to the new annotations by matching event sample positions.
Hi,
here is an idea how we could fetch additional metadata columns from
events.tsvfiles for BIDS datasets.E.g. for the
FakeDataset withthe
events.tsvfiles would have the following columns:While the
onsetand thetrial_typeare implicitly encoded in the epochs (by their names and how they are cut), the additional information, such asvalueorsamplewould not be part of the epoch/metadata as extracted with:This pull request adds a
additional_metadata: Literal["default", "all"] | list[str] = "default"kwarg to theparadigm.get_datamethod, which allows to either fetch all"all"or a selected list of columns from theevents.tsvand attach it to the metadata - also see theTestMetadata.