Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update eFEL deprecated functions calls #178

Merged
merged 3 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
Expand Down
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ BluePyEfe: Blue Brain Python E-feature extraction
Introduction
============

BluePyEfe aims at easing the process of reading experimental recordings and extracting
BluePyEfe aims at easing the process of reading experimental recordings and extracting
batches of electrical features from these recordings. To do so, it combines trace reading
functions and features extraction functions from the `eFel library <https://github.com/BlueBrain/eFEL>`_.

Expand All @@ -84,7 +84,7 @@ This software is citable using a `DOI generated by Zenodo <https://zenodo.org/re
Requirements
============

* `Python 3.8+ <https://www.python.org/downloads/release/python-380/>`_
* `Python 3.9+ <https://www.python.org/downloads/release/python-380/>`_
* `eFEL eFeature Extraction Library <https://github.com/BlueBrain/eFEL>`_ (automatically installed by pip)
* `Numpy <http://www.numpy.org>`_ (automatically installed by pip)
* `Scipy <https://www.scipy.org/>`_ (automatically installed by pip)
Expand Down Expand Up @@ -112,7 +112,7 @@ The e-features considered in the present package are the one implemented in the
The present package makes one major assumption: E-features are more meaningful if they are coming from a set of traces rather than a single trace. And they are even more meaningful if these traces come from different cells of the same cellular type.
This assumption dictates the organisation of the package and has several consequences:

The efeatures extracted through the package will always be averaged over the trace considered. For example, the AP_amplitude will be an average over all the action potentials present in a trace. If you wish to work on an AP by AP basis, please consider using the eFEL library directly.
The efeatures extracted through the package will always be averaged over the trace considered. For example, the AP_amplitude will be an average over all the action potentials present in a trace. If you wish to work on an AP by AP basis, please consider using the eFEL library directly.

A large part of the present software is therefore dedicated to averaging the features across set of "equivalent" recordings. To be able to average e-features across different cells in a meaningful way, an equivalence must be established between the traces coming from these different cells. It would not make sense to average the mean firing frequency obtain cell A on a 1s long step protocol with the one obtain for cell B on a ramp protocol that lasts for 500ms. We chose to define recordings as equivalent based on two criteria: (1) They have the same name and (2) they are of the same amplitude when the amplitude is expressed as a percentage of the rheobase of the cell.

Expand All @@ -130,7 +130,7 @@ Each of these steps are parametrized by a number of settings, therefore we recom
Coming from the legacy version
==============================
The legacy version (v0.4*) is moved to the legacy branch.
Changes introduced in v2.0.0 are listed in the `CHANGELOG.rst <CHANGELOG.rst>`_.
Changes introduced in v2.0.0 are listed in the `CHANGELOG.rst <CHANGELOG.rst>`_.
That is the only file you need to look at for the changes as the future changes will also be noted there.

Funding
Expand All @@ -139,10 +139,10 @@ This work has been partially funded by the European Union Seventh Framework Prog


..
The following image is also defined in the index.rst file, as the relative path is
The following image is also defined in the index.rst file, as the relative path is
different, depending from where it is sourced.
The following location is used for the github README
The index.rst location is used for the docs README; index.rst also defined an end-marker,
The index.rst location is used for the docs README; index.rst also defined an end-marker,
to skip content after the marker 'substitutions'.

.. substitutions
Expand Down
3 changes: 2 additions & 1 deletion bluepyefe/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,8 @@ def extract_efeatures(

if efel_settings is None:
logger.warning(
"efel_settings is None. Default settings will be used"
"efel_settings is None. Default settings will be used: " +
str(DEFAULT_EFEL_SETTINGS)
)
efel_settings = DEFAULT_EFEL_SETTINGS.copy()

Expand Down
12 changes: 1 addition & 11 deletions bluepyefe/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,7 @@ def set_efel_settings(efeature_settings):
if setting in ['stim_start', 'stim_end']:
value = float(value)

if setting == 'Threshold':
efel.setThreshold(value)

elif isinstance(value, bool) or isinstance(value, int):
efel.setIntSetting(setting, int(value))

elif isinstance(value, (float, list)):
efel.setDoubleSetting(setting, value)

elif isinstance(value, str):
efel.setStrSetting(setting, value)
efel.set_setting(setting, value)


def dict_to_json(data, path):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"format that can then be used by BluePyOpt for electrical model building "
"purposes.",
packages=setuptools.find_packages(exclude=["tests"]),
python_requires=">=3.8",
python_requires=">=3.9",
include_package_data=True,
author="BlueBrain Project, EPFL",
license="LGPLv3",
Expand Down
13 changes: 12 additions & 1 deletion tests/test_efel_settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""bluepyefe.cell tests"""

import unittest
import pytest

import bluepyefe.cell
import bluepyefe.recording
Expand All @@ -27,7 +28,7 @@ def setUp(self):
)

def test_efel_threshold(self):

self.cell.recordings[0].efeatures = {}

self.cell.extract_efeatures(
Expand Down Expand Up @@ -69,6 +70,16 @@ def test_efel_threshold(self):
recording = self.cell.recordings[0]
self.assertEqual(recording.efeatures["Spikecount"], 0.)

def test_efel_incorrect_threshold(self):

self.cell.recordings[0].efeatures = {}

with pytest.raises(ValueError):
self.cell.extract_efeatures(
protocol_name="IDRest",
efeatures=["Spikecount"],
efel_settings={'Threshold': "40."}
)

if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ minversion = 4

[gh-actions]
python =
3.8: py3
3.9: py3
3.10: py3
3.11: py3
3.12: py3

[testenv]
envdir =
Expand Down
Loading