Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions spikeinterface/core/baserecording.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Iterable, List, Union
from pathlib import Path
import warnings

import numpy as np

Expand Down Expand Up @@ -103,6 +104,13 @@ def get_traces(self,
assert order in ["C", "F"]
traces = np.asanyarray(traces, order=order)
if return_scaled:
if hasattr(self, "NeoRawIOClass"):
if self.has_non_standard_units:
message = (
f'This extractor based on neo.{self.NeoRawIOClass} has channels with units not in (V, mV, uV)'
)
warnings.warn(message)

if not self.has_scaled_traces():
raise ValueError('This recording do not support return_scaled=True (need gain_to_uV and offset_'
'to_uV properties)')
Expand Down
9 changes: 5 additions & 4 deletions spikeinterface/extractors/neoextractors/neobaseextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ def __init__(self, stream_id=None, all_annotations=False, **neo_kwargs):
offsets = signal_channels['offset']

units = signal_channels['units']
if not np.all(np.isin(units, ['V', 'Volt', 'mV', 'uV'])):
# check that units are V, mV or uV
message = f'This extractor based on neo.{self.NeoRawIOClass} have strange units not in (V, mV, uV) {units}'
warnings.warn(message)

# mark that units are V, mV or uV
self.has_non_standard_units = False
if not np.all(np.isin(units, ['V', 'Volt', 'mV', 'uV'])):
self.has_non_standard_units = True

additional_gain = np.ones(units.size, dtype='float')
additional_gain[units == 'V'] = 1e6
additional_gain[units == 'Volt'] = 1e6
Expand Down