Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUpContainer(self):
""" Return the test DecompositionSeries to read/write """
self.timeseries = TimeSeries(name='dummy timeseries', description='desc',
data=np.ones((3, 3)), unit='flibs',
timestamps=np.ones((3,)))
bands = DynamicTable(name='bands', description='band info for LFPSpectralAnalysis', columns=[
VectorData(name='band_name', description='name of bands', data=['alpha', 'beta', 'gamma']),
VectorData(name='band_limits', description='low and high cutoffs in Hz', data=np.ones((3, 2)))
])
spec_anal = DecompositionSeries(name='LFPSpectralAnalysis',
description='my description',
data=np.ones((3, 3, 3)),
timestamps=np.ones((3,)),
source_timeseries=self.timeseries,
metric='amplitude',
bands=bands)
return spec_anal
def setUpContainer(self):
"""
Return placeholder table for electrodes. Tested electrodes are added directly to the NWBFile in addContainer
"""
return DynamicTable('electrodes', 'a placeholder table')
def setUpContainer(self):
# this will get ignored
return DynamicTable('units', 'a placeholder table')
class MotionCorrection(MultiContainerInterface):
"""
A collection of corrected images stacks.
"""
__clsconf__ = {
'add': 'add_corrected_image_stack',
'get': 'get_corrected_image_stack',
'create': 'create_corrected_image_stack',
'type': CorrectedImageStack,
'attr': 'corrected_images_stacks'
}
@register_class('PlaneSegmentation', CORE_NAMESPACE)
class PlaneSegmentation(DynamicTable):
"""
Stores pixels in an image that represent different regions of interest (ROIs)
or masks. All segmentation for a given imaging plane is stored together, with
storage for multiple imaging planes (masks) supported. Each ROI is stored in its
own subgroup, with the ROI group containing both a 2D mask and a list of pixels
that make up this mask. Segments can also be used for masking neuropil. If segmentation
is allowed to change with time, a new imaging plane (or module) is required and
ROI names should remain consistent between them.
"""
__fields__ = ('imaging_plane',
{'name': 'reference_images', 'child': True})
__columns__ = (
{'name': 'image_mask', 'description': 'Image masks for each ROI'},
{'name': 'pixel_mask', 'description': 'Pixel masks for each ROI', 'index': True},
pynwb.misc.DecompositionSeries: misc.show_decomposition_series,
pynwb.file.Subject: base.show_fields,
pynwb.ophys.ImagingPlane: base.show_fields,
pynwb.ecephys.SpikeEventSeries: ecephys.show_spike_event_series,
pynwb.ophys.ImageSegmentation: ophys.show_image_segmentation,
pynwb.ophys.TwoPhotonSeries: ophys.show_two_photon_series,
ndx_grayscalevolume.GrayscaleVolume: ophys.show_grayscale_volume,
pynwb.ophys.PlaneSegmentation: ophys.show_plane_segmentation,
pynwb.ophys.DfOverF: ophys.show_df_over_f,
pynwb.ophys.RoiResponseSeries: ophys.RoiResponseSeriesWidget,
pynwb.misc.AnnotationSeries: OrderedDict({
'text': base.show_text_fields,
'times': misc.show_annotations}),
pynwb.core.LabelledDict: base.dict2accordion,
pynwb.ProcessingModule: base.processing_module,
hdmf.common.DynamicTable: show_dynamic_table,
pynwb.ecephys.ElectricalSeries: ecephys.ElectricalSeriesWidget,
pynwb.behavior.Position: behavior.show_position,
pynwb.behavior.SpatialSeries: OrderedDict({
'over time': timeseries.SeparateTracesPlotlyWidget,
'trace': behavior.plotly_show_spatial_trace}),
pynwb.image.GrayscaleImage: image.show_grayscale_image,
pynwb.image.RGBImage: image.show_rbg_image,
pynwb.image.ImageSeries: image.show_image_series,
pynwb.image.IndexSeries: image.show_index_series,
pynwb.TimeSeries: timeseries.show_timeseries,
pynwb.core.NWBDataInterface: base.show_neurodata_base,
h5py.Dataset: base.show_dset
}
def nwb2widget(node, neurodata_vis_spec=default_neurodata_vis_spec):
def __init__(self, **kwargs):
metric, source_timeseries, bands = popargs('metric', 'source_timeseries', 'bands', kwargs)
super(DecompositionSeries, self).__init__(**kwargs)
self.source_timeseries = source_timeseries
if self.source_timeseries is None:
warnings.warn("It is best practice to set `source_timeseries` if it is present to document "
"where the DecompositionSeries was derived from. (Optional)")
self.metric = metric
if bands is None:
bands = DynamicTable("bands", "data about the frequency bands that the signal was decomposed into")
self.bands = bands
{'name': 'electrode_table', 'type': DynamicTable,
'doc': 'the table that the *electrodes* column indexes', 'default': None},
{'name': 'waveform_rate', 'type': 'float',
'doc': 'Sampling rate of the waveform means', 'default': None},
{'name': 'waveform_unit', 'type': str,
'doc': 'Unit of measurement of the waveform means', 'default': 'volts'},
{'name': 'resolution', 'type': 'float',
'doc': 'The smallest possible difference between two spike times', 'default': None},
)
def __init__(self, **kwargs):
if kwargs.get('description', None) is None:
kwargs['description'] = "data on spiking units"
call_docval_func(super(Units, self).__init__, kwargs)
if 'spike_times' not in self.colnames:
self.__has_spike_times = False
self.__electrode_table = getargs('electrode_table', kwargs)
self.waveform_rate = getargs('waveform_rate', kwargs)
def _tablefunc(table_name, description, columns):
t = DynamicTable(table_name, description)
for c in columns:
if isinstance(c, tuple):
t.add_column(c[0], c[1])
elif isinstance(c, str):
t.add_column(c)
else:
raise ValueError("Elements of 'columns' must be str or tuple")
return t
{'name': 'electrodes', 'type': DynamicTable,
'doc': 'the ElectrodeTable that belongs to this NWBFile', 'default': None},
{'name': 'electrode_groups', 'type': Iterable,
'doc': 'the ElectrodeGroups that belong to this NWBFile', 'default': None},
{'name': 'ic_electrodes', 'type': (list, tuple),
'doc': 'DEPRECATED use icephys_electrodes parameter instead. '
'IntracellularElectrodes that belong to this NWBFile', 'default': None},
{'name': 'sweep_table', 'type': SweepTable,
'doc': 'the SweepTable that belong to this NWBFile', 'default': None},
{'name': 'imaging_planes', 'type': (list, tuple),
'doc': 'ImagingPlanes that belong to this NWBFile', 'default': None},
{'name': 'ogen_sites', 'type': (list, tuple),
'doc': 'OptogeneticStimulusSites that belong to this NWBFile', 'default': None},
{'name': 'devices', 'type': (list, tuple),
'doc': 'Device objects belonging to this NWBFile', 'default': None},
{'name': 'subject', 'type': Subject,
'doc': 'subject metadata', 'default': None},