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: Make update_anat_landmarks() accept fiducials file #977

Merged
merged 11 commits into from Mar 7, 2022

Conversation

hoechenberger
Copy link
Member

@hoechenberger hoechenberger commented Mar 4, 2022

Fixes #968

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>"

@codecov
Copy link

codecov bot commented Mar 4, 2022

Codecov Report

Merging #977 (65c45a1) into main (b26f062) will decrease coverage by 0.01%.
The diff coverage is 95.00%.

❗ Current head 65c45a1 differs from pull request most recent head aaa3f45. Consider uploading reports for the commit aaa3f45 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #977      +/-   ##
==========================================
- Coverage   94.63%   94.62%   -0.02%     
==========================================
  Files          25       25              
  Lines        3600     3626      +26     
==========================================
+ Hits         3407     3431      +24     
- Misses        193      195       +2     
Impacted Files Coverage Δ
mne_bids/read.py 95.91% <0.00%> (-0.25%) ⬇️
mne_bids/sidecar_updates.py 98.09% <95.83%> (-0.72%) ⬇️
mne_bids/write.py 96.62% <100.00%> (+0.01%) ⬆️

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 a16a1c7...aaa3f45. Read the comment docs.

@hoechenberger hoechenberger marked this pull request as ready for review March 4, 2022 20:34
@hoechenberger
Copy link
Member Author

@agramfort Turns out we didn't have an issue with zooming … I just used sample fiducials on testing-data MRI 🤦

@hoechenberger hoechenberger changed the title Make update_anat_landmarks() accept fiducials file MRG: Make update_anat_landmarks() accept fiducials file Mar 4, 2022
mne_bids/sidecar_updates.py Outdated Show resolved Hide resolved
mne_bids/write.py Show resolved Hide resolved
mne_bids/read.py Outdated Show resolved Hide resolved
mne_bids/read.py Show resolved Hide resolved
mne_bids/read.py Outdated Show resolved Hide resolved
hoechenberger and others added 2 commits March 5, 2022 18:20
Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org>
@hoechenberger
Copy link
Member Author

@agramfort I've addressed all your comments, this should be good to merge once CI comes back green

@agramfort
Copy link
Member

ok to merge this as is as it already fixes a practical problem but it seems the code only works if the landmarks passed as DigMontage are already in mri voxels. This should not be needed. We allow the same thing as what we allow with write_anat

@hoechenberger if you want we can merge this and please create an issue for the next stuff to do

@hoechenberger
Copy link
Member Author

hoechenberger commented Mar 6, 2022

@agramfort

ok to merge this as is as it already fixes a practical problem but it seems the code only works if the landmarks passed as DigMontage are already in mri voxels. This should not be needed. We allow the same thing as what we allow with write_anat

Very interesting observation, I just looked at the docstring and implementation of write_anat(); it calls _get_landmarks(), which only works with coordinates in scanner RAS and voxel space (and raises an exception otherwise).

The docstring suggests to use get_anat_landmarks() to produce landmark coordinates in the required coordinate frame (the function returns coords in voxel space); scanner RAS is never mentioned anywhere in the write_anat() docstring.

So this is at least a documentation bug / shortcoming.

But it also means that update_anat_landmarks() should support scanner RAS coordinates as well, in addition to voxel (which is already supported in main) and mri (surface RAS; for which this PR adds support)

I will look into this.

@hoechenberger
Copy link
Member Author

@agramfort I've decided to document the inconsistency in #978 and will go ahead here and merge for now!

@hoechenberger hoechenberger merged commit 7343e20 into mne-tools:main Mar 7, 2022
@hoechenberger hoechenberger deleted the hoechenberger/issue968 branch March 7, 2022 09:19
@hoechenberger hoechenberger added this to the 0.10 milestone Mar 7, 2022
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.

Converting fiducials read via mne.io.read_fiducials() to BIDS anatomical landmarks
2 participants