aces / brainbrowser

Web-based visualization tools for neurological data.
https://brainbrowser.cbrain.mcgill.ca/
GNU Affero General Public License v3.0
353 stars 124 forks source link

Possible issue with coordinate conversion #25

Closed pinelopakik closed 10 years ago

pinelopakik commented 10 years ago

Louis noticed (and Cecile and I confirmed) that when going through world coordinates in one axis each step is equal for both voxel and world coordinates. Based on the conversion from voxel to world this is probably not expected behaviour. There is a voxel to world minc tool and some explanation of world coordinates in the following url: http://www.bic.mni.mcgill.ca/software/minc/minc2_format/node4.html

It might be worthwhile looking at a file that is in stereotaxic space to ensure that voxel coordinates are correct first. For example look at 0,0,0 location to ensure that this is correctly encoded.

tsherif commented 10 years ago

Are you sure about this? If you select the functional data in the Volume Viewer demo, you'll see that the steps aren't equal (they're about 2.1:1). For the structural data, it is 1:1, but that's just because that dataset has steps of 1.

@cmadjar care to comment?

pinelopakik commented 10 years ago

The voxel coordinates displayed are the actual coordinates of the Brain Browser pixels and not the voxels of the minc file.

To get the minc voxel coordinates you will need to take into account direction_cosines. See info at: http://en.wikibooks.org/wiki/MINC/Reference/MINC2.0_File_Format_Reference

tsherif commented 10 years ago

It looks like this requires two steps:

  1. The direction_cosines attribute should be extracted for each dimension from the minc headers in minc2volume-viewer.js.
  2. The cosines should be applied in the voxel coordinate conversion in getWorldCoordinates().
tsherif commented 10 years ago

@pinelopakik, I'm a little confused by the matrix multiplication shown in the MINC reference you posted a link to. It seems all the matrices are transposed for some reason. If this is the case, that's no problem, but can you verify this with Louis? As a concrete example, can you ask him if the following would be the correct way to calculate the world x coordinate: wx = vx * stepx * cxx + vy * stepx * cxy + vz * stepx * cxz + ox

tsherif commented 10 years ago

@pinelopakik, I created the following two matrices, based on the link you sent. Can you verify that they're correct? Also, I found another site giving a different matrix for the conversion. It seems to be older, but the matrix is actually written correctly. Can you make sure that the one we're using is correct?

EDIT: THE BELOW MATRICES ARE INCORRECT

minc-matrices

tsherif commented 10 years ago

The original link an above matrices are incorrect. The correct conversion can be found here: http://www.bic.mni.mcgill.ca/software/minc/minc2_format/node4.html