spikeinterface
spikeinterface copied to clipboard
Recorders with non voltage (non standard) channels and slicing channels
In #761 we move the warnings of non standard units to get_traces
. We achieved this by introducing an extra attribute:
https://github.com/SpikeInterface/spikeinterface/blob/486bc67d364745437ebf1ed90bfdef7fae255c1c/spikeinterface/core/baserecording.py#L109-L116
However, as far as I know this attribute (self.has_non_standards_units
) is not copied when we slice the channels with recorder.slice_channel
which indicates problems. I think that what would happen right now is that the attribute NeoRawIOClass
is not copied either so the sliced recorder with non voltage units will never raise the warning.
Maybe we should handle this with annotations as you already have the machinery in those methods to copy that?
Context: #758, #761 and https://github.com/NeuralEnsemble/python-neo/issues/1133
@h-mayorquin you can extend the copy_metadata
function: https://github.com/SpikeInterface/spikeinterface/blob/master/spikeinterface/core/base.py#L227
I think I would go for an annotation like this '__has_non_standards_units__'
and not an attribute.
@alejoe91 we should probably move this warning to get_traces
to the neobase recording withing the library.
what if you slice ? I think in base it is OK.
Hi suggest adding this to the NeoBaseRecordingExtractor
:
def get_traces(self,
segment_index: Union[int, None] = None,
start_frame: Union[int, None] = None,
end_frame: Union[int, None] = None,
channel_ids: Union[Iterable, None] = None,
order: Union[str, None] = None,
return_scaled=False,
cast_unsigned=False
):
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)
return super().get_traces(segment_index, start_frame, end_frame, channek_ids, order, return_scaled, cast_unsigned)
This would have the same effect without "polluting" the base with NEO related stuff (the BaseRecording doesn't even know neo exists!!!)
ok for me.
except the cascade of if that could be done in one line with and
except the cascade of if that could be done in one line with and
????
All right, so we should:
- Do this in
NeoBaseRecordingExtractor
as @alejoe91 points out, and - Do this with attributes so the copying machinery of slicing works.
Please say if you agree with both and I will take care of it,
@h-mayorquin please go ahead!