@@ -900,8 +900,17 @@ def read_rhs(filename, file_format: str):
900900 channel_number_dict = {name : len (stream_name_to_channel_info_list [name ]) for name in names_to_count }
901901
902902 # Both DC Amplifier and Stim streams have the same number of channels as the amplifier stream
903+ # if using the `header-attached` or `one-file-per-signal` formats
904+ # the amplifier data is stored in the same place in the header so no matter what the DC amp
905+ # uses the same info as the RHS amp.
903906 channel_number_dict ["DC Amplifier channel" ] = channel_number_dict ["RHS2000 amplifier channel" ]
904- channel_number_dict ["Stim channel" ] = channel_number_dict ["RHS2000 amplifier channel" ]
907+ if file_format != "one-file-per-channel" :
908+ channel_number_dict ["Stim channel" ] = channel_number_dict ["RHS2000 amplifier channel" ]
909+ else :
910+ raw_file_paths_dict = create_one_file_per_channel_dict_rhs (dirname = filename .parent )
911+ channel_number_dict ["Stim channel" ] = len (raw_file_paths_dict ["Stim channel" ])
912+ # but the user can shut off the normal amplifier and only save dc amplifier
913+ channel_number_dict ["RHS2000 amplifier channel" ] = len (raw_file_paths_dict ["RHS2000 amplifier channel" ])
905914
906915 header_size = f .tell ()
907916
@@ -915,24 +924,25 @@ def read_rhs(filename, file_format: str):
915924 memmap_data_dtype ["timestamp" ] = "int32"
916925 channel_number_dict ["timestamp" ] = 1
917926
918- for chan_info in stream_name_to_channel_info_list ["RHS2000 amplifier channel" ]:
919- chan_info ["sampling_rate" ] = sr
920- chan_info ["units" ] = "uV"
921- chan_info ["gain" ] = 0.195
922- if file_format == "header-attached" :
923- chan_info ["offset" ] = - 32768 * 0.195
924- else :
925- chan_info ["offset" ] = 0.0
926- if file_format == "header-attached" :
927- chan_info ["dtype" ] = "uint16"
928- else :
929- chan_info ["dtype" ] = "int16"
930- ordered_channel_info .append (chan_info )
931- if file_format == "header-attached" :
932- name = chan_info ["native_channel_name" ]
933- memmap_data_dtype += [(name , "uint16" , BLOCK_SIZE )]
934- else :
935- memmap_data_dtype ["RHS2000 amplifier channel" ] = "int16"
927+ if file_format != "one-file-per-channel" or channel_number_dict ["RHS2000 amplifier channel" ] > 0 :
928+ for chan_info in stream_name_to_channel_info_list ["RHS2000 amplifier channel" ]:
929+ chan_info ["sampling_rate" ] = sr
930+ chan_info ["units" ] = "uV"
931+ chan_info ["gain" ] = 0.195
932+ if file_format == "header-attached" :
933+ chan_info ["offset" ] = - 32768 * 0.195
934+ else :
935+ chan_info ["offset" ] = 0.0
936+ if file_format == "header-attached" :
937+ chan_info ["dtype" ] = "uint16"
938+ else :
939+ chan_info ["dtype" ] = "int16"
940+ ordered_channel_info .append (chan_info )
941+ if file_format == "header-attached" :
942+ name = chan_info ["native_channel_name" ]
943+ memmap_data_dtype += [(name , "uint16" , BLOCK_SIZE )]
944+ else :
945+ memmap_data_dtype ["RHS2000 amplifier channel" ] = "int16"
936946
937947 if bool (global_info ["dc_amplifier_data_saved" ]):
938948 # if we have dc amp we need to grab the correct number of channels
@@ -957,30 +967,26 @@ def read_rhs(filename, file_format: str):
957967 # so ideally at some point we need test data to confirm this is true
958968 # based on what Heberto and I read in the docs
959969 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 )
970+ # we see which stim were activated
971+ if any ([chan_info ["native_channel_name" ] in stim_file .stem for stim_file in raw_file_paths_dict ['Stim channel' ]]):
972+ chan_info_stim = dict (chan_info )
973+ name = chan_info ["native_channel_name" ]
974+ chan_info_stim ["native_channel_name" ] = name + "_STIM"
975+ chan_info_stim ["sampling_rate" ] = sr
976+ # stim channel are complicated because they are coded
977+ # with bits, they do not fit the gain/offset rawio strategy
978+ chan_info_stim ["units" ] = "A" # Amps
979+ chan_info_stim ["gain" ] = global_info ["stim_step_size" ]
980+ chan_info_stim ["offset" ] = 0.0
981+ chan_info_stim ["signal_type" ] = 11 # put it in another group
982+ chan_info_stim ["dtype" ] = "int16" # this change is due to bit decoding see note below
983+ ordered_channel_info .append (chan_info_stim )
984+ # Note that the data on disk is uint16 but the data is
985+ # then decoded as int16 so the chan_info is int16
986+ if file_format == "header-attached" :
987+ memmap_data_dtype += [(name + "_STIM" , "uint16" , BLOCK_SIZE )]
988+ else :
989+ memmap_data_dtype ["Stim channel" ] = "uint16"
984990
985991 # No supply or aux for rhs files (ie no stream_id 1 and 2)
986992 # We have an error above that requests test files to help if the spec is changed
0 commit comments