Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit 79c9fc5

Browse files
author
Jaquier Aurélien Tristan
committed
Small changes
* turn print statements in eFELFeature into logger.info * change docstring description of exp_mean and exp_std in extraFELFeature * remove MEA dependency in setup * use custom lfpy from fork in setup * use lfpy from extras in tox * add test function for masked_cosine_distance
1 parent b139c64 commit 79c9fc5

File tree

4 files changed

+44
-16
lines changed

4 files changed

+44
-16
lines changed

bluepyopt/ephys/efeatures.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,14 @@ def __init__(
316316
of channels
317317
stim_start (float): stimulation start time (ms)
318318
stim_end (float): stimulation end time (ms)
319-
exp_mean (float): experimental mean of this eFeature
320-
exp_std(float): experimental standard deviation of this eFeature
321-
threshold(float): spike detection threshold (mV)
319+
exp_mean (list of floats): experimental mean of this eFeature
320+
exp_std (list of floats): experimental standard deviation of this eFeature
321+
threshold (float): spike detection threshold (mV)
322322
comment (str): comment
323-
interp_step(float): interpolation step (ms)
324-
double_settings(dict): dictionary with efel double settings that
323+
interp_step (float): interpolation step (ms)
324+
double_settings (dict): dictionary with efel double settings that
325325
should be set before extracting the features
326-
int_settings(dict): dictionary with efel int settings that
326+
int_settings (dict): dictionary with efel int settings that
327327
should be set before extracting the features
328328
"""
329329

@@ -421,7 +421,6 @@ def calculate_feature(
421421
responses,
422422
raise_warnings=False,
423423
return_waveforms=False,
424-
verbose=False,
425424
):
426425
from .extra_features_utils import calculate_features
427426

@@ -445,21 +444,18 @@ def calculate_feature(
445444
np.diff(response["time"])
446445
):
447446
assert self.fs is not None
448-
if verbose:
449-
print("interpolate")
447+
logger.info("extraFELFeature.calculate_feature: interpolate")
450448
response_interp = _interpolate_response(response, fs=self.fs)
451449
else:
452450
response_interp = response
453451

454452
if self.fcut is not None:
455-
if verbose:
456-
print("filter enabled")
453+
logger.info("extraFELFeature.calculate_feature: enabled")
457454
response_filter = _filter_response(response_interp,
458455
fcut=self.fcut,
459456
filt_type=self.filt_type)
460457
else:
461-
if verbose:
462-
print("filter disabled")
458+
logger.info("extraFELFeature.calculate_feature: filter disabled")
463459
response_filter = response_interp
464460

465461
ewf = _get_waveforms(response_filter, peak_times, self.ms_cut)

bluepyopt/tests/test_ephys/test_features.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,3 +326,36 @@ def test_extraFELFeature():
326326

327327
assert efeature.name == name
328328
assert extrafel_feature_name in str(efeature)
329+
330+
331+
332+
333+
@pytest.mark.unit
334+
def test_masked_cosine_distance():
335+
"""ephys.efeatures: Testing masked_cosine_distance"""
336+
from scipy.spatial import distance
337+
338+
exp = numpy.array([0.5, 0.5, 0.5])
339+
model = numpy.array([0.7, 0.8, 0.4])
340+
341+
score = efeatures.masked_cosine_distance(exp, model)
342+
assert score == distance.cosine(exp, model)
343+
344+
# test nan in model feature values
345+
model = numpy.array([0.7, numpy.nan, 0.4])
346+
score = efeatures.masked_cosine_distance(exp, model)
347+
assert score == distance.cosine([0.5, 0.5], [0.7, 0.4])
348+
349+
# test nan in experimental feature values
350+
exp = numpy.array([0.5, 0.5, numpy.nan])
351+
model = numpy.array([0.7, 0.8, 0.4])
352+
353+
score = efeatures.masked_cosine_distance(exp, model)
354+
assert score == distance.cosine([0.5, 0.5], [0.7, 0.8]) * 2. / 3.
355+
356+
# test na in both exp and model feature values
357+
exp = numpy.array([0.5, 0.5, numpy.nan])
358+
model = numpy.array([0.7, numpy.nan, 0.4])
359+
360+
score = efeatures.masked_cosine_distance(exp, model)
361+
assert score == distance.cosine([0.5], [0.7]) * 2. / 3.

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
]
3030

3131
EXTRA_LFP = [
32-
'MEAutility',
33-
'LFPy>=2.2.0',
32+
'LFPy @ git+https://github.com/LFPy/LFPy.git@mpi_optional',
3433
]
3534

3635
setuptools.setup(

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ envdir =
1515
py27{-unit,-functional,-style,-syntax}: {toxworkdir}/py27
1616
py3{5,6,7,8,9,10,}{-unit,-functional,-style,-syntax}: {toxworkdir}/py3
1717
docs: {toxworkdir}/docs
18+
extras = lfpy
1819
deps =
1920
coverage
2021
flake8
2122
mock
2223
neuron-nightly
23-
git+https://github.com/LFPy/LFPy.git@mpi_optional
2424
sh
2525
pytest-cov
2626
download = true

0 commit comments

Comments
 (0)