@@ -154,6 +154,15 @@ def auto_parse(check_function, obj, result: Optional[InspectorMessage] = None):
154154 return auto_parsed_result
155155
156156
157+ known_location_dict = dict (
158+ nwbfile = "/" ,
159+ subject = "/subject" ,
160+ devices = "/general/devices" ,
161+ electrode_group = "/general/extracellular_ephys/" ,
162+ # TODO: add ophys equivalents
163+ )
164+
165+
157166def parse_location (neurodata_object ) -> str :
158167 """Infer the human-readable path of the object within an NWBFile by tracing its parents."""
159168 if neurodata_object .parent is None :
@@ -165,22 +174,4 @@ def parse_location(neurodata_object) -> str:
165174 for field in neurodata_object .fields .values ():
166175 if isinstance (field , h5py .Dataset ):
167176 return "/" .join (field .parent .name .split ("/" )[:- 1 ]) + "/"
168- try :
169- # General case for nested modules not containing Datasets
170- level = neurodata_object
171- level_names = []
172- while level .parent .name != "root" :
173- level_names .append (level .parent .name )
174- level = level .parent
175- # Determine which field of the NWBFile contains the previous recent level
176- invalid_field_names = ["timestamps_reference_time" , "session_start_time" ]
177- possible_fields = level .parent .fields
178- for field_name in invalid_field_names :
179- if field_name in possible_fields :
180- possible_fields .pop (field_name )
181- for field_name , field in possible_fields .items ():
182- if level .name in field :
183- level_names .append (field_name )
184- return "/" + "/" .join (level_names [::- 1 ]) + "/"
185- except Exception :
186- return ""
177+ return known_location_dict .get (neurodata_object , None )
0 commit comments