dbbs-lab / bsb-core

The Brain Scaffold Builder
https://bsb.readthedocs.io
GNU General Public License v3.0
22 stars 16 forks source link

The orientation of the x,y,z axes employed by BSB is not a left-handed orientation #672

Closed alessiomarta closed 1 year ago

alessiomarta commented 1 year ago

Currently if (a,b,c) is a vector representing the coordinates of a point in the 3D space the y coordinate is c and the z coordinate is b. This choice of the coordinate system does not follow the left hand rule (in which the y coordinate is b and the z coordinate is c) and can lead to problems when we compute a cross product between two vectors or when we need to rotate points. These operations are needed to generate a point cloud in the GeometricShape class, which are done following the left-hand rule. Using another convention introduces additional geometric operations.

Helveg commented 1 year ago

The BSB core makes this mistake by associating Y with "height"; luckily the data format takes (a, b, c) and stores it as (a, b, c), any internal labels will also always take X to be column index 0, Y column index 1, and Z column index 2. Most notable however is the swap in the bsb.plotting module, where Y is plotted as UP DOWN in 3D plots.

To fix this we have to:

drodarie commented 1 year ago

It is a shame that this class is using the left-handed axis base because all the 3D datasets coming from Blue Brain Project and the Allen Institute are right hand oriented. For these datasets also the Y axis is the "height" pointing down, the X axis is the rostral-caudal axis and Z being the left-right axis: http://help.brain-map.org/display/mousebrain/API#API-DownloadAtlas3-DReferenceModels

Furthermore, we should take the opportunity of this discussion to decide on a default direction vector for the entities in BSB in order to make sense of the rotation obtained. I would suggest that entities are pointing upward by default.

Helveg commented 1 year ago

@alessiomarta or @drodarie does either one of you have the time to help me fish out all locations in the BSB where this is an issue?