Skip to content

Commit

Permalink
Merge 6ce7ab5 into 38ffcb8
Browse files Browse the repository at this point in the history
  • Loading branch information
jpgill86 committed Oct 17, 2019
2 parents 38ffcb8 + 6ce7ab5 commit 4151a43
Show file tree
Hide file tree
Showing 7 changed files with 377 additions and 29 deletions.
12 changes: 1 addition & 11 deletions .travis.yml
Expand Up @@ -22,13 +22,8 @@ matrix:
# install dev versions of important packages
- pip install -U \
git+https://github.com/NeuralEnsemble/python-neo.git \
git+https://github.com/NeuralEnsemble/elephant.git \
git+https://github.com/NeuralEnsemble/ephyviewer.git

# remove elephant's strict requirements for neo
# - without this patch, the neurotic CLI script may fail to start
- "sed -i '/^Requires-Dist: neo/d' /home/travis/miniconda/envs/test-environment/lib/python3.7/site-packages/elephant-*.dist-info/METADATA"

# list versions
- python --version
- python -c "import os, sys; assert sys.version_info[:2] == tuple(map(int, os.environ['TRAVIS_PYTHON_VERSION'].split('.')))[:2]"
Expand Down Expand Up @@ -69,12 +64,7 @@ install:

# install package
- echo "INSTALLING NEUROTIC"
# - python setup.py install

# temporary, very dirty workaround for elephant incompatibility with neo 0.8 -- REMOVE LATER
- pip install --no-warn-conflicts . # will write version.py to a temp dir, so manually create it below
- echo version=\'unknown\' > neurotic/version.py
- echo git_revision=\'unknown\' >> neurotic/version.py
- python setup.py install

before_script:
# list versions
Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Expand Up @@ -205,7 +205,6 @@
'python': ('https://docs.python.org/3', None),
'neo': ('https://neo.readthedocs.io/en/latest', None),
'ephyviewer': ('https://ephyviewer.readthedocs.io/en/latest', None),
'elephant': ('https://elephant.readthedocs.io/en/latest', None),
'tridesclous': ('https://tridesclous.readthedocs.io/en/latest', None),
}

Expand Down
16 changes: 7 additions & 9 deletions neurotic/datasets/data.py
Expand Up @@ -10,10 +10,10 @@
import numpy as np
import pandas as pd
import quantities as pq
import elephant
import neo

from ..datasets.metadata import _abs_path
from ..elephant_tools import _butter, _peak_detection

def load_dataset(metadata, lazy=False, signal_group_mode='split-all', filter_events_from_epochs=False):
"""
Expand Down Expand Up @@ -407,8 +407,7 @@ def _create_neo_spike_trains_from_dataframe(dataframe, metadata, t_start, t_stop

def _apply_filters(metadata, blk):
"""
Apply filters specified in ``metadata`` to the signals in ``blk`` using
:func:`elephant.signal_processing.butter`.
Apply filters specified in ``metadata`` to the signals in ``blk``.
"""

if metadata['filters'] is not None:
Expand All @@ -430,7 +429,7 @@ def _apply_filters(metadata, blk):
high *= pq.Hz
if low:
low *= pq.Hz
blk.segments[0].analogsignals[index] = elephant.signal_processing.butter( # may raise a FutureWarning
blk.segments[0].analogsignals[index] = _butter(
signal = blk.segments[0].analogsignals[index],
highpass_freq = high,
lowpass_freq = low,
Expand Down Expand Up @@ -470,9 +469,8 @@ def _run_amplitude_discriminators(metadata, blk):

def _detect_spikes(sig, discriminator, epochs):
"""
Detect spikes in the amplitude window given by ``discriminator`` using
:func:`elephant.spike_train_generation.peak_detection`, and optionally
filter them by coincidence with epochs of a given name.
Detect spikes in the amplitude window given by ``discriminator`` and
optionally filter them by coincidence with epochs of a given name.
"""

assert sig.name == discriminator['channel'], 'sig name "{}" does not match amplitude discriminator channel "{}"'.format(sig.name, discriminator['channel'])
Expand All @@ -486,8 +484,8 @@ def _detect_spikes(sig, discriminator, epochs):
else:
raise ValueError('amplitude discriminator must have two nonnegative thresholds or two nonpositive thresholds: {}'.format(discriminator))

spikes_crossing_min = elephant.spike_train_generation.peak_detection(sig, pq.Quantity(min_threshold, discriminator['units']), sign, 'raw')
spikes_crossing_max = elephant.spike_train_generation.peak_detection(sig, pq.Quantity(max_threshold, discriminator['units']), sign, 'raw')
spikes_crossing_min = _peak_detection(sig, pq.Quantity(min_threshold, discriminator['units']), sign, 'raw')
spikes_crossing_max = _peak_detection(sig, pq.Quantity(max_threshold, discriminator['units']), sign, 'raw')
if sign == 'above':
spikes_between_min_and_max = np.setdiff1d(spikes_crossing_min, spikes_crossing_max)
elif sign == 'below':
Expand Down

0 comments on commit 4151a43

Please sign in to comment.