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

Mcsh5 offsets and proper scaling in uV for return_scaled #2988

Merged
merged 9 commits into from
Jul 5, 2024
15 changes: 12 additions & 3 deletions src/spikeinterface/extractors/mcsh5extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ def __init__(self, file_path, stream_id=0):
# set gain
self.set_channel_gains(mcs_info["gain"])

# set offsets
self.set_channel_offsets(mcs_info["offset"])

# set other properties
self.set_property("electrode_labels", mcs_info["electrode_labels"])

Expand Down Expand Up @@ -101,7 +104,11 @@ def get_traces(self, start_frame=None, end_frame=None, channel_indices=None):


def openMCSH5File(filename, stream_id):
"""Open an MCS hdf5 file, read and return the recording info."""
"""Open an MCS hdf5 file, read and return the recording info.
Specs can be found online
https://www.multichannelsystems.com/downloads/documentation?page=3
"""

import h5py

rf = h5py.File(filename, "r")
Expand All @@ -122,7 +129,8 @@ def openMCSH5File(filename, stream_id):
Tick = info["Tick"][0] / 1e6
exponent = info["Exponent"][0]
convFact = info["ConversionFactor"][0]
gain = convFact.astype(float) * (10.0**exponent)
gain_uV = 1e6 * (convFact.astype(float) * (10.0**exponent))
offset_uV = -1e6 * (info["ADZero"].astype(float) * (10.0**exponent)) * gain_uV

nRecCh, nFrames = data.shape
channel_ids = [f"Ch{ch}" for ch in info["ChannelID"]]
Expand Down Expand Up @@ -150,8 +158,9 @@ def openMCSH5File(filename, stream_id):
"num_channels": nRecCh,
"channel_ids": channel_ids,
"electrode_labels": electrodeLabels,
"gain": gain,
"gain": gain_uV,
"dtype": dtype,
"offset": offset_uV,
}

return mcs_info
Expand Down