@@ -40,6 +40,30 @@ def test_displacements_init():
4040 )
4141
4242
43+ @pytest .mark .parametrize ("image_orientation" , ["RAS" , "LAS" , "LPS" , "oblique" ])
44+ @pytest .mark .parametrize ("axis" , [0 , 1 , 2 , (0 , 1 ), (1 , 2 ), (0 , 1 , 2 )])
45+ def test_displacements_to_filename (tmp_path , get_testdata , image_orientation , axis ):
46+ """Exercise to_filename."""
47+
48+ nii = get_testdata [image_orientation ]
49+ fieldmap = np .zeros ((* nii .shape [:3 ], 3 ), dtype = "float32" )
50+ fieldmap [..., axis ] = - 10.0
51+
52+ xfm = DenseFieldTransform (
53+ fieldmap ,
54+ reference = nii ,
55+ )
56+ xfm .to_filename (tmp_path / "warp_itk.nii.gz" , fmt = "itk" )
57+ xfm .to_filename (tmp_path / "warp_afni.nii.gz" , fmt = "afni" )
58+ xfm .to_filename (tmp_path / "warp_fsl.nii.gz" , fmt = "fsl" )
59+
60+ with pytest .raises (NotImplementedError ):
61+ xfm .to_filename (tmp_path / "warp_freesurfer.nii.gz" , fmt = "fs" )
62+
63+ with pytest .raises (TypeError ):
64+ xfm .to_filename (tmp_path / "warp.x5" , fmt = "X5" )
65+
66+
4367@pytest .mark .parametrize ("size" , [(20 , 20 , 20 ), (20 , 20 , 20 , 2 , 3 ), (20 , 20 , 20 , 1 , 4 )])
4468def test_displacements_bad_sizes (size ):
4569 """Checks field sizes."""
0 commit comments