Skip to content

Commit 1eac371

Browse files
committed
update header parsing for stim + update docstring
1 parent 359c7db commit 1eac371

File tree

1 file changed

+36
-34
lines changed

1 file changed

+36
-34
lines changed

neo/rawio/intanrawio.py

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,12 @@ class IntanRawIO(BaseRawIO):
6363
'one-file-per-channel' which have a header file called 'info.rhd' or 'info.rhs' and a series
6464
of binary files with the '.dat' suffix
6565
66-
* The reader can handle three file formats 'header-attached', 'one-file-per-signal' and
67-
'one-file-per-channel'.
68-
69-
* Intan files contain amplifier channels labeled 'A', 'B' 'C' or 'D'
70-
depending on the port in which they were recorded along with the following
66+
* Intan files contain amplifier channels labeled 'A', 'B' 'C' or 'D' for the 512 recorder
67+
or 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' for the 1024 recorder system
68+
depending on the port in which they were recorded along (stored in stream_id '0') with the following
7169
additional streams.
7270
73-
0: 'RHD2000' amplifier channel
71+
0: 'RHD2000 amplifier channel'
7472
1: 'RHD2000 auxiliary input channel',
7573
2: 'RHD2000 supply voltage channel',
7674
3: 'USB board ADC input channel',
@@ -87,9 +85,11 @@ class IntanRawIO(BaseRawIO):
8785
10: 'DC Amplifier channel',
8886
11: 'Stim channel',
8987
90-
* For the "header-attached" and "one-file-per-signal" formats, the structure of the digital input and output channels is
91-
one long vector, which must be post-processed to extract individual digital channel information.
92-
See the intantech website for more information on performing this post-processing.
88+
* We currently implement digital data demultiplexing so that if digital streams are requested they are
89+
returned as arrays of 1s and 0s.
90+
91+
* We also do stim data decoding which returns the stim data as an int16 of appropriate magnitude. Please
92+
use `rescale_signal_raw_to_float` to obtain stim data in amperes.
9393
9494
9595
Examples
@@ -954,31 +954,33 @@ def read_rhs(filename, file_format: str):
954954
memmap_data_dtype["DC Amplifier channel"] = "uint16"
955955

956956
# I can't seem to get stim files to generate for one-file-per-channel
957-
# so let's skip for now and can be given on request
958-
if file_format != "one-file-per-channel":
959-
for chan_info in stream_name_to_channel_info_list["RHS2000 amplifier channel"]:
960-
chan_info_stim = dict(chan_info)
961-
name = chan_info["native_channel_name"]
962-
chan_info_stim["native_channel_name"] = name + "_STIM"
963-
chan_info_stim["sampling_rate"] = sr
964-
# stim channel are complicated because they are coded
965-
# with bits, they do not fit the gain/offset rawio strategy
966-
chan_info_stim["units"] = "A" # Amps
967-
chan_info_stim["gain"] = global_info["stim_step_size"]
968-
chan_info_stim["offset"] = 0.0
969-
chan_info_stim["signal_type"] = 11 # put it in another group
970-
chan_info_stim["dtype"] = "int16"
971-
ordered_channel_info.append(chan_info_stim)
972-
973-
# Note that the data on disk is uint16 but the data is
974-
# then decoded as int16 so the chan_info is int16
975-
memmap_dtype = "uint16"
976-
if file_format == "header-attached":
977-
memmap_data_dtype += [(name + "_STIM", "uint16", BLOCK_SIZE)]
978-
else:
979-
memmap_data_dtype["Stim channel"] = "uint16"
980-
else:
981-
warnings.warn("Stim not implemented for `one-file-per-channel` due to lack of test files")
957+
# so ideally at some point we need test data to confirm this is true
958+
# based on what Heberto and I read in the docs
959+
for chan_info in stream_name_to_channel_info_list["RHS2000 amplifier channel"]:
960+
chan_info_stim = dict(chan_info)
961+
name = chan_info["native_channel_name"]
962+
chan_info_stim["native_channel_name"] = name + "_STIM"
963+
chan_info_stim["sampling_rate"] = sr
964+
# stim channel are complicated because they are coded
965+
# with bits, they do not fit the gain/offset rawio strategy
966+
chan_info_stim["units"] = "A" # Amps
967+
chan_info_stim["gain"] = global_info["stim_step_size"]
968+
chan_info_stim["offset"] = 0.0
969+
chan_info_stim["signal_type"] = 11 # put it in another group
970+
chan_info_stim["dtype"] = "int16" # this change is due to bit decoding see note below
971+
ordered_channel_info.append(chan_info_stim)
972+
# Note that the data on disk is uint16 but the data is
973+
# then decoded as int16 so the chan_info is int16
974+
if file_format == "header-attached":
975+
memmap_data_dtype += [(name + "_STIM", "uint16", BLOCK_SIZE)]
976+
else:
977+
memmap_data_dtype["Stim channel"] = "uint16"
978+
if file_format == "one-file-per-channel":
979+
warning_msg = ("Stim decoding for `one-file-per-channel` is based on a reading of the documention "
980+
"and we would appreciate test data to ensure we've implemented this format "
981+
"appropriately. If you use the stim data please verify it is as you expected "
982+
"and if it is not then open an issue on the python-neo repo")
983+
warnings.warn(warning_msg)
982984

983985
# No supply or aux for rhs files (ie no stream_id 1 and 2)
984986
# We have an error above that requests test files to help if the spec is changed

0 commit comments

Comments
 (0)