Skip to content

Commit 3940b2d

Browse files
authored
Merge pull request #1069 from alejoe91/spikeglx_gains
Fix gains for SpikeGLX
2 parents 2e00c99 + 0cfe62d commit 3940b2d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

neo/rawio/spikeglxrawio.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def scan_files(dirname):
272272
# except for the last fake channel
273273
per_channel_gain = np.ones(num_chan, dtype='float64')
274274
if 'imDatPrb_type' not in meta or meta['imDatPrb_type'] == '0':
275-
# This wirk with NP 1.0 case with different metadata versions
275+
# This work with NP 1.0 case with different metadata versions
276276
# https://github.com/billkarsh/SpikeGLX/blob/gh-pages/Support/Metadata_3A.md#imec
277277
# https://github.com/billkarsh/SpikeGLX/blob/gh-pages/Support/Metadata_3B1.md#imec
278278
# https://github.com/billkarsh/SpikeGLX/blob/gh-pages/Support/Metadata_3B2.md#imec
@@ -284,18 +284,18 @@ def scan_files(dirname):
284284
v = meta['imroTbl'][c].split(' ')[index_imroTbl]
285285
per_channel_gain[c] = 1. / float(v)
286286
gain_factor = float(meta['imAiRangeMax']) / 512
287-
channel_gains = per_channel_gain * gain_factor * 1e6
287+
channel_gains = gain_factor * per_channel_gain * 1e6
288288
elif meta['imDatPrb_type'] in ('21', '24') and signal_kind == 'ap':
289-
# This wirk with NP 2.0 case with different metadata versions
289+
# This work with NP 2.0 case with different metadata versions
290290
# https://github.com/billkarsh/SpikeGLX/blob/gh-pages/Support/Metadata_20.md#channel-entries-by-type
291291
# https://github.com/billkarsh/SpikeGLX/blob/gh-pages/Support/Metadata_20.md#imec
292292
# https://github.com/billkarsh/SpikeGLX/blob/gh-pages/Support/Metadata_30.md#imec
293-
per_channel_gain[:-1] = 80.
293+
per_channel_gain[:-1] = 1 / 80.
294294
gain_factor = float(meta['imAiRangeMax']) / 8192
295-
channel_gains = per_channel_gain * gain_factor * 1e6
295+
channel_gains = gain_factor * per_channel_gain * 1e6
296296
else:
297297
raise NotImplementedError('This meta file version of spikeglx'
298-
'is not implemented')
298+
'is not implemented')
299299
else:
300300
signal_kind = ''
301301
stream_name = device
@@ -305,8 +305,8 @@ def scan_files(dirname):
305305
# there are differents kinds of channels with different gain values
306306
mn, ma, xa, dw = [int(e) for e in meta['snsMnMaXaDw'].split(sep=',')]
307307
per_channel_gain = np.ones(num_chan, dtype='float64')
308-
per_channel_gain[0:mn] = float(meta['niMNGain'])
309-
per_channel_gain[mn:mn + ma] = float(meta['niMAGain'])
308+
per_channel_gain[0:mn] = 1. / float(meta['niMNGain'])
309+
per_channel_gain[mn:mn + ma] = 1. / float(meta['niMAGain'])
310310
# this scaling come from the code in this zip
311311
# https://billkarsh.github.io/SpikeGLX/Support/SpikeGLX_Datafile_Tools.zip
312312
# in file readSGLX.py line76

0 commit comments

Comments
 (0)