neuroanatomy / BrainBox

BrainBox is a web application that lets you annotate and segment 3D brain imaging data in real time, collaboratively.
https://brainbox.pasteur.fr
Other
96 stars 46 forks source link

nifti orientation not being read correctly #133

Closed satra closed 7 years ago

satra commented 7 years ago

example:

http://brainbox.pasteur.fr/mri/?url=https://s3.amazonaws.com/fcp-indi/data/Projects/BrainGenomicsSuperstructProject/orig_bids/sub-1000/ses-01/anat/sub-1000_ses-01_T1w.nii.gz&view=sag&slice=96

r03ert0 commented 7 years ago

I'll try to see what makes that some files are read right and some wrong.

List of test files

Read right:

  1. https://s3.amazonaws.com/fcp-indi/data/Projects/ACPI/RawData/uci_1/0028031/session_1/anat_1/anat.nii.gz
  2. https://s3.amazonaws.com/fcp-indi/data/Projects/ACPI/RawData/uci_1/0028034/session_1/anat_1/anat.nii.gz
  3. https://s3.amazonaws.com/fcp-indi/data/Projects/ACPI/RawData/uci_1/0028035/session_1/anat_1/anat.nii.gz

Read wrong:

  1. https://s3.amazonaws.com/fcp-indi/data/Projects/BrainGenomicsSuperstructProject/orig_bids/sub-1000/ses-01/anat/sub-1000_ses-01_T1w.nii.gz
  2. https://s3.amazonaws.com/fcp-indi/data/Projects/ACPI/RawData/uci_1/0028147/session_1/anat_1/anat.nii.gz
  3. https://s3.amazonaws.com/fcp-indi/data/Projects/ACPI/RawData/uci_1/0028083/session_1/anat_1/anat.nii.gz
  4. https://s3.amazonaws.com/fcp-indi/data/Projects/ACPI/RawData/uci_1/0028084/session_1/anat_1/anat.nii.gz
  5. https://s3.amazonaws.com/fcp-indi/data/Projects/ACPI/RawData/uci_1/0028085/session_1/anat_1/anat.nii.gz

It seems that the error only happens with .nii files. I'll convert the wrongly read .nii files to mgz to check that the orientation matrix is the same.

r03ert0 commented 7 years ago

Transformation matrices:

Right 1. Q-Form Code = 1 S-Form Code = 1 Quaternion Parameters: b = -0.5 c = 0.5 d = -0.5 Quaternion Offsets: x = -97.1253 y = 168.71899 z = 134.5 S-Form Parameters X: 0.0, 0.0, 1.2, -97.1253 S-Form Parameters Y: -1.0, 0.0, 0.0, 168.71899 S-Form Parameters Z: 0.0, -1.0, 0.0, 134.5

2. Q-Form Code = 1 S-Form Code = 1 Quaternion Parameters: b = -0.5 c = 0.5 d = -0.5 Quaternion Offsets: x = -101.694 y = 161.256 z = 128.45599 S-Form Parameters X: 0.0, 0.0, 1.2, -101.694 S-Form Parameters Y: -1.0, 0.0, 0.0, 161.256 S-Form Parameters Z: 0.0, -1.0, 0.0, 128.45599

3. Q-Form Code = 1 S-Form Code = 1 Quaternion Parameters: b = -0.5 c = 0.5 d = -0.5 Quaternion Offsets: x = -99.9378 y = 160.75 z = 131.21899 S-Form Parameters X: 0.0, 0.0, 1.2, -99.9378 S-Form Parameters Y: -1.0, 0.0, 0.0, 160.75 S-Form Parameters Z: 0.0, -1.0, 0.0, 131.21899

Wrong: 4. Q-Form Code = 1 S-Form Code = 1 Quaternion Parameters: b = -0.509 c = 0.46986 d = -0.51714 Quaternion Offsets: x = 77.98633 y = 137.22293 z = 101.17432 S-Form Parameters X: 0.02828, 0.04988, -1.19862, 77.98633 S-Form Parameters Y: -1.19583, -0.06351, -0.03097, 137.22293 S-Form Parameters Z: 0.06472, -1.19519, -0.04838, 101.17432

5. Q-Form Code = 1 S-Form Code = 1 Quaternion Parameters: b = -0.00873 c = 0.99996 d = 0.0 Quaternion Offsets: x = 101.64774 y = -104.80825 z = -130.44547 S-Form Parameters X: -1.19982, -0.01745, 0.0, 101.64746 S-Form Parameters Y: -0.02094, 0.99985, 0.0, -104.80835 S-Form Parameters Z: 0.0, 0.0, 1.0, -130.44537

6. Q-Form Code = 1 S-Form Code = 1 Quaternion Parameters: b = -0.56027 c = 0.46574 d = -0.50575 Quaternion Offsets: x = -98.71835 y = 145.51309 z = 98.69789 S-Form Parameters X: 0.05461, -0.05462, 1.19642, -98.71835 S-Form Parameters Y: -0.98915, -0.13938, 0.05585, 145.51309 S-Form Parameters Z: 0.13642, -0.98873, -0.07396, 98.69789

  1. (misplaced by Mango) Q-Form Code = 1 S-Form Code = 1 Quaternion Parameters: b = -0.53913 c = 0.48078 d = -0.51892 Quaternion Offsets: x = -94.43201 y = 178.21742 z = 107.86959 S-Form Parameters X: -0.00086, -0.04403, 1.19884, -94.43201 S-Form Parameters Y: -0.99277, -0.11988, -0.00736, 178.21742 S-Form Parameters Z: 0.12003, -0.99181, -0.05233, 107.86959

  2. Q-Form Code = 1 S-Form Code = 1 Quaternion Parameters: b = -0.0294 c = 0.99159 d = -0.11966 Quaternion Offsets: x = 110.68605 y = -118.85867 z = -91.81419 S-Form Parameters X: -1.19418, -0.04886, -0.0854, 110.68604 S-Form Parameters Y: -0.08132, 0.96964, 0.23498, -118.85868 S-Form Parameters Z: -0.08559, -0.23963, 0.96824, -91.81419

Transformation errors:

  1. transformation volume: ok; transformation origin: ok
  2. transformation volume: ok; transformation origin: ok
  3. transformation volume: ok; transformation origin: ok
  4. transformation volume: fail; transformation origin: ok
  5. transformation volume: fail; transformation origin: ok
  6. transformation volume: fail; transformation origin: ok
  7. transformation volume: fail; transformation origin: ok
  8. transformation volume: fail; transformation origin: ok

Wrongly read nii files are failing the transformation volume check. I'll unplug that check to see if it's leading to unnecessary transformation resets.

r03ert0 commented 7 years ago

The mapping between volume coordinates and screen coordinates is now built directly, without passing through the world coordinates. Each column of the volume-to-world rotation matrix is read to determine to which screen coordinate maps each volume coordinate.