Skip to content
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: Add "description" entity to BIDSPath #1057

Merged
merged 20 commits into from
Aug 29, 2022

Conversation

hoechenberger
Copy link
Member

@hoechenberger hoechenberger commented Aug 27, 2022

Fixes #1049
Fixes #449

It seems to be working already:

# %%
import mne
import mne_bids

sample_dir = mne.datasets.sample.data_path()
raw_path = sample_dir / 'MEG' / 'sample' / 'sample_audvis_raw.fif'
raw = mne.io.read_raw_fif(raw_path, preload=False)

bp = mne_bids.BIDSPath(
    subject='foo',
    task='bar',
    description='baz',
    suffix='meg',
    extension='.fif',
    datatype='meg',
    root='/tmp',
)
bp_written = mne_bids.write_raw_bids(
    raw=raw,
    bids_path=bp,
    overwrite=True
)
mne_bids.read_raw_bids(bp_written)

@sappelhoff It's unclear to me where exactly to inject the desc entity in the BIDS path. For now, I'm putting it at the very end, before split and suffix. I couldn't find anything in the BIDS spec to help here.

Screen Shot 2022-08-27 at 10 25 14

@agramfort Please feel free to test and also to finalize ;)

Merge checklist

Maintainer, please confirm the following before merging.
If applicable:

  • All comments are resolved
  • This is not your own PR
  • All CIs are happy
  • PR title starts with [MRG]
  • whats_new.rst is updated
  • New contributors have been added to CITATION.cff
  • PR description includes phrase "closes <#issue-number>"

mne_bids/path.py Outdated Show resolved Hide resolved
('recording', self.recording),
('split', self.split)
])
return {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dict insertion order is preserved in Python 3.7+, so no need to have an OrderedDict anymore

@hoechenberger
Copy link
Member Author

Needs to be added to get_entities_from_fname() (???) too

mne_bids/path.py Outdated Show resolved Hide resolved
@agramfort
Copy link
Member

agramfort commented Aug 27, 2022 via email

@hoechenberger
Copy link
Member Author

Yep absolutely, I just wasn't sure about the exact name of that function :)

Co-authored-by: Alexandre Gramfort <[email protected]>
@hoechenberger
Copy link
Member Author

Doc build is broken due to recent changes upstream in MNE.

@agramfort
Copy link
Member

@alexrockhill can you have a look the doc build issue? It’s related to seeg example 🙏

@sappelhoff
Copy link
Member

@sappelhoff It's unclear to me where exactly to inject the desc entity in the BIDS path. For now, I'm putting it at the very end, before split and suffix. I couldn't find anything in the BIDS spec to help here.

see: https://github.com/bids-standard/bids-specification/blob/b3afa2ada5faaebeef9c48e6074a6fa5174289a3/src/schema/rules/entities.yaml#L1-L31

@hoechenberger
Copy link
Member Author

Wow, how did you even find that 😅 but perfect

@hoechenberger
Copy link
Member Author

Actually no it's not good. Why is split not last? Having it not be last doesn't make any sense to me.

mne_bids/path.py Outdated Show resolved Hide resolved
mne_bids/path.py Outdated Show resolved Hide resolved
mne_bids/path.py Outdated Show resolved Hide resolved
@hoechenberger
Copy link
Member Author

Failing tests all seem to be due to new set_montage() behavior upstream.

@hoechenberger hoechenberger marked this pull request as ready for review August 28, 2022 11:30
@hoechenberger hoechenberger reopened this Aug 29, 2022
@hoechenberger hoechenberger enabled auto-merge (squash) August 29, 2022 15:25
@hoechenberger hoechenberger disabled auto-merge August 29, 2022 15:25
@hoechenberger hoechenberger changed the title Add "description" entity to BIDSPath MRG: Add "description" entity to BIDSPath Aug 29, 2022
@codecov
Copy link

codecov bot commented Aug 29, 2022

Codecov Report

Merging #1057 (fdeb5ef) into main (7eb37ef) will increase coverage by 1.21%.
The diff coverage is 90.90%.

@@            Coverage Diff             @@
##             main    #1057      +/-   ##
==========================================
+ Coverage   93.95%   95.17%   +1.21%     
==========================================
  Files          25       25              
  Lines        3822     3831       +9     
==========================================
+ Hits         3591     3646      +55     
+ Misses        231      185      -46     
Impacted Files Coverage Δ
mne_bids/config.py 97.61% <ø> (ø)
mne_bids/path.py 97.56% <90.90%> (-0.11%) ⬇️
mne_bids/utils.py 95.74% <0.00%> (+0.53%) ⬆️
mne_bids/write.py 97.06% <0.00%> (+1.82%) ⬆️
mne_bids/dig.py 98.27% <0.00%> (+9.65%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

'space': self.space,
'recording': self.recording,
'split': self.split,
'description': self.description,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a loose thought...

Is it worth differentiating "raw" entities and "derivative" entities? E.g. via a parameter passed to entities?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about this too at least for writing, but I'd say we can always add this later on... for now we had a specific use case where @agramfort couldnt read some OpenNeuro data with MNE-BIDS, and this PR fixes this :)

@alexrockhill
Copy link
Contributor

@alexrockhill can you have a look the doc build issue? It’s related to seeg example pray

Looks like it's passing now, happy to review though.

@agramfort
Copy link
Member

@sappelhoff merge if happy

🙏 @hoechenberger

Copy link
Member

@sappelhoff sappelhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Richard!

@sappelhoff sappelhoff merged commit c5c6ab9 into mne-tools:main Aug 29, 2022
@hoechenberger hoechenberger deleted the hoechenberger/issue1049 branch August 29, 2022 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "description" entity to BIDSPath Adding desc keyword to BIDSPath and get_entities_from_fname?
5 participants