diff --git a/spikeinterface/core/baserecording.py b/spikeinterface/core/baserecording.py index 7afd5506a9..82e9cefd91 100644 --- a/spikeinterface/core/baserecording.py +++ b/spikeinterface/core/baserecording.py @@ -1,5 +1,6 @@ from typing import Iterable, List, Union from pathlib import Path +import warnings import numpy as np @@ -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)') diff --git a/spikeinterface/extractors/neoextractors/neobaseextractor.py b/spikeinterface/extractors/neoextractors/neobaseextractor.py index 4d023a45c9..a5b661b001 100644 --- a/spikeinterface/extractors/neoextractors/neobaseextractor.py +++ b/spikeinterface/extractors/neoextractors/neobaseextractor.py @@ -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