diff --git a/CITATION.cff b/CITATION.cff index 1b6ee06..d17cba2 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -48,6 +48,9 @@ authors: - given-names: Nabil family-names: Alibou affiliation: 'Biotrial, Neuroscience Department, Rennes, France' + - given-names: Ayush + family-names: Agarwal + affiliation: 'Techno India University, India' type: software repository-code: 'https://github.com/sappelhoff/pyprep' license: MIT diff --git a/docs/whats_new.rst b/docs/whats_new.rst index e8ce05d..2106264 100644 --- a/docs/whats_new.rst +++ b/docs/whats_new.rst @@ -27,6 +27,7 @@ Version 0.5.0 (Unreleased) Changelog ~~~~~~~~~ - :meth:`~pyprep.NoisyChannels.find_bad_by_nan_flat` now accepts a ``flat_threshold`` argument, by `Nabil Alibou`_ (:gh:`144`) +- changed _mad function in utils.py to use median_abs_deviation from the sciPy module, by `Ayush Agarwal`_ (:gh:`153`). Bug ~~~ @@ -234,3 +235,4 @@ Changelog .. _Mathieu Scheltienne: https://github.com/mscheltienne .. _Ole Bialas: https://github.com/OleBialas .. _Nabil Alibou: https://github.com/nabilalibou +.. _Ayush Agarwal: https://github.com/Ayush-Devs diff --git a/pyprep/utils.py b/pyprep/utils.py index ae29678..c32f016 100644 --- a/pyprep/utils.py +++ b/pyprep/utils.py @@ -10,6 +10,7 @@ from psutil import virtual_memory from scipy import linalg from scipy.signal import firwin, lfilter, lfilter_zi +from scipy.stats import median_abs_deviation def _union(list1, list2): @@ -487,11 +488,7 @@ def _mad(x, axis=None): raise ValueError(e.format(x.ndim)) # Calculate the median absolute deviation from the median - med = np.median(x, axis=axis) - if axis == 1: - med = med.reshape(-1, 1) # Transposes array to allow subtraction below - mad = np.median(np.abs(x - med), axis=axis) - + mad = median_abs_deviation(x, axis=axis) return mad