Skip to content

Commit

Permalink
small fixes for multicore
Browse files Browse the repository at this point in the history
  • Loading branch information
royerloic committed Mar 23, 2022
1 parent fe7e422 commit 1c84382
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
11 changes: 8 additions & 3 deletions aydin/it/classic_denoisers/butterworth.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def calibrate_denoise_butterworth(
crop_size_in_voxels: Optional[int] = _defaults.default_crop_size,
optimiser: str = _defaults.default_optimiser,
max_num_evaluations: int = _defaults.default_max_evals_normal,
multi_core: bool = True,
display_images: bool = False,
display_crop: bool = False,
**other_fixed_parameters,
Expand Down Expand Up @@ -87,6 +88,10 @@ def calibrate_denoise_butterworth(
Maximum number of evaluations for finding the optimal parameters.
(advanced)
multi_core: bool
Use all CPU cores during calibration.
(advanced)
display_images: bool
When True the denoised images encountered during optimisation are shown.
(advanced)
Expand Down Expand Up @@ -125,7 +130,7 @@ def calibrate_denoise_butterworth(
if mode == 'isotropic':
# Partial function:
_denoise_butterworth = partial(
denoise_butterworth, **(other_fixed_parameters | {'multi_core': False})
denoise_butterworth, **(other_fixed_parameters | {'multi_core': multi_core})
)

# Parameters to test when calibrating the denoising algorithm
Expand All @@ -145,7 +150,7 @@ def _denoise_butterworth(*args, **kwargs):
return denoise_butterworth(
*args,
freq_cutoff=_freq_cutoff,
**(kwargs | other_fixed_parameters),
**(kwargs | other_fixed_parameters | {'multi_core': multi_core}),
)

# Parameters to test when calibrating the denoising algorithm
Expand All @@ -164,7 +169,7 @@ def _denoise_butterworth(*args, **kwargs):
return denoise_butterworth(
*args,
freq_cutoff=_freq_cutoff,
**(kwargs | other_fixed_parameters | {'multi_core': False}),
**(kwargs | other_fixed_parameters | {'multi_core': multi_core}),
)

# Parameters to test when calibrating the denoising algorithm
Expand Down
7 changes: 6 additions & 1 deletion aydin/it/classic_denoisers/pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def calibrate_denoise_pca(
crop_size_in_voxels: Optional[int] = _defaults.default_crop_size,
optimiser: str = _defaults.default_optimiser,
max_num_evaluations: int = _defaults.default_max_evals_ultralow,
multi_core: bool = True,
display_images: bool = False,
display_crop: bool = False,
**other_fixed_parameters,
Expand Down Expand Up @@ -57,6 +58,10 @@ def calibrate_denoise_pca(
Maximum number of evaluations for finding the optimal parameters.
(advanced)
multi_core: bool
Use all CPU cores during calibration.
(advanced)
display_images: bool
When True the denoised images encountered during optimisation are shown
Expand Down Expand Up @@ -95,7 +100,7 @@ def calibrate_denoise_pca(

# Partial function:
_denoise_pca = partial(
denoise_pca, **(other_fixed_parameters | {'multi_core': True})
denoise_pca, **(other_fixed_parameters | {'multi_core': multi_core})
)

# Calibrate denoiser
Expand Down
7 changes: 6 additions & 1 deletion aydin/it/classic_denoisers/spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def calibrate_denoise_spectral(
crop_size_in_voxels: Optional[int] = _defaults.default_crop_size,
optimiser: str = _defaults.default_optimiser,
max_num_evaluations: int = _defaults.default_max_evals_low,
multi_core: bool = True,
display_images: bool = False,
display_crop: bool = False,
**other_fixed_parameters,
Expand Down Expand Up @@ -81,6 +82,10 @@ def calibrate_denoise_spectral(
Maximum number of evaluations for finding the optimal parameters.
(advanced)
multi_core: bool
Use all CPU cores during calibration.
(advanced)
display_images: bool
When True the denoised images encountered during optimisation are shown
Expand Down Expand Up @@ -140,7 +145,7 @@ def calibrate_denoise_spectral(

# Partial function:
_denoise_spectral = partial(
denoise_spectral, **(other_fixed_parameters | {'multi_core': True})
denoise_spectral, **(other_fixed_parameters | {'multi_core': multi_core})
)

# Calibrate denoiser
Expand Down
2 changes: 1 addition & 1 deletion aydin/it/classic_denoisers/test/test_butterworth.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def test_butterworth():
assert demo_butterworth(cropped_newyork(), display=False) >= 0.608 - 0.03
assert demo_butterworth(cropped_newyork(), display=False) >= 0.608 - 0.035


def test_butterworth_nd():
Expand Down
4 changes: 2 additions & 2 deletions aydin/it/classic_denoisers/test/test_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@


def test_dictionary_learned():
assert demo_dictionary_learned(cropped_newyork(), display=False) >= 0.636 - 0.015
assert demo_dictionary_learned(cropped_newyork(), display=False) >= 0.636 - 0.02


@pytest.mark.heavy
def test_dictionary_fixed():
assert demo_dictionary_fixed(cropped_newyork(), display=False) >= 0.636 - 0.015
assert demo_dictionary_fixed(cropped_newyork(), display=False) >= 0.636 - 0.02


def test_dictionary_nd():
Expand Down

0 comments on commit 1c84382

Please sign in to comment.