From 3992bfc82c71cd2b71f959eaf6d9ce3d5019f596 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 31 Aug 2018 11:30:09 +0100 Subject: [PATCH 01/14] Remove the explicit shape checking of input array --- pyxem/utils/peakfinders2D.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyxem/utils/peakfinders2D.py b/pyxem/utils/peakfinders2D.py index cf72bb799..37790a997 100644 --- a/pyxem/utils/peakfinders2D.py +++ b/pyxem/utils/peakfinders2D.py @@ -100,8 +100,6 @@ def gradient(image): return gradient_of_image # Generate an ordered list of matrix coordinates. - if len(z.shape) != 2: - raise ValueError("'z' should be a 2-d image matrix.") z = z / np.max(z) coordinates = np.indices(z.data.shape).reshape(2, -1).T # Calculate the gradient at every point. From 73a290da38b6b430f9051c08b424340d113155d5 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 31 Aug 2018 11:32:00 +0100 Subject: [PATCH 02/14] removing the regionprops peakfinder --- pyxem/utils/peakfinders2D.py | 45 ------------------------------------ 1 file changed, 45 deletions(-) diff --git a/pyxem/utils/peakfinders2D.py b/pyxem/utils/peakfinders2D.py index 37790a997..5cd5e6da9 100644 --- a/pyxem/utils/peakfinders2D.py +++ b/pyxem/utils/peakfinders2D.py @@ -321,48 +321,3 @@ def find_peaks_log(z, min_sigma=1., max_sigma=50., num_sigma=10., except IndexError: return NO_PEAKS return centers - -def find_peaks_regionprops(z, min_sigma=4, max_sigma=5, threshold=1, - min_size=50, return_props=False): - """ - Finds peaks using regionprops. - Uses the difference of two gaussian convolutions to separate signal from - background, and then uses the skimage.measure.regionprops function to find - connected islands (peaks). Small blobs can be rejected using `min_size`. - - Parameters - ---------- - z : numpy.ndarray - Array of image intensities. - min_sigma : int, float - Standard deviation for the minimum gaussian convolution - max_sigma : int, float - Standard deviation for the maximum gaussian convolution - threshold : int, float - Minimum difference in intensity - min_size : int - Minimum size in pixels of blob - return_props : bool - Return skimage.measure.regionprops - - Returns - ------- - numpy.ndarray - (n_peaks, 2) - Array of peak coordinates. - - """ - from skimage import morphology, measure - - difference = ndi.gaussian_filter(z, min_sigma) - ndi.gaussian_filter(z, max_sigma) - - labels, numlabels = ndi.label(difference > threshold) - labels = morphology.remove_small_objects(labels, min_size) - - props = measure.regionprops(labels, z) - - if return_props: - return props - else: - peaks = np.array([prop.centroid for prop in props]) - return clean_peaks(peaks) From f4c08e2d845c740c70405663d9f427f84c24e005 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 31 Aug 2018 12:43:27 +0100 Subject: [PATCH 03/14] BUG: blob finders from skimage never return empty, so tryexcept had no merit --- pyxem/utils/peakfinders2D.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/pyxem/utils/peakfinders2D.py b/pyxem/utils/peakfinders2D.py index 5cd5e6da9..b91e26d9c 100644 --- a/pyxem/utils/peakfinders2D.py +++ b/pyxem/utils/peakfinders2D.py @@ -274,10 +274,8 @@ def find_peaks_dog(z, min_sigma=1., max_sigma=50., sigma_ratio=1.6, blobs = blob_dog(z, min_sigma=min_sigma, max_sigma=max_sigma, sigma_ratio=sigma_ratio, threshold=threshold, overlap=overlap) - try: - centers = blobs[:, :2] - except IndexError: - return NO_PEAKS + + centers = blobs[:, :2] clean_centers = [] for center in centers: if len(np.intersect1d(center, (0, 1) + z.shape + tuple( @@ -314,10 +312,6 @@ def find_peaks_log(z, min_sigma=1., max_sigma=50., num_sigma=10., blobs = blob_log(z, min_sigma=min_sigma, max_sigma=max_sigma, num_sigma=num_sigma, threshold=threshold, overlap=overlap, log_scale=log_scale) - # Attempt to return only peak positions. If no peaks exist, return an - # empty array. - try: - centers = blobs[:, :2] - except IndexError: - return NO_PEAKS + + centers = blobs[:, :2] return centers From c4ac253ce1cf24fa67d2a06e7e6e0cb459b49cda Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 31 Aug 2018 12:52:51 +0100 Subject: [PATCH 04/14] overhaul of the peakfinder test suite --- tests/test_utils/test_peakfinders2D.py | 58 ++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/tests/test_utils/test_peakfinders2D.py b/tests/test_utils/test_peakfinders2D.py index e4e448b51..2357bcf7b 100644 --- a/tests/test_utils/test_peakfinders2D.py +++ b/tests/test_utils/test_peakfinders2D.py @@ -20,6 +20,17 @@ import numpy as np from pyxem.utils.peakfinders2D import * +""" +A philosophical note: + It's very dificult to prove that a peakfinder with many parameters couldn't + find the peaks you have 'defined' if you just picked better parameters. + These tests are designed to show that when the peakfinders find 0,1,x (x>1) + peaks the results are of the style - if not the value - that we expect. +""" + +# see https://stackoverflow.com/questions/9205081/ +dispatcher = {'log': find_peaks_log, 'dog': find_peaks_dog, 'zaf':find_peaks_zaefferer,'stat':find_peaks_stat} + @pytest.fixture def single_peak(): pattern = np.zeros((128,128)) @@ -27,30 +38,60 @@ def single_peak(): return pattern @pytest.fixture -def double_peak(): +def many_peak(): pattern = np.zeros((128,128)) pattern[40:43,40:43] = 1 #index 40,41,42 are greater than zero pattern[70,21] = 1 #index 70 and 21 are greater than zero + pattern[10:13,41:43] = 1 + pattern[100:113,100:105] = 2 + return pattern + +@pytest.fixture +def no_peak(): + pattern = np.ones((128,128))*0.5 return pattern -def test_fp_dog(single_peak): - peaks = find_peaks_dog(single_peak) +methods = ['zaf'] +""" +dog and log have no safe way of returning for an empty peak array +Stat throws an error while running +""" +@pytest.mark.parametrize('method', methods) +def test_no_peak_case(no_peak,method): + peaks = dispatcher[method](no_peak) + assert np.isnan(peaks[0,0,0]) + assert np.isnan(peaks[0,0,1]) + +methods = ['zaf','log', 'dog','stat'] +@pytest.mark.parametrize('method', methods) +def test_one_peak_case(single_peak,method): + peaks = dispatcher[method](single_peak) assert peaks[0,0] > 39.5 assert peaks[0,0] < 42.5 assert peaks[0,0] == peaks[0,1] + +methods = ['zaf','log','stat'] +@pytest.mark.parametrize('method', methods) +def test_many_peak_case(many_peak,method): + peaks = dispatcher[method](many_peak) + assert np.max(peaks) > 2 + + + + + + + +""" @pytest.mark.skip(reason="params") def test_fp_dog_double(double_peak): peaks = find_peaks_dog(double_peak) assert (np.array([71,21]) in peaks) assert (np.array([41,41]) in peaks) -def test_fp_log(single_peak): - peaks = find_peaks_log(single_peak) - assert peaks[0,0] > 39.5 - assert peaks[0,0] < 42.5 - assert peaks[0,0] == peaks[0,1] + def test_fp_log_double(double_peak): peaks = find_peaks_log(double_peak) @@ -79,3 +120,4 @@ def test_fp_stat_double(double_peak): peaks = find_peaks_stat(double_peak) assert (np.array([71,21]) in peaks) assert (np.array([41,41]) in peaks) +""" From 65637982c2d1eff4418305b29d76e754f6217482 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 31 Aug 2018 14:02:19 +0100 Subject: [PATCH 05/14] typo corrections --- tests/test_utils/test_peakfinders2D.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/test_utils/test_peakfinders2D.py b/tests/test_utils/test_peakfinders2D.py index 2357bcf7b..5ec9778a1 100644 --- a/tests/test_utils/test_peakfinders2D.py +++ b/tests/test_utils/test_peakfinders2D.py @@ -53,10 +53,8 @@ def no_peak(): methods = ['zaf'] -""" -dog and log have no safe way of returning for an empty peak array -Stat throws an error while running -""" +# dog and log have no safe way of returning for an empty peak array +# stat throws an error while running @pytest.mark.parametrize('method', methods) def test_no_peak_case(no_peak,method): peaks = dispatcher[method](no_peak) From 522b3c492c678c461402e69c0ae8e8de0a34a3da Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 31 Aug 2018 14:03:03 +0100 Subject: [PATCH 06/14] carrying show_progressbar through to deadpixel map --- pyxem/signals/electron_diffraction.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyxem/signals/electron_diffraction.py b/pyxem/signals/electron_diffraction.py index 81146d703..521ef8aba 100644 --- a/pyxem/signals/electron_diffraction.py +++ b/pyxem/signals/electron_diffraction.py @@ -299,7 +299,8 @@ def apply_gain_normalisation(self, def remove_deadpixels(self, deadpixels, deadvalue='average', - inplace=True): + inplace=True, + progress_bar=True): """Remove deadpixels from experimentally acquired diffraction patterns. Parameters @@ -318,7 +319,8 @@ def remove_deadpixels(self, return self.map(remove_dead, deadpixels=deadpixels, deadvalue=deadvalue, - inplace=inplace) + inplace=inplace, + show_progressbar=progress_bar) def get_radial_profile(self,inplace=False,**kwargs): """Return the radial profile of the diffraction pattern. From f7a9236ac2d6d7d20130d4c7e48905e76826f150 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 31 Aug 2018 14:03:19 +0100 Subject: [PATCH 07/14] testing remove_deadpixels --- tests/test_signals/test_electron_diffraction.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/test_signals/test_electron_diffraction.py b/tests/test_signals/test_electron_diffraction.py index abe56005c..daf024dc5 100644 --- a/tests/test_signals/test_electron_diffraction.py +++ b/tests/test_signals/test_electron_diffraction.py @@ -76,7 +76,7 @@ def test_center_direct_beam(self,diffraction_pattern): def test_center_direct_beam_in_small_region(self,diffraction_pattern): assert isinstance(diffraction_pattern,ElectronDiffraction) diffraction_pattern.center_direct_beam(radius_start=1,radius_finish=3,square_width=3) - assert isinstance(diffraction_pattern,ElectronDiffraction) + assert isinstance(diffraction_pattern,ElectronDiffraction) def test_apply_affine_transformation(self, diffraction_pattern): diffraction_pattern.apply_affine_transformation( @@ -85,6 +85,19 @@ def test_apply_affine_transformation(self, diffraction_pattern): [0., 0., 1.]])) assert isinstance(diffraction_pattern, ElectronDiffraction) + methods = ['average','nan'] + @pytest.mark.parametrize('method', methods) + #@pytest.mark.skip(reason="currently crashes via a tqdm issue") + def test_remove_dead_pixels(self,diffraction_pattern,method): + diffraction_pattern.remove_deadpixels([[1,2],[5,6]],method,progress_bar=False) + assert isinstance(diffraction_pattern, ElectronDiffraction) + + @pytest.mark.xfail(raises=NotImplementedError) + def test_remove_dead_pixels_failing(self,diffraction_pattern): + diffraction_pattern.remove_deadpixels([[1,2],[5,6]],'fake_method',progress_bar=False) + + + class TestSimpleHyperspy: # Tests functions that assign to hyperspy metadata From a321b58a6e8a1e9a2ecddfbdcb75606e66251ea1 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 31 Aug 2018 14:36:33 +0100 Subject: [PATCH 08/14] Implement copy into remove_deadpixel to allow for non-inplace removal --- pyxem/utils/expt_utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pyxem/utils/expt_utils.py b/pyxem/utils/expt_utils.py index 3c30f3082..d53346527 100644 --- a/pyxem/utils/expt_utils.py +++ b/pyxem/utils/expt_utils.py @@ -157,20 +157,21 @@ def remove_dead(z, deadpixels, deadvalue="average", d=1): img : array Array containing the diffraction pattern with dead pixels removed. """ + z_bar = np.copy(z) if deadvalue == 'average': for (i,j) in deadpixels: neighbours = z[i-d:i+d+1, j-d:j+d+1].flatten() - z[i,j] = np.mean(neighbours) + z_bar[i,j] = np.mean(neighbours) elif deadvalue == 'nan': for (i,j) in deadpixels: - z[i,j] = np.nan + z_bar[i,j] = np.nan else: raise NotImplementedError("The method specified is not implemented. " "See documentation for available " "implementations.") - return z + return z_bar def affine_transformation(z,matrix,order,**kwargs): """Apply an affine transformation to a 2-dimensional array. From f0e57cf70f4af94b44deb37d8962b287f7bb3f77 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 31 Aug 2018 14:37:34 +0100 Subject: [PATCH 09/14] Remove inplace returns --- tests/test_signals/test_electron_diffraction.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/test_signals/test_electron_diffraction.py b/tests/test_signals/test_electron_diffraction.py index daf024dc5..789d39fa7 100644 --- a/tests/test_signals/test_electron_diffraction.py +++ b/tests/test_signals/test_electron_diffraction.py @@ -87,14 +87,13 @@ def test_apply_affine_transformation(self, diffraction_pattern): methods = ['average','nan'] @pytest.mark.parametrize('method', methods) - #@pytest.mark.skip(reason="currently crashes via a tqdm issue") def test_remove_dead_pixels(self,diffraction_pattern,method): - diffraction_pattern.remove_deadpixels([[1,2],[5,6]],method,progress_bar=False) - assert isinstance(diffraction_pattern, ElectronDiffraction) + dpr = diffraction_pattern.remove_deadpixels([[1,2],[5,6]],method,inplace=False) + assert isinstance(dpr, ElectronDiffraction) @pytest.mark.xfail(raises=NotImplementedError) def test_remove_dead_pixels_failing(self,diffraction_pattern): - diffraction_pattern.remove_deadpixels([[1,2],[5,6]],'fake_method',progress_bar=False) + dpr = diffraction_pattern.remove_deadpixels([[1,2],[5,6]],'fake_method',inplace=False,progress_bar=False) @@ -150,10 +149,10 @@ class TestGainNormalisation: ]) def test_apply_gain_normalisation(self, diffraction_pattern, dark_reference, bright_reference): - diffraction_pattern.apply_gain_normalisation( - dark_reference=dark_reference, bright_reference=bright_reference) - assert diffraction_pattern.max() == bright_reference - assert diffraction_pattern.min() == dark_reference + dpr = diffraction_pattern.apply_gain_normalisation( + dark_reference=dark_reference, bright_reference=bright_reference,inplace=False) + assert dpr.max() == bright_reference + assert dpr.min() == dark_reference class TestDirectBeamMethods: From 5735ff74c7d5f3c9f6800594f0a295733d290f36 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 31 Aug 2018 14:38:05 +0100 Subject: [PATCH 10/14] Add double cover to dead_pixels and subtract_reference --- tests/test_utils/test_expt_utils.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_utils/test_expt_utils.py b/tests/test_utils/test_expt_utils.py index ef1248ba9..eedb5a1af 100644 --- a/tests/test_utils/test_expt_utils.py +++ b/tests/test_utils/test_expt_utils.py @@ -91,6 +91,24 @@ def test_peaks_as_gvectors(z, center, calibration, g): gc = peaks_as_gvectors(z=z, center=center, calibration=calibration) np.testing.assert_almost_equal(gc, g) + +methods = ['average','nan'] +@pytest.mark.parametrize('method', methods) +def test_remove_dead_pixels(diffraction_pattern,method): + z = diffraction_pattern.data + dead_removed = remove_dead(z,[[3,3]],deadvalue=method) + assert z[3,3] != dead_removed[3,3] + + +def test_subtract_reference(diffraction_pattern): + z = diffraction_pattern.data + ref = 2*(z/3) + ref[0,0] = 1e6 #so that we get a less than zero subtraction + ref_subtracted = subtract_reference(z,ref) + assert ref_subtracted[0,0] == 0 + assert ref_subtracted[0,1] == z[0,1]*(1/3) + + class TestCenteringAlgorithm: @pytest.mark.parametrize("shifts_expected",[(0, 0)]) From 495c476484d58f1bedef7d695080b88345278df8 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 31 Aug 2018 15:11:04 +0100 Subject: [PATCH 11/14] Test map to bg subtraction method, create Testfailing class --- .../test_signals/test_electron_diffraction.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tests/test_signals/test_electron_diffraction.py b/tests/test_signals/test_electron_diffraction.py index 789d39fa7..fae3eeaf4 100644 --- a/tests/test_signals/test_electron_diffraction.py +++ b/tests/test_signals/test_electron_diffraction.py @@ -91,12 +91,6 @@ def test_remove_dead_pixels(self,diffraction_pattern,method): dpr = diffraction_pattern.remove_deadpixels([[1,2],[5,6]],method,inplace=False) assert isinstance(dpr, ElectronDiffraction) - @pytest.mark.xfail(raises=NotImplementedError) - def test_remove_dead_pixels_failing(self,diffraction_pattern): - dpr = diffraction_pattern.remove_deadpixels([[1,2],[5,6]],'fake_method',inplace=False,progress_bar=False) - - - class TestSimpleHyperspy: # Tests functions that assign to hyperspy metadata @@ -216,16 +210,18 @@ def test_radial_profile(self, diffraction_pattern_for_radial,expected): class TestBackgroundMethods: @pytest.mark.parametrize('method, kwargs', [ - ('h-dome', {'h': 1}), + ('h-dome', {'h': 1,}), ('gaussian_difference', {'sigma_min': 0.5, 'sigma_max': 1, }), - ('median', {'footprint': 4, }) + ('median', {'footprint': 4,}), + ('reference_pattern',{'bg':np.ones((8,8)),}) ]) - def test_remove_background(self, diffraction_pattern: ElectronDiffraction, + def test_remove_background(self, diffraction_pattern, method, kwargs): bgr = diffraction_pattern.remove_background(method=method, **kwargs) assert bgr.data.shape == diffraction_pattern.data.shape assert bgr.max() <= diffraction_pattern.max() +#@pytest.mark.skip(reason="Uncommented for speed during development") class TestPeakFinding: #This isn't testing the finding, that is done in test_peakfinders2D @@ -264,7 +260,14 @@ def test_findpeaks_ragged(self,peak,method): if peak(self).data[1,0,72,22] == 1: # 3 peaks assert output.data.shape == (2,2) # tests we have a sensible ragged array - @pytest.mark.xfail(raises=NotImplementedError) def test_failing_run(self,ragged_peak): ragged_peak.find_peaks(method='no_such_method_exists') + +@pytest.mark.xfail(raises=NotImplementedError) +class TestNotImplemented(): + def test_remove_dead_pixels_failing(self,diffraction_pattern): + dpr = diffraction_pattern.remove_deadpixels([[1,2],[5,6]],'fake_method',inplace=False,progress_bar=False) + + def test_remove_background(self, diffraction_pattern): + bgr = diffraction_pattern.remove_background(method='fake_method') From 34c86fb1379b6c77382cfbecaeaf2064d8699b45 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 31 Aug 2018 15:11:27 +0100 Subject: [PATCH 12/14] Force inplace return in all paths --- pyxem/signals/electron_diffraction.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyxem/signals/electron_diffraction.py b/pyxem/signals/electron_diffraction.py index 521ef8aba..3aac6a168 100644 --- a/pyxem/signals/electron_diffraction.py +++ b/pyxem/signals/electron_diffraction.py @@ -450,7 +450,8 @@ def remove_background(self, method, *args, **kwargs): Returns ------- bg_subtracted : :obj:`ElectronDiffraction` - A copy of the data with the background subtracted. + A copy of the data with the background subtracted. Be aware that + this function will only return inplace. """ if method == 'h-dome': @@ -470,7 +471,7 @@ def remove_background(self, method, *args, **kwargs): inplace=False, *args, **kwargs) elif method == 'reference_pattern': - bg_subtracted = self.map(subtract_reference, *args, **kwargs) + bg_subtracted = self.map(subtract_reference, inplace=False, *args, **kwargs) else: raise NotImplementedError( From 4e787adeac7c3fba54e624c3590eac95339fc024 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 31 Aug 2018 15:34:35 +0100 Subject: [PATCH 13/14] cleaning up background_subtraction functionality --- pyxem/utils/expt_utils.py | 2 +- tests/test_utils/test_expt_utils.py | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/pyxem/utils/expt_utils.py b/pyxem/utils/expt_utils.py index d53346527..e0e594e5e 100644 --- a/pyxem/utils/expt_utils.py +++ b/pyxem/utils/expt_utils.py @@ -271,7 +271,7 @@ def subtract_background_median(z, footprint=19, implementation='scipy'): # skimage only accepts input image as uint16 bg_subtracted = z - filters.median(z.astype(np.uint16), selem).astype(z.dtype) else: - raise ValueError("Unknown implementation `{}`".format(implementation)) + raise NotImplementedError("Unknown implementation `{}`".format(implementation)) return np.maximum(bg_subtracted, 0) diff --git a/tests/test_utils/test_expt_utils.py b/tests/test_utils/test_expt_utils.py index eedb5a1af..684760c50 100644 --- a/tests/test_utils/test_expt_utils.py +++ b/tests/test_utils/test_expt_utils.py @@ -99,16 +99,6 @@ def test_remove_dead_pixels(diffraction_pattern,method): dead_removed = remove_dead(z,[[3,3]],deadvalue=method) assert z[3,3] != dead_removed[3,3] - -def test_subtract_reference(diffraction_pattern): - z = diffraction_pattern.data - ref = 2*(z/3) - ref[0,0] = 1e6 #so that we get a less than zero subtraction - ref_subtracted = subtract_reference(z,ref) - assert ref_subtracted[0,0] == 0 - assert ref_subtracted[0,1] == z[0,1]*(1/3) - - class TestCenteringAlgorithm: @pytest.mark.parametrize("shifts_expected",[(0, 0)]) From a591ad5437abb2ac27e70c5d5369712efc0472db Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 31 Aug 2018 15:35:44 +0100 Subject: [PATCH 14/14] Add paramaterization to access another code branch --- tests/test_signals/test_electron_diffraction.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_signals/test_electron_diffraction.py b/tests/test_signals/test_electron_diffraction.py index fae3eeaf4..2883e8e14 100644 --- a/tests/test_signals/test_electron_diffraction.py +++ b/tests/test_signals/test_electron_diffraction.py @@ -213,6 +213,7 @@ class TestBackgroundMethods: ('h-dome', {'h': 1,}), ('gaussian_difference', {'sigma_min': 0.5, 'sigma_max': 1, }), ('median', {'footprint': 4,}), + ('median', {'footprint': 4, 'implementation': 'skimage'}), ('reference_pattern',{'bg':np.ones((8,8)),}) ]) def test_remove_background(self, diffraction_pattern, @@ -271,3 +272,6 @@ def test_remove_dead_pixels_failing(self,diffraction_pattern): def test_remove_background(self, diffraction_pattern): bgr = diffraction_pattern.remove_background(method='fake_method') + + def test_remove_background(self, diffraction_pattern): + bgr = diffraction_pattern.remove_background(method='median',implementation='fake_implementation')