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

[ENH, MRG] Allow template coordinate frame writing #980

Merged
merged 6 commits into from
Mar 8, 2022

Conversation

alexrockhill
Copy link
Contributor

@alexrockhill alexrockhill commented Mar 7, 2022

Fixes last part from #973

Merge checklist

Maintainer, please confirm the following before merging:

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

@alexrockhill
Copy link
Contributor Author

@adam2392 these should all come back green, I think this would be nice to have in the release tomorrow but they should be reviewed. Do you have some time today to do a bit more thorough review. I've tested and it should be good but ideally it wouldn't break anything on the stable version!

@codecov
Copy link

codecov bot commented Mar 7, 2022

Codecov Report

Merging #980 (c29942d) into main (7343e20) will increase coverage by 0.27%.
The diff coverage is 98.43%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #980      +/-   ##
==========================================
+ Coverage   94.72%   94.99%   +0.27%     
==========================================
  Files          25       25              
  Lines        3698     3678      -20     
==========================================
- Hits         3503     3494       -9     
+ Misses        195      184      -11     
Impacted Files Coverage Δ
mne_bids/write.py 96.75% <88.88%> (-0.08%) ⬇️
mne_bids/config.py 97.59% <100.00%> (+0.02%) ⬆️
mne_bids/dig.py 97.58% <100.00%> (+4.78%) ⬆️
mne_bids/utils.py 96.09% <100.00%> (-0.02%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 33cbe67...c29942d. Read the comment docs.

doc/whats_new.rst Outdated Show resolved Hide resolved
examples/convert_ieeg_to_bids.py Outdated Show resolved Hide resolved
examples/convert_ieeg_to_bids.py Outdated Show resolved Hide resolved
@@ -289,7 +285,7 @@
MNE_FRAME_TO_STR = {val: key for key, val in MNE_STR_TO_FRAME.items()}

# see BIDS specification for description we copied over from each
BIDS_COORD_FRAME_DESCRIPTIONS = {
BIDS_COORD_FRAME_DESCRIPTIONS = dict(**{
Copy link
Member

Choose a reason for hiding this comment

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

uh there's gotta be a better way to do this. In the worst case, simply first create a dict and then append to it / update it, please.

Comment on lines +391 to +394
with warnings.catch_warnings():
warnings.filterwarnings(action='ignore', category=RuntimeWarning,
message='.*nasion not found', module='mne')
raw.set_montage(montage)
Copy link
Member

Choose a reason for hiding this comment

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

Have you considered setting the verbosity level of set_montage() to 'error'? (I didn't take a look at this method, not sure if it even supports verbosity!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There could be other warnings though... wouldn't want to miss those

mne_bids/dig.py Outdated Show resolved Hide resolved
with warnings.catch_warnings():
warnings.filterwarnings(action='ignore', category=RuntimeWarning,
message='.*nasion not found', module='mne')
raw.set_montage(montage, on_missing='warn')
Copy link
Member

Choose a reason for hiding this comment

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

see above: can you maybe change the verbosity level?

mne_bids/tests/test_dig.py Show resolved Hide resolved
mne_bids/tests/test_dig.py Outdated Show resolved Hide resolved
with pytest.warns(RuntimeWarning, match="Skipping EEG electrodes.tsv"):
with pytest.raises(RuntimeError, match="'head' coordinate frame "
Copy link
Member

Choose a reason for hiding this comment

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

Wait, what? So this is a breaking behavior change? If yes, we might need a deprecation cycle for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think there is anything to cycle, it's raising an error where before there was a warning. I think this is appropriate and needed; I really don't like when among all the things that are printed out you get a warning that the channels weren't written which is kind of a big deal if you think they are supposed to be. This is a pretty edge case anyway, when you have a montage in head with no fiducials.

@hoechenberger
Copy link
Member

@alexrockhill We can also postpone the release to Wednesday or so, so you have more time to get this here cleaned up & tested

@alexrockhill
Copy link
Contributor Author

@alexrockhill We can also postpone the release to Wednesday or so, so you have more time to get this here cleaned up & tested

Okay, trying to respond to all comments and test right away not to hold things up

@alexrockhill
Copy link
Contributor Author

There was one part of the coverage I wasn't able to get to: when orient == 'n/a' which is when MEG isn't in one of the recognized formats. According to BIDS, you should be able to write MEG in any of the EEG formats, edf for instance, but we don't currently allow that. The behavior would be that it would write with the given BIDSPath.space coordinate frame if one was provided, if not the behavior wouldn't change.

@alexrockhill
Copy link
Contributor Author

Ah that was an annoying bug, I modified the raw when passing it to write_raw_bids, this should be good to go now. Sorry this is a bit later in the day East Coast.

@alexrockhill
Copy link
Contributor Author

Ok to merge @hoechenberger and @adam2392 ?

Copy link
Member

@agramfort agramfort left a comment

Choose a reason for hiding this comment

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

looks good https://6077-89170358-gh.circle-artifacts.com/0/dev/auto_examples/convert_ieeg_to_bids.html#step-6-store-coordinates-in-another-template-space-accepted-by-bids

but I realize we don't support pyvista and 3D plots in the doc of mne-bids... to be done later I guess

@hoechenberger hoechenberger merged commit 5798e49 into mne-tools:main Mar 8, 2022
@hoechenberger
Copy link
Member

Thanks, @alexrockhill!

@alexrockhill
Copy link
Contributor Author

looks good https://6077-89170358-gh.circle-artifacts.com/0/dev/auto_examples/convert_ieeg_to_bids.html#step-6-store-coordinates-in-another-template-space-accepted-by-bids

but I realize we don't support pyvista and 3D plots in the doc of mne-bids... to be done later I guess

Those are block quotes, not actual executed code since we don't have that template in the sample data. I wouldn't doubt that the 3D scraper is also not implemented but they shouldn't render.

@agramfort
Copy link
Member

agramfort commented Mar 8, 2022 via email

@alexrockhill
Copy link
Contributor Author

Sure, actually while I was writing my response, I thought that fsaverage is actually a template that we do have so we could use that and make it executable. It would also be a lot longer because you'd have to convert the coordinates to voxel and scanner RAS. I'll make a PR and we can see if it looks reasonable.

@alexrockhill alexrockhill deleted the ieeg branch March 8, 2022 13:28
@alexrockhill
Copy link
Contributor Author

There were a few issues with this PR but I'm almost done fixing and rewriting the example (I think the mne.viz.Brain would be nice but isn't needed). I will make another PR ASAP.

@alexrockhill alexrockhill mentioned this pull request Mar 8, 2022
6 tasks
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.

None yet

3 participants