Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Errors reading LTAs, especially interpreting VOX2VOX type #125

Closed
oesteban opened this issue Jul 15, 2021 · 1 comment · Fixed by #129
Closed

BUG: Errors reading LTAs, especially interpreting VOX2VOX type #125

oesteban opened this issue Jul 15, 2021 · 1 comment · Fixed by #129
Assignees
Labels
bug Something isn't working
Milestone

Comments

@oesteban
Copy link
Collaborator

For instance, when reading:

# transform file /work/fmriprep_wf/single_subject_10316_wf/func_preproc_task_bart_wf/bold_reg_wf/bbreg_wf/bbregister/uni_xform_masked_bbreg_sub-10316.lta
# created by unknown on Wed Jul 14 10:10:37 2021

type      = 0 # LINEAR_VOX_TO_VOX
nxforms   = 1
mean      = 0.0000 0.0000 0.0000
sigma     = 10000.0000
1 4 4
2.999451637268066e+00 1.401854865252972e-02 -7.407368719577789e-02 3.591539764404297e+01 
-2.879538573324680e-02 -2.145972728729248e+00 -2.794905662536621e+00 2.451114654541016e+02 
-4.953517019748688e-02 2.096330165863037e+00 -2.860595941543579e+00 9.669815826416016e+01 
0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00 
src volume info
valid = 1  # volume info valid
filename = /work/fmriprep_wf/single_subject_10316_wf/func_preproc_task_bart_wf/bold_reg_wf/bbreg_wf/bbregister/uni_xform_masked.nii.gz
volume = 64 64 34
voxelsize = 3.000000000000000e+00 3.000000000000000e+00 4.000000000000000e+00
xras   = -1.000000000000000e+00 -0.000000000000000e+00 0.000000000000000e+00
yras   = 0.000000000000000e+00 6.858183145523071e-01 7.277727723121643e-01
zras   = -0.000000000000000e+00 -7.277727723121643e-01 6.858183741569519e-01
cras   = -4.697326660156250e+00 -9.175056457519531e+00 1.141981506347656e+01
dst volume info
valid = 1  # volume info valid
filename = /freesurfer/sub-10316/mri/orig.mgz
volume = 256 256 256
voxelsize = 1.000000000000000e+00 1.000000000000000e+00 1.000000000000000e+00
xras   = -1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
yras   = 0.000000000000000e+00 0.000000000000000e+00 -1.000000000000000e+00
zras   = 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
cras   = -1.008934020996094e+00 4.937973022460938e+00 1.715942382812500e+00
subject sub-10316
fscale 0.100000

nitransforms interprets:

array([[ 9.99817987e-01,  1.65117331e-02, -9.59846639e-03,
        -4.28724891e-01],
       [-1.33126352e-02,  8.69583683e-01,  1.09197014e-01,
        -1.15830952e+00],
       [ 8.16591683e-03,  1.87605373e-01,  1.17332468e+00,
         1.12279528e+01],
       [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
         1.00000000e+00]])

However, the same lta converted into RAS2RAS with freesurfer is:

type      = 1 # LINEAR_RAS_TO_RAS
nxforms   = 1
mean      = 0.0000 0.0000 0.0000
sigma     = 10000.0000
1 4 4
9.998270869255066e-01 -1.609659194946289e-02 9.315837174654007e-03 3.623275756835938e-01 
1.592489145696163e-02 9.997072815895081e-01 1.822045445442200e-02 -4.755706787109375e-01 
-9.606399573385715e-03 -1.806887984275818e-02 9.997907876968384e-01 -9.910827636718750e+00 
0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00 
src volume info
valid = 1  # volume info valid
filename = /work/fmriprep_wf/single_subject_10316_wf/func_preproc_task_bart_wf/bold_reg_wf/bbreg_wf/bbregister/uni_xform_masked.nii.gz
volume = 64 64 34
voxelsize = 3.000000000000000e+00 3.000000000000000e+00 4.000000000000000e+00
xras   = -1.000000000000000e+00 -0.000000000000000e+00 0.000000000000000e+00
yras   = 0.000000000000000e+00 6.858183145523071e-01 7.277727723121643e-01
zras   = -0.000000000000000e+00 -7.277727723121643e-01 6.858183741569519e-01
cras   = -4.697326660156250e+00 -9.175056457519531e+00 1.141981506347656e+01
dst volume info
valid = 1  # volume info valid
filename = /out/freesurfer/sub-10316/mri/orig.mgz
volume = 256 256 256
voxelsize = 1.000000000000000e+00 1.000000000000000e+00 1.000000000000000e+00
xras   = -1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
yras   = 0.000000000000000e+00 0.000000000000000e+00 -1.000000000000000e+00
zras   = 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
cras   = -1.008934020996094e+00 4.937973022460938e+00 1.715942382812500e+00
subject sub-10316
fscale 0.100000

which shows nitransforms' matrix is pretty far off.

Similarly, when reading the RAS2RAS lta immediately above, we get:

array([[ 9.99826998e-01,  1.59248919e-02, -9.60639406e-03,
        -4.49898796e-01],
       [-1.60965870e-02,  9.99707047e-01, -1.80689438e-02,
         3.02185409e-01],
       [ 9.31583934e-03,  1.82203793e-02,  9.99790400e-01,
         9.91404002e+00],
       [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
         1.00000000e+00]])

which seems off (I cannot say this for certain yet).

@oesteban
Copy link
Collaborator Author

Link #73 .

oesteban added a commit to nipreps/fmriprep that referenced this issue Jul 16, 2021
As reported by @eburkevt back in October 18, 2020, resampled BOLD time-series in standard spaces do not look good anymore.
This PR uses FreeSurfer to cater RAS2RAS transforms to *NiTransforms*.
This may resolved the problem for *fMRIPrep* regardless of the resolution of nipy/nitransforms#125

Addresses: #2307.
wq
oesteban added a commit that referenced this issue Jul 19, 2021
The structarray was used directly and the extra axis actually changed
the order of operations when the direction cosines were scaled by the
voxel sizes.

A new test case has been added for which this error was apparent.
This bug caused nipreps/fmriprep#2307, nipreps/fmriprep#2393, and
nipreps/fmriprep#2410.
nipreps/fmriprep#2444 just works around the problem by using
``lta_convert`` instead of *NiTransforms*.
The ``lta_convert`` tool can be now dropped.

Resolves: #125
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant