Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a23b704

Browse files
committedMar 20, 2020
ENH: Beef-up LTA tests with one equivalent to mri_concatenate_lta
This PR adds more LTA and corresponding ITK conversions. The ITK conversions have been calculated with ``lta_convert``. The original NIfTI files have also been added to this PR for the implementation of future tests. Files have been named with some sort of BIDS derived nomenclature. Some provenance has been recorded as initial comments of the LTA files.
1 parent fe96372 commit a23b704

15 files changed

+105
-19
lines changed
 
Binary file not shown.
Binary file not shown.

‎nitransforms/tests/data/regressions/bbregister.tfm

Lines changed: 0 additions & 5 deletions
This file was deleted.
Binary file not shown.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file was generated with bbregister, with fMRIPrep-20.0.5's settings
2+
type = 0 # LINEAR_VOX_TO_VOX
3+
nxforms = 1
4+
mean = 0.0000 0.0000 0.0000
5+
sigma = 10000.0000
6+
1 4 4
7+
3.124095916748047e+00 -2.993918396532536e-02 -8.824434876441956e-02 3.380017089843750e+01
8+
-7.292380183935165e-02 -1.901555061340332e+00 -3.172848463058472e+00 2.405808868408203e+02
9+
-1.820227503776550e-02 2.479679346084595e+00 -2.434180974960327e+00 7.082101440429688e+01
10+
0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
11+
src volume info
12+
valid = 1 # volume info valid
13+
filename = /home/oesteban/tmp/fmriprep-ds005/fprep-work/fmriprep_wf/single_subject_01_wf/func_preproc_task_mixedgamblestask_run_01_wf/bold_reg_wf/bbreg_wf/bbregister/uni_xform_masked.nii.gz
14+
volume = 64 64 34
15+
voxelsize = 3.125000000000000e+00 3.125000000000000e+00 4.000000000000000e+00
16+
xras = -1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
17+
yras = 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
18+
zras = 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
19+
cras = 1.000000000000000e+00 2.800000000000000e+01 -3.100000000000000e+01
20+
dst volume info
21+
valid = 1 # volume info valid
22+
filename = /oak/stanford/groups/russpold/data/openfmri/derivatives/ds000005/freesurfer-6.0.1/sub-01/mri/orig.mgz
23+
volume = 256 256 256
24+
voxelsize = 1.000000000000000e+00 1.000000000000000e+00 1.000000000000000e+00
25+
xras = -9.999999403953552e-01 0.000000000000000e+00 0.000000000000000e+00
26+
yras = 0.000000000000000e+00 0.000000000000000e+00 -9.999999403953552e-01
27+
zras = 0.000000000000000e+00 9.999999403953552e-01 0.000000000000000e+00
28+
cras = -9.999847412109375e-01 -5.000015258789062e+00 -1.000038146972656e+00
29+
subject sub-01
30+
fscale 0.100000
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#Insight Transform File V1.0
2+
#Transform 0
3+
Transform: AffineTransform_double_3_3
4+
Parameters: 0.99971085786819458 0.0058247237466275692 0.023335624486207962 0.0095805395394563675 0.79349809885025024 -0.608498215675354 -0.022061100229620934 0.60854566097259521 0.79321271181106567 -5.5388064384460449 -45.559787750244141 -48.801029205322266
5+
FixedParameters: 0 0 0

‎nitransforms/tests/data/regressions/bbregister.lta renamed to ‎nitransforms/tests/data/regressions/from-scanner_to-bold_mode-image.lta

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
# This file was generated with bbregister, with fMRIPrep-20.0.5's settings
2+
# mri_concatenate_lta from-fsnative_to-bold_mode-image.lta from-scanner_to-fsnative_mode-image.lta from-scanner_to-bold_mode-image.lta
13
type = 0 # LINEAR_VOX_TO_VOX
24
nxforms = 1
35
mean = 0.0000 0.0000 0.0000
46
sigma = 1.0000
57
1 4 4
6-
-3.124080896377563e+00 2.981145866215229e-02 8.914728462696075e-02 1.741926879882812e+02
7-
-1.405486371368170e-02 1.859627604484558e+00 -1.825850725173950e+00 5.312585067749023e+01
8-
5.505303665995598e-02 1.426339745521545e+00 2.379452466964722e+00 1.154438781738281e+01
9-
0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 9.999998807907104e-01
8+
-3.124080896377563e+00 2.981145866215229e-02 8.914728462696075e-02 1.741926879882812e+02
9+
-1.405486371368170e-02 1.859627604484558e+00 -1.825850725173950e+00 5.312585067749023e+01
10+
5.505303665995598e-02 1.426339745521545e+00 2.379452466964722e+00 1.154438781738281e+01
11+
0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 9.999998807907104e-01
1012
src volume info
1113
valid = 1 # volume info valid
1214
filename = /home/oesteban/tmp/fmriprep-ds005/fprep-work/fmriprep_wf/single_subject_01_wf/func_preproc_task_mixedgamblestask_run_01_wf/bold_reg_wf/bbreg_wf/bbregister/uni_xform_masked.nii.gz
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#Insight Transform File V1.0
2+
#Transform 0
3+
Transform: AffineTransform_double_3_3
4+
Parameters: 0.99970638751983643 0.0059967394918203354 0.023489311337471008 0.0095396693795919418 0.79344195127487183 -0.60857224464416504 -0.02228684164583683 0.60861742496490479 0.7931513786315918 -5.5388941764831543 -45.574077606201172 -48.804073333740234
5+
FixedParameters: 0 0 0
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file was generated with mri_robust_register, with fMRIPrep-20.0.5's settings
2+
# mri_robust_register --satit --iscale --lta from-scanner_to-fsnative_mode-image.lta --mov T1_fsnative.nii.gz --dst T1_scanner.nii.gz
3+
4+
type = 1 # LINEAR_RAS_TO_RAS
5+
nxforms = 1
6+
mean = 129.0000 157.0000 132.0000
7+
sigma = 10000.0000
8+
1 4 4
9+
9.999999403953552e-01 -1.698292035143822e-04 1.542967074783519e-04 -1.678466796875000e-04
10+
1.698438863968477e-04 9.999999403953552e-01 -9.513227996649221e-05 -1.318359375000000e-02
11+
-1.542805403005332e-04 9.515848068986088e-05 9.999999403953552e-01 -6.271362304687500e-03
12+
0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 9.999999403953552e-01
13+
src volume info
14+
valid = 1 # volume info valid
15+
filename = /oak/stanford/groups/russpold/data/openfmri/derivatives/ds000005/freesurfer-6.0.1/sub-01/mri/T1.mgz
16+
volume = 256 256 256
17+
voxelsize = 1.000000000000000e+00 1.000000000000000e+00 1.000000000000000e+00
18+
xras = -9.999999403953552e-01 0.000000000000000e+00 0.000000000000000e+00
19+
yras = 0.000000000000000e+00 0.000000000000000e+00 -9.999999403953552e-01
20+
zras = 0.000000000000000e+00 9.999999403953552e-01 0.000000000000000e+00
21+
cras = -9.999847412109375e-01 -5.000015258789062e+00 -1.000038146972656e+00
22+
dst volume info
23+
valid = 1 # volume info valid
24+
filename = /oak/stanford/groups/russpold/data/openfmri/ds000005/sub-01/anat/sub-01_T1w.nii.gz
25+
volume = 160 192 192
26+
voxelsize = 1.000000000000000e+00 1.333333015441895e+00 1.333333015441895e+00
27+
xras = 1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
28+
yras = 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
29+
zras = 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
30+
cras = -1.000000000000000e+00 -5.000030517578125e+00 -1.000030517578125e+00
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#Insight Transform File V1.0
2+
#Transform 0
3+
Transform: AffineTransform_double_3_3
4+
Parameters: 1 0.00016984390094876289 0.00015428056940436363 -0.00016982921806629747 1 -9.5158495241776109e-05 -0.00015429672203026712 9.513228724244982e-05 1 -0.00016911829879973084 -0.01318416278809309 0.0062701348215341568
5+
FixedParameters: 0 0 0

‎nitransforms/tests/test_conversions.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,32 @@
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33
"""Conversions between formats."""
44
import numpy as np
5+
import pytest
56
from .. import linear as _l
67

78

8-
def test_conversions0(data_path):
9+
@pytest.mark.parametrize('filename', [
10+
"from-fsnative_to-bold_mode-image",
11+
"from-fsnative_to-scanner_mode-image",
12+
"from-scanner_to-bold_mode-image",
13+
"from-scanner_to-fsnative_mode-image",
14+
])
15+
def test_lta2itk_conversions(data_path, filename):
916
"""Check conversions between formats."""
10-
lta = _l.load(data_path / "regressions" / "robust_register.lta", fmt="lta")
11-
itk = _l.load(data_path / "regressions" / "robust_register.tfm", fmt="itk")
12-
17+
lta = _l.load(data_path / "regressions" / ".".join((filename, "lta")),
18+
fmt="lta")
19+
itk = _l.load(data_path / "regressions" / ".".join((filename, "tfm")),
20+
fmt="itk")
1321
assert np.allclose(lta.matrix, itk.matrix)
1422

1523

16-
def test_conversions1(data_path):
17-
"""Check conversions between formats."""
18-
lta = _l.load(data_path / "regressions" / "bbregister.lta", fmt="lta")
19-
itk = _l.load(data_path / "regressions" / "bbregister.tfm", fmt="itk")
24+
def test_concatenation(data_path):
25+
"""Check replacement to lta_concat."""
26+
lta0 = _l.load(data_path / "regressions" / "from-scanner_to-fsnative_mode-image.lta",
27+
fmt="lta")
28+
lta1 = _l.load(data_path / "regressions" / "from-fsnative_to-bold_mode-image.lta", fmt="lta")
2029

21-
assert np.allclose(lta.matrix, itk.matrix)
30+
lta_combined = _l.load(data_path / "regressions" / "from-scanner_to-bold_mode-image.lta",
31+
fmt="lta")
32+
33+
assert np.allclose(lta1.matrix.dot(lta0.matrix), lta_combined.matrix)

‎nitransforms/tests/test_io.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ def test_Displacements(sw_tool):
342342
afni.AFNIDisplacementsField.from_image(field)
343343

344344

345-
@pytest.mark.parametrize('file_type, test_file', [(LTA, 'robust_register.lta')])
345+
@pytest.mark.parametrize('file_type, test_file', [
346+
(LTA, 'from-fsnative_to-scanner_mode-image.lta')
347+
])
346348
def test_regressions(file_type, test_file, data_path):
347349
file_type.from_filename(data_path / 'regressions' / test_file)

0 commit comments

Comments
 (0)
Please sign in to comment.