feat: port lps2sph/sph2lps coordinate transforms from MATLAB#476
Open
AmitSubhash wants to merge 1 commit into
Open
feat: port lps2sph/sph2lps coordinate transforms from MATLAB#476AmitSubhash wants to merge 1 commit into
AmitSubhash wants to merge 1 commit into
Conversation
Port fus.seg.lps2sph and fus.seg.sph2lps from the legacy MATLAB toolbox (opw_neuromod_sw) into openlifu.geo.transforms, with scalar and vectorized variants matching the existing cartesian/spherical converters. Faithfully preserves the MATLAB convention (degrees, azimuth+90 offset, elevation angle). Adds golden-value, round-trip, edge-case (r=0), and vectorized-consistency tests to test_geo.py. Refs OpenwaterHealth#463
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #463
Ports fus.seg.lps2sph and sph2lps from openwater-neuromod-software into
openlifu.geo.transforms, right next to the existing cartesian/spherical
converters. Scalar versions plus vectorized ones for arrays.
The main thing here was matching the MATLAB convention exactly: angles in
degrees, the +90 azimuth offset (0 is the anterior/nose line, increasing
toward patient-left), and phi as an elevation angle rather than the polar
angle off z. Return order follows the MATLAB ([th, phi, r] and [l, p, s]).
These are deterministic transforms with no captured fixtures, so I tested
them analytically like you suggested in the issue:
45 degree case, a 3-4-5 case)
I also checked the outputs against Octave's cart2sph/sph2cart to be sure the
convention lines up. pytest passes locally.
Happy to move the functions if you'd rather they live somewhere else.