Skip to content

Instantly share code, notes, and snippets.

@ajtritt
Last active October 12, 2017 21:06
Show Gist options
  • Save ajtritt/17c96025e8cec8d0410055029c3449d5 to your computer and use it in GitHub Desktop.
Save ajtritt/17c96025e8cec8d0410055029c3449d5 to your computer and use it in GitHub Desktop.
get_builder_dt and get_builder_ns for nwb 1.x
def get_builder_ns(self, builder):
return 'core'
def get_builder_dt(self, builder):
attrs = builder.attributes
ndt = attrs.get('neurodata_type')
if ndt == 'Module':
return 'ProcessingModule'
elif ndt == 'TimeSeries':
ancestry = attrs['ancestry']
return ancestry[-1]
elif ndt == 'Interface':
return builder.name
elif ndt == 'Epoch':
return 'Epoch'
else:
parent_ndt = self.get_builder_dt(builder.parent)
if parent_ndt == 'Epoch':
return 'EpochTimeSeries'
elif parent_ndt == 'ImaginePlane' and isinstance(builder, GroupBuilder):
return 'OpticalChannel'
parent_names = {
'extracellular_ephys': 'ElectrodeGroup',
'intracellular_ephys': 'IntracellularElectrodeGroup',
'optophysiology': 'ImagingPlane',
'optogenetics': 'OptogeneticStimulusSite'
}
return parent_names.get(builder.parent.name)
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment