Skip to content

Commit

Permalink
Mcsh5 offsets and proper scaling in uV for return_scaled (#2988)
Browse files Browse the repository at this point in the history
Mcsh5 offsets and proper scaling in uV for return_scaled
  • Loading branch information
yger authored Jul 5, 2024
1 parent f8a4331 commit 0422cfb
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/spikeinterface/extractors/mcsh5extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,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 @@ -100,7 +103,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 @@ -121,7 +128,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 @@ -149,8 +157,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

0 comments on commit 0422cfb

Please sign in to comment.