Skip to content

Commit

Permalink
Allow amplitude discriminators to be specified with arbitrary units
Browse files Browse the repository at this point in the history
Closes #76
  • Loading branch information
jpgill86 committed Jul 26, 2019
1 parent 21d4c1f commit af07bd1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ To use the app, first organize your datasets in a *metadata file* like this
amplitude_discriminators: # used only if fast loading is off (lazy=False)
- name: B3 neuron
channel: BN2
units: uV
amplitude: [50, 100]
# etc
Expand Down
6 changes: 4 additions & 2 deletions docs/metadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,13 @@ for each amplitude discriminator.
- name: Unit 1
channel: Extracellular
amplitude: [50, 150] # uV
units: uV
amplitude: [50, 150]
- name: Unit 2
channel: Extracellular
amplitude: [20, 50] # uV
units: uV
amplitude: [20, 50]
epoch: Unit 2 activity
Here two units are detected on the same channel with different amplitude
Expand Down
1 change: 1 addition & 0 deletions docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ this (see :ref:`config-metadata`):
amplitude_discriminators: # used only if fast loading is off (lazy=False)
- name: B3 neuron
channel: BN2
units: uV
amplitude: [50, 100]
# etc
Expand Down
4 changes: 2 additions & 2 deletions neurotic/datasets/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ def DetectSpikes(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, min_threshold*pq.uV, sign, 'raw')
spikes_crossing_max = elephant.spike_train_generation.peak_detection(sig, max_threshold*pq.uV, sign, 'raw')
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')
if sign == 'above':
spikes_between_min_and_max = np.setdiff1d(spikes_crossing_min, spikes_crossing_max)
elif sign == 'below':
Expand Down
4 changes: 2 additions & 2 deletions neurotic/datasets/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ def _defaults_for_key(key):
# list of labels for epoch encoder
'epoch_encoder_possible_labels': ['Type 1', 'Type 2', 'Type 3'],

# list of dicts giving name, channel, amplitude window, epoch window for each unit
# - e.g. [{'name': 'Unit X', 'channel': 'Channel A', 'amplitude': [75, 150], 'epoch': 'Type 1'}, ...]
# list of dicts giving name, channel, units, amplitude window, epoch window for each unit
# - e.g. [{'name': 'Unit X', 'channel': 'Channel A', 'units': 'uV', 'amplitude': [75, 150], 'epoch': 'Type 1'}, ...]
'amplitude_discriminators': None,

# the output file of a tridesclous spike sorting analysis
Expand Down
9 changes: 6 additions & 3 deletions neurotic/example/metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@ example dataset:

- name: B3
channel: BN2
amplitude: [50, 150] # uV
units: uV
amplitude: [50, 150]

- name: B38
channel: BN2
amplitude: [17, 26] # uV
units: uV
amplitude: [17, 26]
epoch: B38 activity

- name: B4/B5
channel: BN3
amplitude: [85, 200] # uV
units: uV
amplitude: [85, 200]

0 comments on commit af07bd1

Please sign in to comment.