Skip to content

Commit

Permalink
Fix smoothing for current amplitude detection (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudon committed Mar 24, 2023
2 parents 44bb87d + 5c31ff6 commit 93ac7e0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bluepyefe/ecode/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""
import numpy
from scipy.signal import medfilt2d
from scipy.ndimage import median_filter


def scipy_signal2d(data, width):
return medfilt2d(data.reshape(1, -1), (1, width))[0].tolist()
return median_filter(data, size=width).tolist()


def base_current(current, idx_ton=300):
Expand Down
31 changes: 31 additions & 0 deletions tests/test_ecode_tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from bluepyefe.ecode import tools
import numpy as np
from numpy.testing import assert_array_almost_equal, assert_almost_equal


def test_scipy_signal2d():
np.random.seed(42)
data = np.random.uniform(-1, 1, 10)
res = tools.scipy_signal2d(data, 85)
assert_array_almost_equal(
res,
[
0.2022300234864176,
0.1973169683940732,
0.1973169683940732,
0.1973169683940732,
0.1973169683940732,
0.1973169683940732,
0.1973169683940732,
0.2022300234864176,
0.2022300234864176,
0.2022300234864176,
],
)


def test_base_current():
np.random.seed(42)
data = np.random.uniform(-1, 1, 10)
base = tools.base_current(data)
assert_almost_equal(base, 0.1973169683940732)

0 comments on commit 93ac7e0

Please sign in to comment.