Closed hazedine closed 1 month ago
I can reproduce this error on my local machine:
dot|joshua@monarch:~/data/sct_example_data/t2$ sct_maths -i t2.nii.gz -denoise 2 -o denoised_image.nii.gz
--
Spinal Cord Toolbox (git-jn/4318-sct_deepseg_subcommands-cd84b1ddd5b79dde7887a6dafc7f28b781beb573)
sct_maths -i t2.nii.gz -denoise 2 -o denoised_image.nii.gz
--
Traceback (most recent call last):
File "/home/joshua/repos/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_maths.py", line 640, in <module>
main(sys.argv[1:])
File "/home/joshua/repos/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_maths.py", line 572, in main
data = sct_math.denoise_nlmeans(data, patch_radius, block_radius)
File "/home/joshua/repos/spinalcordtoolbox/spinalcordtoolbox/math.py", line 316, in denoise_nlmeans
sigma = dipy.denoise.noise_estimate.estimate_sigma(data_in)
File "/home/joshua/repos/spinalcordtoolbox/contrib/tensorflow/lazy_loader.py", line 82, in __getattr__
return getattr(module, item)
AttributeError: module 'dipy' has no attribute 'denoise'
The LazyLoader solution requires accessing functions from modules, and does not work if you try to access submodules from modules.
So, the following changes are necessary:
# before
dipy = LazyLoader("dipy", globals(), "dipy")
sigma = dipy.denoise.noise_estimate.estimate_sigma(data_in)
denoised = dipy.denoise.nlmeans.nlmeans(data_in, sigma, patch_radius=patch_radius, block_radius=block_radius)
# after
dipy_noise = LazyLoader("dipy_noise", globals(), "dipy.denoise.noise_estimate")
dipy_nlmeans = LazyLoader("dipy_nlmeans", globals(), "dipy.denoise.nlmeans")
sigma = dipy_noise.estimate_sigma(data_in)
denoised = dipy_nlmeans.nlmeans(data_in, sigma, patch_radius=patch_radius, block_radius=block_radius)
After making these changes, the function runs without error. My apologies for the inconvenience, I will fix this ASAP and backport the fix to v6.4.
Description
LazyLoader seems to cause issues in my system, previously working with SCT version 6.1.
Steps to Reproduce
Install SCT <release or git revision and platform, you can use the first lines of output of sct_check_dependencies>
Expected behavior:
Command executes without error
Actual behavior: