diff --git a/platipy/imaging/label/utils.py b/platipy/imaging/label/utils.py index 35f8d64a..f3e8138f 100644 --- a/platipy/imaging/label/utils.py +++ b/platipy/imaging/label/utils.py @@ -168,8 +168,16 @@ def prime_encode_structure_list(structure_list): # Multiply with the encoded image prime_encoded_image = ( - sitk.MaskNegated(prime_encoded_image, s_img_int) - + sitk.Mask(prime_encoded_image, s_img_int) * prime * s_img_int + sitk.Cast( + sitk.MaskNegated( + sitk.Cast(prime_encoded_image, sitk.sitkUInt8), + sitk.Cast(s_img_int, sitk.sitkUInt8), + ), + sitk.sitkUInt64, + ) + + sitk.Mask(prime_encoded_image, sitk.Cast(s_img_int, sitk.sitkUInt8)) + * prime + * s_img_int ) return prime_encoded_image @@ -262,7 +270,6 @@ def binary_decode_image(binary_encoded_img): num_nonzero_voxels = 1 for power in range(32): - # Calculate the region originally defined with this prime s_arr = np.bitwise_and(binary_encoded_arr, 2 ** (power + 1)) diff --git a/platipy/imaging/registration/deformable.py b/platipy/imaging/registration/deformable.py index ced1d60c..39231c9d 100644 --- a/platipy/imaging/registration/deformable.py +++ b/platipy/imaging/registration/deformable.py @@ -65,7 +65,6 @@ def multiscale_demons( moving_images = [] for resolution, smoothing_sigma in zip(resolution_staging, smoothing_sigmas): - isotropic_voxel_size_mm = None shrink_factor = None @@ -123,9 +122,7 @@ def multiscale_demons( ) initial_displacement_field.CopyInformation(fixed_image) else: - initial_displacement_field = sitk.Resample( - initial_displacement_field, fixed_image - ) + initial_displacement_field = sitk.Resample(initial_displacement_field, fixed_image) # Run the registration. # Start at the top of the pyramid and work our way down. @@ -139,9 +136,7 @@ def multiscale_demons( # we now apply the (total) transform to the moving image dvf_total = sitk.Resample(dvf_total, f_image) - tfm_total = sitk.DisplacementFieldTransform( - sitk.Cast(dvf_total, sitk.sitkVectorFloat64) - ) + tfm_total = sitk.DisplacementFieldTransform(sitk.Cast(dvf_total, sitk.sitkVectorFloat64)) m_image = sitk.Resample(m_image, tfm_total, interp_order) # set up iteration staging @@ -258,7 +253,7 @@ def fast_symmetric_forces_demons_registration( regularisation_kernel_vox = np.array(regularisation_kernel_mm) / np.array( fixed_image.GetSpacing() ) - print("regularisation_kernel_vox", regularisation_kernel_vox) + registration_method.SetStandardDeviations(regularisation_kernel_vox.tolist()) # This allows monitoring of the progress