-
Notifications
You must be signed in to change notification settings - Fork 98
[MRG] Add motion to BIDSPath #1430
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
Conversation
…nd duration columns
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
|
The CI's fail for two example scripts anonymize_dataset.py and bidspath.py (Error here). If I run the same scripts locally, I cannot recreate the same error. @sappelhoff, maybe you have an idea how to solve this? |
|
@JuliusWelzel If I checkout your branch locally, I do get the same error that the CI's are hitting: RuntimeError: Found more than one matching data file for the requested recording. While searching:
BIDSPath(
root: /Users/scotterik/devel/repos/mne-bids/mne_bids/tests/data/tiny_bids
datatype: eeg
basename: sub-01_ses-eeg)
Found 5 paths:
/Users/scotterik/devel/repos/mne-bids/mne_bids/tests/data/tiny_bids/sub-01/ses-eeg/eeg/sub-01_ses-eeg_electrodes.tsv
/Users/scotterik/devel/repos/mne-bids/mne_bids/tests/data/tiny_bids/sub-01/ses-eeg/eeg/sub-01_ses-eeg_space-CapTrak_electrodes.tsv
/Users/scotterik/devel/repos/mne-bids/mne_bids/tests/data/tiny_bids/sub-01/ses-eeg/eeg/sub-01_ses-eeg_task-rest_channels.tsv
/Users/scotterik/devel/repos/mne-bids/mne_bids/tests/data/tiny_bids/sub-01/ses-eeg/eeg/sub-01_ses-eeg_task-rest_eeg.vhdr
/Users/scotterik/devel/repos/mne-bids/mne_bids/tests/data/tiny_bids/sub-01/ses-eeg/eeg/sub-01_ses-eeg_task-rest_events.tsvI think I see the problem. |
| allowed_extensions_motion = [ | ||
| ".tsv", # Tab-separated values | ||
| ] | ||
|
|
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.
This seems to be the line causing the issue, which makes sense because the EEG BIDS datasets have sidecar files that are just text files. So adding .tsv to the allowed datafile extensions seems to be confusing some of mne_bids internal functions..
Motion data might be the first modality with data that are stored in simple text files that we are trying to add into MNE-BIDS, which is why we are hitting this problem now. But I know that Eye-tracking BIDS will have the same issue.. So supporting these data might require more refactoring of the codebase.
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.
As a grumpy sidenote, I never understood why BIDS encourages storing some modalities of data in text files... !
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.
without having looked into it too deeply, that could be something that needs refactoring, yes.
drammock
left a comment
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.
couple minor comments. I haven't yet tried to debug the CI error
mne_bids/config.py
Outdated
| "description", | ||
| "suffix", | ||
| "extension", | ||
| "tracking-system", |
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.
this is hyphen-separated, but below in ALLOWED_PATH_ENTITIES_SHORT it's underscore_separated. Is that intentional?
| "physio", | ||
| "stim", # behavioral | ||
| "nirs", | ||
| "motion", # motion |
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.
redundant comment
| "motion", # motion | |
| "motion", |
|
|
the fix looks good to me |
…sponding change in 'ALLOWED_PATH_ENTITIES_SHORT'
… test_get_entities_from_fname_errors
for more information, see https://pre-commit.ci
…LLOWED_PATH_ENTITIES and ALLOWED_PATH_ENTITIES_SHORT
…and add it to valid entities
for more information, see https://pre-commit.ci
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1430 +/- ##
=======================================
Coverage 97.42% 97.43%
=======================================
Files 40 40
Lines 9136 9147 +11
=======================================
+ Hits 8901 8912 +11
Misses 235 235 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi, thanks for the help with fixing the tests. All CI's are passing now. One question from my side: |
Underscore seems ok to me. |
sappelhoff
left a comment
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.
@JuliusWelzel could you please also add a what's new entry and resolve the conflicts?
for more information, see https://pre-commit.ci
sappelhoff
left a comment
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.
Cool, LGTM! Thanks @JuliusWelzel.
If this is doing what you need for mne-bids to be helpful for motion data, then I think this can be merged as is.
|
Thanks @sappelhoff. The changes would now allow me to use mne-bids to handle the path to import numpy as np
from mne_bids import BIDSPath
# define motion-bids relevant information
subject_id = "01"
session = "01"
task = "walking"
tracking_system = "imu1"
# initialize BIDSPath for motion data
motion_raw_bids_path = BIDSPath(subject=subject_id, task=task, datatype='motion', tracking_system=tracking_system, root=bids_root)
print(motion_raw_bids_path)
motion_raw_bids_path.mkdir()
# generate random data for 9 markers and 10 seconds of data at 200Hz srate
raw_motion_data = np.random.rand(9, 10 * 200) # 9 channels, 10 seconds, 200 Hz
#store as tsv without headers
np.savetxt(str(motion_raw_bids_path), raw_motion_data, delimiter='\t', header='', comments='')
# update path for motion.json
motion_json_bids_path = motion_raw_bids_path.update(extension='.json')
print(motion_json_bids_path)
# update path for channels
motion_channels_bids_path = motion_raw_bids_path.update(suffix='channels', extension='.tsv')
print(motion_channels_bids_path)As long as MNE does not want/allow motion data the current approach is already helpful. However, I am open to extend the write_raw_bids function to allow motion data, but would need a little support. If you think this the current approach is to much of an edge case and not relevant to Brain Imaging Data, I am happy not to merge :) |
|
Thanks for the explanation @JuliusWelzel I am happy with how you aim to use mne-bids for motion data. And will merge this, thanks! Looking forward to future enhancements (to mne or mne-bids) for motion data compatibility. 🚀 |
* fixups from #1430 * fix wrong orig_unit sometimes written to channels.tsv * fix doctest (bad syntax; add verbose; avoid np types) * add curryreader to full and test deps * importorskip
PR Description
This PR adds motion as an allowed datatype for the BIDSPath with relevant changes in the config.py in a693a4e.
Closes #1145.
Merge checklist
Maintainer, please confirm the following before merging.
If applicable: