MRtrix3 / mrtrix3

MRtrix3 provides a set of tools to perform various advanced diffusion MRI analyses, including constrained spherical deconvolution (CSD), probabilistic tractography, track-density imaging, and apparent fibre density
http://www.mrtrix.org
Mozilla Public License 2.0
294 stars 180 forks source link

Inclination vs elevation #2630

Open Lestropie opened 1 year ago

Lestropie commented 1 year ago

I've been aware of this one for a while, but didn't realise that I had not listed it. Has come back to the front of my mind due to playing with particularly #2626.

Spherical coordinates can be defined using different conventions, in terms or presence or absence of elements / ordering of elements / symbols for elements / reference & range for quantities. In BIDS BEP016 I've stuck to ISO standard as much as possible. In MRtrix3 code, one frequently sees references in this context to "az_el", ie. azimuth-elevation pairs. However the cos / acos transformations indicate that the origin of the second spherical angle is the z-axis. This would make it an inclination rather than elevation angle: the former uses the angle from the zenith direction, the latter uses the angle from the reference plane.

fionaEyoung commented 1 year ago

Here's a summary of some of the different conventions I've dealt with across different tools over the years. Not particularly helpful for the tasks listed above, but it's good to know what users may or may not be assuming when mixing tools/packages...

Source XY plane Z axis Order
Scipy sph_harm 𝜽
"azimuth"
[0,2Ο€]
𝝓
"polar"
[0,Ο€]
[az, pol]
Dipy sphere2cart / cart2sphere 𝝓
"azimuth"
[-Ο€,Ο€]
𝜽
"incl/polar"
[0,Ο€]
[r, pol, az]
Descoteaux 2006 𝝓
[0,2Ο€]
𝜽
[0,Ο€]
matlab cart2sph "azimuth"
[-Ο€,Ο€]
"elevation"
[-Ο€/2, Ο€/2]
[az, el, r]
CSD matlab s2c "azimuth"
[-Ο€,Ο€]
"elevation"
[0,Ο€]
[el, az, r]
Lestropie commented 1 year ago

True; might we worth expanding the scope of the issue to cover the order of coefficients. The expected ranges should ideally not be of consequence since they should wash out in any relevant calculations; what matters most is the definition of where zero is. For inclination vs elevation as polar angle in particular, there should be a bunch of cos() / acos() vs. sin() / asin() calls in conversions to / from Cartesian.

The inhomogeneity certainly justifies my assertion of enforcing ISO in BEP016... πŸ˜„

fionaEyoung commented 1 year ago

The expected ranges should ideally not be of consequence since they should wash out in any relevant calculations

Indeed, and I was thinking that some functions may enforce the ranges through input checks, but for example even though the scipy sph_harm documentation says "must be in [0, 2*pi]", it looks like that isn't actually inforced and it accepts negative values just fine...