From 97ec31173124d8be903ae936e58a88fee1841e02 Mon Sep 17 00:00:00 2001 From: Keith Jamison Date: Tue, 14 May 2024 10:53:44 -0400 Subject: [PATCH 1/5] [FIX] Add "double" type to allowed DisplacementFieldTransform The ANTs utility `CompositeTransformUtil --assemble` outputs its displacement field as 'DisplacementFieldTransform_double_3_3', but utils/transform/load_ants_h5 throws an error unless it is 'DisplacementFieldTransform_float_3_3'. Presumably this is just a check to make sure it is a displacement field. The code after this check works fine for "double". --- fmriprep/utils/transforms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fmriprep/utils/transforms.py b/fmriprep/utils/transforms.py index 0210f90f8..51a8a11a5 100644 --- a/fmriprep/utils/transforms.py +++ b/fmriprep/utils/transforms.py @@ -71,7 +71,7 @@ def load_ants_h5(filename: Path) -> nt.base.TransformBase: transform2 = h['TransformGroup']['2'] # Confirm these transformations are applicable - if transform2['TransformType'][:][0] != b'DisplacementFieldTransform_float_3_3': + if transform2['TransformType'][:][0] not in (b'DisplacementFieldTransform_float_3_3', b'DisplacementFieldTransform_double_3_3'): msg = 'Unknown transform type [2]\n' for i in h['TransformGroup'].keys(): msg += f'[{i}]: {h["TransformGroup"][i]["TransformType"][:][0]}\n' From 0b3774b2a09ca5c514b78c25a9bcf124c1de0492 Mon Sep 17 00:00:00 2001 From: Keith Jamison Date: Tue, 14 May 2024 11:02:42 -0400 Subject: [PATCH 2/5] Wrap proposed line in transforms.py Wrap line to stay under style limits --- fmriprep/utils/transforms.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fmriprep/utils/transforms.py b/fmriprep/utils/transforms.py index 51a8a11a5..4e6cdd0bf 100644 --- a/fmriprep/utils/transforms.py +++ b/fmriprep/utils/transforms.py @@ -71,7 +71,8 @@ def load_ants_h5(filename: Path) -> nt.base.TransformBase: transform2 = h['TransformGroup']['2'] # Confirm these transformations are applicable - if transform2['TransformType'][:][0] not in (b'DisplacementFieldTransform_float_3_3', b'DisplacementFieldTransform_double_3_3'): + if transform2['TransformType'][:][0] not in (b'DisplacementFieldTransform_float_3_3', + b'DisplacementFieldTransform_double_3_3'): msg = 'Unknown transform type [2]\n' for i in h['TransformGroup'].keys(): msg += f'[{i}]: {h["TransformGroup"][i]["TransformType"][:][0]}\n' From d487cc17f848f44429d2b0e0335212e7d7fb660c Mon Sep 17 00:00:00 2001 From: Keith Jamison Date: Tue, 14 May 2024 11:05:42 -0400 Subject: [PATCH 3/5] Remove trailing whitespace in new line Remove trailing whitespace per style guidelines --- fmriprep/utils/transforms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fmriprep/utils/transforms.py b/fmriprep/utils/transforms.py index 4e6cdd0bf..6c6d73737 100644 --- a/fmriprep/utils/transforms.py +++ b/fmriprep/utils/transforms.py @@ -71,7 +71,7 @@ def load_ants_h5(filename: Path) -> nt.base.TransformBase: transform2 = h['TransformGroup']['2'] # Confirm these transformations are applicable - if transform2['TransformType'][:][0] not in (b'DisplacementFieldTransform_float_3_3', + if transform2['TransformType'][:][0] not in (b'DisplacementFieldTransform_float_3_3', b'DisplacementFieldTransform_double_3_3'): msg = 'Unknown transform type [2]\n' for i in h['TransformGroup'].keys(): From 1dcfa55b33562ca62196ef277043fd699b96a76c Mon Sep 17 00:00:00 2001 From: Keith Jamison Date: Tue, 14 May 2024 11:13:47 -0400 Subject: [PATCH 4/5] Re-re-wrap lines according to style suggestion --- fmriprep/utils/transforms.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fmriprep/utils/transforms.py b/fmriprep/utils/transforms.py index 6c6d73737..297ab0b92 100644 --- a/fmriprep/utils/transforms.py +++ b/fmriprep/utils/transforms.py @@ -71,8 +71,10 @@ def load_ants_h5(filename: Path) -> nt.base.TransformBase: transform2 = h['TransformGroup']['2'] # Confirm these transformations are applicable - if transform2['TransformType'][:][0] not in (b'DisplacementFieldTransform_float_3_3', - b'DisplacementFieldTransform_double_3_3'): + if transform2['TransformType'][:][0] not in ( + b'DisplacementFieldTransform_float_3_3', + b'DisplacementFieldTransform_double_3_3' + ): msg = 'Unknown transform type [2]\n' for i in h['TransformGroup'].keys(): msg += f'[{i}]: {h["TransformGroup"][i]["TransformType"][:][0]}\n' From 9483f5bb23e0bd846657ffd155a076c9e0739596 Mon Sep 17 00:00:00 2001 From: Keith Jamison Date: Tue, 14 May 2024 11:15:28 -0400 Subject: [PATCH 5/5] Update transforms.py --- fmriprep/utils/transforms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fmriprep/utils/transforms.py b/fmriprep/utils/transforms.py index 297ab0b92..7b36eb359 100644 --- a/fmriprep/utils/transforms.py +++ b/fmriprep/utils/transforms.py @@ -73,7 +73,7 @@ def load_ants_h5(filename: Path) -> nt.base.TransformBase: # Confirm these transformations are applicable if transform2['TransformType'][:][0] not in ( b'DisplacementFieldTransform_float_3_3', - b'DisplacementFieldTransform_double_3_3' + b'DisplacementFieldTransform_double_3_3', ): msg = 'Unknown transform type [2]\n' for i in h['TransformGroup'].keys():