@@ -960,46 +960,60 @@ def read_openephys(
960960
961961 info_chain = root .find ("INFO" )
962962 oe_version = parse (info_chain .find ("VERSION" ).text )
963- neuropix_pxi = None
963+ neuropix_pxi_processor = None
964+ onebox_processor = None
964965 for signal_chain in root .findall ("SIGNALCHAIN" ):
965966 for processor in signal_chain :
966967 if "PROCESSOR" == processor .tag :
967968 name = processor .attrib ["name" ]
968969 if "Neuropix-PXI" in name :
969- neuropix_pxi = processor
970+ neuropix_pxi_processor = processor
971+ if "OneBox" in name :
972+ onebox_processor = processor
970973
971- if neuropix_pxi is None :
974+ if neuropix_pxi_processor is None and onebox_processor is None :
972975 if raise_error :
973- raise Exception ("Open Ephys can only be read when the Neuropix-PXI plugin is used" )
976+ raise Exception ("Open Ephys can only be read when the Neuropix-PXI or the " "OneBox plugin is used. " )
974977 return None
975978
976- if "NodeId" in neuropix_pxi .attrib :
977- node_id = neuropix_pxi .attrib ["NodeId" ]
978- elif "nodeId" in neuropix_pxi .attrib :
979- node_id = neuropix_pxi .attrib ["nodeId" ]
979+ if neuropix_pxi_processor is not None :
980+ assert onebox_processor is None , "Only one processor should be present"
981+ processor = neuropix_pxi_processor
982+ neuropix_pxi_version = parse (neuropix_pxi_processor .attrib ["libraryVersion" ])
983+ if neuropix_pxi_version < parse ("0.3.3" ):
984+ if raise_error :
985+ raise Exception ("Electrode locations are available from Neuropix-PXI version 0.3.3" )
986+ return None
987+ if onebox_processor is not None :
988+ assert neuropix_pxi_processor is None , "Only one processor should be present"
989+ processor = onebox_processor
990+
991+ if "NodeId" in processor .attrib :
992+ node_id = processor .attrib ["NodeId" ]
993+ elif "nodeId" in processor .attrib :
994+ node_id = processor .attrib ["nodeId" ]
980995 else :
981996 node_id = None
982- neuropix_pxi_version = parse (neuropix_pxi .attrib ["libraryVersion" ])
983- if neuropix_pxi_version < parse ("0.3.3" ):
984- if raise_error :
985- raise Exception ("Electrode locations are available from Neuropix-PXI version 0.3.3" )
986- return None
987997
988998 # read STREAM fields if present (>=0.6.x)
989- stream_fields = neuropix_pxi .findall ("STREAM" )
999+ stream_fields = processor .findall ("STREAM" )
9901000 if len (stream_fields ) > 0 :
9911001 has_streams = True
9921002 streams = []
1003+ # find probe names (exclude ADC streams)
9931004 for stream_field in stream_fields :
994- streams .append (stream_field .attrib ["name" ])
1005+ stream = stream_field .attrib ["name" ]
1006+ if "ADC" not in stream :
1007+ streams .append (stream )
1008+ # find probe names (exclude ADC streams)
9951009 probe_names_used = np .unique ([stream .split ("-" )[0 ] for stream in streams ])
9961010 else :
9971011 has_streams = False
9981012 probe_names_used = None
9991013
10001014 # for Open Ephys version < 1.0 np_probes is in the EDITOR field.
10011015 # for Open Ephys version >= 1.0 np_probes is in the CUSTOM_PARAMETERS field.
1002- editor = neuropix_pxi .find ("EDITOR" )
1016+ editor = processor .find ("EDITOR" )
10031017 if oe_version < parse ("0.9.0" ):
10041018 np_probes = editor .findall ("NP_PROBE" )
10051019 else :
@@ -1013,12 +1027,11 @@ def read_openephys(
10131027
10141028 # In neuropixel plugin 0.7.0, the option for enabling/disabling probes was added.
10151029 # Make sure we only keep enabled probes.
1016- if neuropix_pxi_version >= parse ("0.7.0" ) and neuropix_pxi_version < parse ("1.0.0dev0" ):
1017- np_probes = [probe for probe in np_probes if probe .attrib ["isEnabled" ] == "1" ]
1018- if len (np_probes ) == 0 :
1019- if raise_error :
1020- raise Exception ("No enabled probes found in settings" )
1021- return None
1030+ np_probes = [probe for probe in np_probes if probe .attrib .get ("isEnabled" , "1" ) == "1" ]
1031+ if len (np_probes ) == 0 :
1032+ if raise_error :
1033+ raise Exception ("No enabled probes found in settings" )
1034+ return None
10221035
10231036 # read probes info
10241037 # If STREAMs are not available, probes are sequentially named based on the node id
0 commit comments