Skip to content

Commit ea1408e

Browse files
Peter N. SteinmetzPeter N. Steinmetz
authored andcommitted
Neuroscope: fix scale of signals.
Need to multiply not divide by 1000 for mV scale.
1 parent 53f4dcd commit ea1408e

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

neo/rawio/neuroscoperawio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ def _parse_header(self):
9292
for xml_rc in xml_chx:
9393
channel_group[int(xml_rc.text)] = grp_index
9494

95+
sig_dtype = "int16"
9596
if nbits == 16:
96-
sig_dtype = "int16"
97-
gain = voltage_range / (2**16) / amplification / 1000.0
97+
gain = voltage_range * 1000 / (2**nbits) / amplification
9898
# ~ elif nbits==32:
9999
# Not sure if it is int or float
100100
# ~ dt = 'int32'

neo/test/rawiotest/test_neuroscoperawio.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import unittest
21
import logging
2+
import os
33
from pathlib import Path
4+
import unittest
45

56
from neo.rawio.neuroscoperawio import NeuroScopeRawIO
67
from neo.test.rawiotest.common_rawio_test import BaseTestRawIO
@@ -17,6 +18,17 @@ class TestNeuroScopeRawIO(BaseTestRawIO, unittest.TestCase):
1718
"neuroscope/dataset_1/YutaMouse42-151117.eeg",
1819
]
1920

21+
def test_signal_scale(self):
22+
local_test_dir = get_local_testing_data_folder()
23+
fname = os.path.join(local_test_dir, "neuroscope/test1/test1.xml")
24+
reader = NeuroScopeRawIO(filename=fname)
25+
reader.parse_header()
26+
27+
gain = reader.header['signal_channels'][0]['gain']
28+
29+
# scale is in mV = range of recording in volts * 1000 mV/V /(number of bits * ampification)
30+
self.assertAlmostEqual(20.0 * 1000 / (2**16 * 1000), gain)
31+
2032
def test_binary_argument_with_non_canonical_xml_file(self):
2133

2234
local_test_dir = get_local_testing_data_folder()

0 commit comments

Comments
 (0)