Skip to content

Commit

Permalink
docs: add set_setting example in quickstart and fix issue #366 (#395)
Browse files Browse the repository at this point in the history
* add set_setting example

* remove unnecessary type: ignore
  • Loading branch information
ilkilic authored May 22, 2024
1 parent 18f7723 commit 8957529
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ To get a list with all the available feature names
efel.get_feature_names()
```

To change the spike detection threshold setting (default is -20 mV)

```python
efel.set_setting('Threshold', -30)
```
For a full list of available settings, please refer to the [Setting class](./efel/settings.py)

The python function to extract features is get_feature_values(...).
Below is a short example on how to use this function. The code and example
trace are available
Expand Down Expand Up @@ -205,6 +212,9 @@ def main():
# argument should be a list
traces = [trace1]

# set the threshold for spike detection to -20 mV
efel.set_setting('Threshold', -20)

# Now we pass 'traces' to the efel and ask it to calculate the feature
# values
traces_results = efel.get_feature_values(traces,
Expand Down
6 changes: 3 additions & 3 deletions efel/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def get_distance(

if trace_check:
trace_check_success = get_feature_values(
[trace], ['trace_check'])[0] # type: ignore
[trace], ['trace_check'], None, True, True)[0]

if trace_check_success["trace_check"] is None:
return error_dist
Expand Down Expand Up @@ -401,14 +401,14 @@ def get_mean_feature_values(
parallel_map=None,
return_list=True,
raise_warnings=raise_warnings)
for featureDict in featureDicts: # type: ignore
for featureDict in featureDicts:
for (key, values) in list(featureDict.items()):
if values is None or len(values) == 0:
featureDict[key] = None
else:
featureDict[key] = np.mean(values)

return featureDicts # type: ignore
return featureDicts


def register_feature(feature_function: Callable):
Expand Down
3 changes: 3 additions & 0 deletions examples/basic/basic_example1.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def main():
# argument should be a list
traces = [trace1]

# set the threshold for spike detection to -20 mV
efel.set_setting('Threshold', -20)

# Now we pass 'traces' to the efel and ask it to calculate the feature
# values
traces_results = efel.get_feature_values(traces,
Expand Down

0 comments on commit 8957529

Please sign in to comment.