diff --git a/sitkibex/__init__.py b/sitkibex/__init__.py index cd984b7..f93f91b 100644 --- a/sitkibex/__init__.py +++ b/sitkibex/__init__.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .globals import default_random_seed # noqa: F401 from .registration import registration from .resample import resample diff --git a/sitkibex/cli.py b/sitkibex/cli.py index c870f43..f3a9c19 100644 --- a/sitkibex/cli.py +++ b/sitkibex/cli.py @@ -15,7 +15,7 @@ # """ Provides command line interfaces for sitkibex registration algorithms""" -from .globals import default_random_seed # noqa: F401 +import sitkibex.globals import os from os.path import basename import SimpleITK as sitk @@ -71,12 +71,12 @@ def cli(**kwargs): def reg_cli(fixed_image, moving_image, output_transform, **kwargs): """Perform registration to solve for an OUTPUT_TRANSFORM mapping points from the FIXED_IMAGE to the MOVING_IMAGE.""" global default_random_seed - from .registration import registration + from sitkibex.registration import registration args = _Bunch(kwargs) if args.random: - default_random_seed = sitk.sitkWallClock + sitkibex.globals.default_random_seed = sitk.sitkWallClock fixed_image = sitk.BinShrink(sitk.ReadImage(fixed_image, sitk.sitkFloat32), [args.bin, args.bin, 1]) moving_image = sitk.BinShrink(sitk.ReadImage(moving_image, sitk.sitkFloat32), [args.bin, args.bin, 1]) diff --git a/sitkibex/registration.py b/sitkibex/registration.py index 0ed65cd..643f24c 100755 --- a/sitkibex/registration.py +++ b/sitkibex/registration.py @@ -18,7 +18,7 @@ import numpy as np from .registration_utilities import RegistrationCallbackManager from . import image_utilities as imgf -from .globals import default_random_seed # noqa: F401 +import sitkibex.globals import logging _logger = logging.getLogger(__name__) @@ -97,7 +97,7 @@ def register_3d(fixed_image, zip(sampling_percentage_per_level, scale_factors)])) reg.SetMetricSamplingPercentagePerLevel(sampling_percentage_per_level, - default_random_seed) + sitkibex.globals.default_random_seed) reg.SetMetricSamplingStrategy(reg.REGULAR) reg.SetShrinkFactorsPerLevel([f for f in scale_factors]) reg.SmoothingSigmasAreSpecifiedInPhysicalUnitsOn() @@ -201,7 +201,8 @@ def register_as_2d_affine(fixed_image, # We don't need more samples for larger image, so base the number of samples on the number of parameters sampling_percentage = len( initial_rigid.GetParameters()) * number_of_samples_per_parameter / fixed_2d.GetNumberOfPixels() - R.SetMetricSamplingPercentagePerLevel([min(0.10, sampling_percentage) for f in scale_factors], default_random_seed) + R.SetMetricSamplingPercentagePerLevel([min(0.10, sampling_percentage) for f in scale_factors], + sitkibex.globals.default_random_seed) R.SetMetricSamplingStrategy(R.REGULAR) R.SetShrinkFactorsPerLevel([1 for f in scale_factors]) R.SmoothingSigmasAreSpecifiedInPhysicalUnitsOn() @@ -255,7 +256,7 @@ def register_as_2d_affine(fixed_image, scale_factors = [8, 4, 2] sampling_percentage = len(affine.GetParameters()) * number_of_samples_per_parameter / fixed_2d.GetNumberOfPixels() R2.SetMetricSamplingPercentagePerLevel([min(0.10, sampling_percentage*f) for f in scale_factors], - default_random_seed) + sitkibex.globals.default_random_seed) R2.SetMetricSamplingStrategy(R.RANDOM) R2.SetShrinkFactorsPerLevel([f for f in scale_factors]) R2.SmoothingSigmasAreSpecifiedInPhysicalUnitsOn()