sophie
(Sophie Herbst)
June 13, 2025, 12:34pm
1
Hello!
This question is specific to the mne-bids-pipeline.
I would like to add a column of parametric values to my metadata, for instance a value of confidence or surprise. I have events coded according to my conditions, and the automatically created metadata reflect those as expected.
Which would be the best way to now add my custom column, e.g. read from a pandas data frame? Should I just add it manually to the epochs metadata, or can the pipeline handle it?
I have the impression that this was discussed before, but I cannot find anything in the documentation or the forum.
Thanks in advance for any hints!
richard
(Richard Höchenberger)
June 14, 2025, 9:42am
2
Hello @Sophie , this was recently added and we should probably cut a new release:
main
← harrisonritz:custom_metadata
opened 08:06PM - 05 May 25 UTC
From https://github.com/mne-tools/mne-bids-pipeline/issues/1086
Allow for use… rs to pass custom metadata, which is added to epoch info.
1. Users convert a pandas `DataFrame` into a `Dict` (eg in the config file)
2. this `Dict` is converted back to a `DataFrame` at the point of epoch creation.
e.g. in the config:
```python
import pandas as pd
import numpy as np
metadata_path = "my_dataframe.csv"
metadata_df = pd.read_csv(metadata_path)
epochs_custom_metadata = metadata_df.replace({np.nan: None}).to_dict()
del metadata_path, metadata_df
```
While there are some upcoming methods for putting metadata into the `events.tsv`, this approach allows for analysis-specific metadata (e.g., if some metadata columns apply to specific epoch types)
### todo
- [x] write tests
### Before merging …
- [x] Changelog has been updated (`docs/source/dev.md.inc`)
I believe a release is currently blocked by:
opened 04:12PM - 11 Jun 25 UTC
I'm seeing this:
> E UserWarning: json-tricks: numpy scalar serialization i… s experimental and may work differently in future versions
which looks like https://json-tricks.readthedocs.io/en/latest/index.html?highlight=numpy%20scalar#numpy-scalars
_Originally posted by @drammock in https://github.com/mne-tools/mne-bids-pipeline/issues/1088#issuecomment-2963406924_
But if you’re willing to use the dev version, you should be able to supply custom metadata already.
cc @drammock @larsoner
Ciao,
Richard
2 Likes
sophie
(Sophie Herbst)
June 16, 2025, 7:53am
3
Great news @richard ! We will try with the dev version and keep checking for the new release.
Thank you!
system
(system)
Closed
June 23, 2025, 7:54am
4
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.