@@ -957,46 +957,60 @@ def read_openephys(
957957
958958 info_chain = root .find ("INFO" )
959959 oe_version = parse (info_chain .find ("VERSION" ).text )
960- neuropix_pxi = None
960+ neuropix_pxi_processor = None
961+ onebox_processor = None
961962 for signal_chain in root .findall ("SIGNALCHAIN" ):
962963 for processor in signal_chain :
963964 if "PROCESSOR" == processor .tag :
964965 name = processor .attrib ["name" ]
965966 if "Neuropix-PXI" in name :
966- neuropix_pxi = processor
967+ neuropix_pxi_processor = processor
968+ if "OneBox" in name :
969+ onebox_processor = processor
967970
968- if neuropix_pxi is None :
971+ if neuropix_pxi_processor is None and onebox_processor is None :
969972 if raise_error :
970- raise Exception ("Open Ephys can only be read when the Neuropix-PXI plugin is used" )
973+ raise Exception ("Open Ephys can only be read when the Neuropix-PXI or the " "OneBox plugin is used. " )
971974 return None
972975
973- if "NodeId" in neuropix_pxi .attrib :
974- node_id = neuropix_pxi .attrib ["NodeId" ]
975- elif "nodeId" in neuropix_pxi .attrib :
976- node_id = neuropix_pxi .attrib ["nodeId" ]
976+ if neuropix_pxi_processor is not None :
977+ assert onebox_processor is None , "Only one processor should be present"
978+ processor = neuropix_pxi_processor
979+ neuropix_pxi_version = parse (neuropix_pxi_processor .attrib ["libraryVersion" ])
980+ if neuropix_pxi_version < parse ("0.3.3" ):
981+ if raise_error :
982+ raise Exception ("Electrode locations are available from Neuropix-PXI version 0.3.3" )
983+ return None
984+ if onebox_processor is not None :
985+ assert neuropix_pxi_processor is None , "Only one processor should be present"
986+ processor = onebox_processor
987+
988+ if "NodeId" in processor .attrib :
989+ node_id = processor .attrib ["NodeId" ]
990+ elif "nodeId" in processor .attrib :
991+ node_id = processor .attrib ["nodeId" ]
977992 else :
978993 node_id = None
979- neuropix_pxi_version = parse (neuropix_pxi .attrib ["libraryVersion" ])
980- if neuropix_pxi_version < parse ("0.3.3" ):
981- if raise_error :
982- raise Exception ("Electrode locations are available from Neuropix-PXI version 0.3.3" )
983- return None
984994
985995 # read STREAM fields if present (>=0.6.x)
986- stream_fields = neuropix_pxi .findall ("STREAM" )
996+ stream_fields = processor .findall ("STREAM" )
987997 if len (stream_fields ) > 0 :
988998 has_streams = True
989999 streams = []
1000+ # find probe names (exclude ADC streams)
9901001 for stream_field in stream_fields :
991- streams .append (stream_field .attrib ["name" ])
1002+ stream_name = stream_field .attrib ["name" ]
1003+ if "ADC" not in stream_name :
1004+ streams .append (stream_name )
1005+ # find probe names (exclude ADC streams)
9921006 probe_names_used = np .unique ([stream .split ("-" )[0 ] for stream in streams ])
9931007 else :
9941008 has_streams = False
9951009 probe_names_used = None
9961010
9971011 # for Open Ephys version < 1.0 np_probes is in the EDITOR field.
9981012 # for Open Ephys version >= 1.0 np_probes is in the CUSTOM_PARAMETERS field.
999- editor = neuropix_pxi .find ("EDITOR" )
1013+ editor = processor .find ("EDITOR" )
10001014 if oe_version < parse ("0.9.0" ):
10011015 np_probes = editor .findall ("NP_PROBE" )
10021016 else :
@@ -1010,12 +1024,11 @@ def read_openephys(
10101024
10111025 # In neuropixel plugin 0.7.0, the option for enabling/disabling probes was added.
10121026 # Make sure we only keep enabled probes.
1013- if neuropix_pxi_version >= parse ("0.7.0" ) and neuropix_pxi_version < parse ("1.0.0dev0" ):
1014- np_probes = [probe for probe in np_probes if probe .attrib ["isEnabled" ] == "1" ]
1015- if len (np_probes ) == 0 :
1016- if raise_error :
1017- raise Exception ("No enabled probes found in settings" )
1018- return None
1027+ np_probes = [probe for probe in np_probes if probe .attrib .get ("isEnabled" , "1" ) == "1" ]
1028+ if len (np_probes ) == 0 :
1029+ if raise_error :
1030+ raise Exception ("No enabled probes found in settings" )
1031+ return None
10191032
10201033 # read probes info
10211034 # If STREAMs are not available, probes are sequentially named based on the node id
0 commit comments