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

Commit d12dd08

Browse files
authored
Merge pull request #33 from alejoe91/small-changes
Small changes
2 parents c192c6a + 1363f71 commit d12dd08

File tree

5 files changed

+50
-19
lines changed

5 files changed

+50
-19
lines changed

bluepyopt/ephys/efeatures.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,15 @@ 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
321+
of this eFeature
322+
threshold (float): spike detection threshold (mV)
322323
comment (str): comment
323-
interp_step(float): interpolation step (ms)
324-
double_settings(dict): dictionary with efel double settings that
324+
interp_step (float): interpolation step (ms)
325+
double_settings (dict): dictionary with efel double settings that
325326
should be set before extracting the features
326-
int_settings(dict): dictionary with efel int settings that
327+
int_settings (dict): dictionary with efel int settings that
327328
should be set before extracting the features
328329
"""
329330

@@ -421,7 +422,6 @@ def calculate_feature(
421422
responses,
422423
raise_warnings=False,
423424
return_waveforms=False,
424-
verbose=False,
425425
):
426426
from .extra_features_utils import calculate_features
427427

@@ -445,21 +445,18 @@ def calculate_feature(
445445
np.diff(response["time"])
446446
):
447447
assert self.fs is not None
448-
if verbose:
449-
print("interpolate")
448+
logger.info("extraFELFeature.calculate_feature: interpolate")
450449
response_interp = _interpolate_response(response, fs=self.fs)
451450
else:
452451
response_interp = response
453452

454453
if self.fcut is not None:
455-
if verbose:
456-
print("filter enabled")
454+
logger.info("extraFELFeature.calculate_feature: enabled")
457455
response_filter = _filter_response(response_interp,
458456
fcut=self.fcut,
459457
filt_type=self.filt_type)
460458
else:
461-
if verbose:
462-
print("filter disabled")
459+
logger.info("extraFELFeature.calculate_feature: filter disabled")
463460
response_filter = response_interp
464461

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

bluepyopt/tests/test_ephys/test_features.py

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

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

bluepyopt/tests/test_ephys/test_stimuli.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def test_LFPySquarePulse_instantiate():
250250

251251
lfpy_sim = ephys.simulators.LFPySimulator()
252252
dummy_cell = dummycells.DummyLFPyCellModel1()
253-
_, lfpycell = dummy_cell.instantiate(sim=lfpy_sim)
253+
_, lfpy_cell = dummy_cell.instantiate(sim=lfpy_sim)
254254

255255
soma_loc = ephys.locations.NrnSeclistCompLocation(
256256
name=None,
@@ -266,8 +266,12 @@ def test_LFPySquarePulse_instantiate():
266266
total_duration=300
267267
)
268268

269-
stim.instantiate(sim=lfpy_sim, lfpy_cell=lfpycell)
270-
lfpy_sim.run(stim.total_duration)
269+
stim.instantiate(sim=lfpy_sim, lfpy_cell=lfpy_cell)
270+
lfpy_sim.run(
271+
lfpy_cell=lfpy_cell,
272+
lfpy_electrode=dummy_cell.lfpy_electrode,
273+
tstop=stim.total_duration
274+
)
271275

272276
stim.destroy(sim=lfpy_sim)
273277
dummy_cell.destroy(sim=lfpy_sim)

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)