Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Schnabel <[email protected]>
  • Loading branch information
Shadow-Devil committed Jan 29, 2023
1 parent e4b89cf commit c03d687
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions monai/data/itk_torch_affine_matrix_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ def itk_affine_resample(image, matrix, translation, center_of_rotation=None):

def monai_affine_resample(metatensor: MetaTensor, affine_matrix: NdarrayOrTensor):
# TODO documentation, change to mode=3
#affine = Affine(affine=affine_matrix, mode=3, padding_mode='mirror', dtype=torch.float64, image_only=True)
#output_tensor = cast(MetaTensor, affine(metatensor))
# affine = Affine(affine=affine_matrix, mode=3, padding_mode='mirror', dtype=torch.float64, image_only=True)
# output_tensor = cast(MetaTensor, affine(metatensor))
affine = Affine(affine=affine_matrix, padding_mode="zeros", dtype=torch.float64, image_only=True)
output_tensor = cast(MetaTensor, affine(metatensor, mode="bilinear"))

Expand Down
11 changes: 5 additions & 6 deletions tests/test_itk_torch_affine_matrix_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,24 @@
TESTS = [
"CT_2D_head_fixed.mha",
"CT_2D_head_moving.mha",
#"copd1_highres_INSP_STD_COPD_img.nii.gz"
# "copd1_highres_INSP_STD_COPD_img.nii.gz"
]
# Download URL:
# SHA-521: 60193cd6ef0cf055c623046446b74f969a2be838444801bd32ad5bedc8a7eeecb343e8a1208769c9c7a711e101c806a3133eccdda7790c551a69a64b9b3701e9
#TEST_CASE_3D_1 = [
# TEST_CASE_3D_1 = [
# "copd1_highres_INSP_STD_COPD_img.nii.gz" # https://data.kitware.com/api/v1/file/62a0f067bddec9d0c4175c5a/download
# "copd1_highres_INSP_STD_COPD_img.nii.gz" # https://data.kitware.com/api/v1/item/62a0f045bddec9d0c4175c44/download
# ]



@unittest.skipUnless(has_itk, "Requires `itk` package.")
class TestITKTorchAffineMatrixBridge(unittest.TestCase):
def setUp(self):
# TODO: which data should be used
self.data_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "testing_data")
self.reader = ITKReader()

#for filepath in TEST_CASES:
# for filepath in TEST_CASES:
# if not os.path.exists(os.path.join(self.data_dir, filepath)):
# with skip_if_downloading_fails():
# data_spec = testing_data_config("images", filepath)
Expand Down Expand Up @@ -94,12 +93,12 @@ def test_setting_affine_parameters(self, filepath):
###########################################################################
# Make sure that the array conversion of the inputs is the same
input_array_monai = metatensor_to_array(metatensor)
#output_array_monai = ITKWriter.create_backend_obj(
# output_array_monai = ITKWriter.create_backend_obj(
# metatensor.array,
# channel_dim=None,
# affine=affine_matrix_for_monai,
# affine_lps_to_ras=False, # False if the affine is in itk convention
#)
# )
np.testing.assert_array_equal(input_array_monai, np.asarray(image))

# Compare outputs
Expand Down

0 comments on commit c03d687

Please sign in to comment.