Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read gain scaling from .rec header. #1448

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Changes from 1 commit
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
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,
zm711 marked this conversation as resolved.
Show resolved Hide resolved
in which case the units are not handled correctly.
gkBCCN marked this conversation as resolved.
Show resolved Hide resolved

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
Loading