Skip to content

Commit

Permalink
Fix issue #1441: Read gain scaling from .rec header.
Browse files Browse the repository at this point in the history
Updates spikegadgetsrawio.py:_parse_header() to read
the channel (ntrode) gain scaling from the header file elements.
  • Loading branch information
gkBCCN committed Mar 28, 2024
1 parent 7c85c8e commit 7d0e575
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions neo/rawio/spikegadgetsrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ def __init__(self, filename="", selected_streams=None):
Notes
-----
This file format has multiple version. New versions include the gain for scaling.
The current implementation does not contain this feature because we don't have
files to test this. So now the gain is "hardcoded" to 1, and so units are
not handled correctly.
This file format has multiple versions:
- Newer versions include the gain for scaling to microvolts [uV].
- If the scaling is not found in the header, it will be "hardcoded" to 1,
in which case the units are not handled correctly.
Examples
--------
Expand Down Expand Up @@ -173,12 +173,17 @@ def _parse_header(self):

chan_ind = 0
for trode in sconf:
if "spikeScalingToUv" in trode.attrib:
gain = float(trode.attrib["spikeScalingToUv"])
units = "uV"
else:
gain = 1 # revert to hardcoded gain
units = ""

for schan in trode:
name = "trode" + trode.attrib["id"] + "chan" + schan.attrib["hwChan"]
chan_id = schan.attrib["hwChan"]
# TODO LATER : handle gain correctly according the file version
units = ""
gain = 1.0

offset = 0.0
signal_channels.append(
(name, chan_id, self._sampling_rate, "int16", units, gain, offset, stream_id)
Expand Down

0 comments on commit 7d0e575

Please sign in to comment.