How to use the hdmf.utils.get_docval function in hdmf

To help you get started, we’ve selected a few hdmf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NeurodataWithoutBorders / pynwb / tests / unit / test_extension.py View on Github external
def test_load_namespace_with_reftype_attribute_check_autoclass_const(self):
        ns_builder = NWBNamespaceBuilder('Extension for use in my Lab', self.prefix, version='0.1.0')
        test_ds_ext = NWBDatasetSpec(doc='test dataset to add an attr',
                                     name='test_data', shape=(None,),
                                     attributes=[NWBAttributeSpec(name='target_ds',
                                                                  doc='the target the dataset applies to',
                                                                  dtype=RefSpec('TimeSeries', 'object'))],
                                     neurodata_type_def='my_new_type')
        ns_builder.add_spec(self.ext_source, test_ds_ext)
        ns_builder.export(self.ns_path, outdir=self.tempdir)
        type_map = get_type_map(extensions=os.path.join(self.tempdir, self.ns_path))
        my_new_type = type_map.get_container_cls(self.prefix, 'my_new_type')
        docval = None
        for tmp in get_docval(my_new_type.__init__):
            if tmp['name'] == 'target_ds':
                docval = tmp
                break
        self.assertIsNotNone(docval)
        self.assertEqual(docval['type'], TimeSeries)
github NeurodataWithoutBorders / pynwb / tests / unit / test_extension.py View on Github external
def test_load_namespace_with_reftype_attribute_check_autoclass_const(self):
        ns_builder = NWBNamespaceBuilder('Extension for use in my Lab', self.prefix)
        test_ds_ext = NWBDatasetSpec(doc='test dataset to add an attr',
                                     name='test_data', shape=(None,),
                                     attributes=[NWBAttributeSpec(name='target_ds',
                                                                  doc='the target the dataset applies to',
                                                                  dtype=RefSpec('TimeSeries', 'object'))],
                                     neurodata_type_def='my_new_type')
        ns_builder.add_spec(self.ext_source, test_ds_ext)
        ns_builder.export(self.ns_path, outdir=self.tempdir)
        type_map = get_type_map(extensions=os.path.join(self.tempdir, self.ns_path))
        my_new_type = type_map.get_container_cls(self.prefix, 'my_new_type')
        docval = None
        for tmp in get_docval(my_new_type.__init__):
            if tmp['name'] == 'target_ds':
                docval = tmp
                break
        self.assertIsNotNone(docval)
        self.assertEqual(docval['type'], TimeSeries)
github NeurodataWithoutBorders / pynwb / src / pynwb / file.py View on Github external
    @docval(*get_docval(Units.add_column))
    def add_unit_column(self, **kwargs):
        """
        Add a column to the unit table.
        See :py:meth:`~hdmf.common.DynamicTable.add_column` for more details
        """
        self.__check_units()
        call_docval_func(self.units.add_column, kwargs)
github NeurodataWithoutBorders / pynwb / src / pynwb / file.py View on Github external
    @docval(*get_docval(DynamicTable.add_column))
    def add_trial_column(self, **kwargs):
        """
        Add a column to the trial table.
        See :py:meth:`~hdmf.common.DynamicTable.add_column` for more details
        """
        self.__check_trials()
        call_docval_func(self.trials.add_column, kwargs)
github NeurodataWithoutBorders / pynwb / src / pynwb / ecephys.py View on Github external
            *get_docval(ElectricalSeries.__init__, 'electrodes'),  # required
            *get_docval(ElectricalSeries.__init__, 'resolution', 'conversion', 'comments', 'description', 'control',
                        'control_description'))
    def __init__(self, **kwargs):
        name, data, electrodes = popargs('name', 'data', 'electrodes', kwargs)
        timestamps = getargs('timestamps', kwargs)
        if not (isinstance(data, TimeSeries) or isinstance(timestamps, TimeSeries)):
            if not (isinstance(data, DataChunkIterator) or isinstance(timestamps, DataChunkIterator)):
                if len(data) != len(timestamps):
                    raise Exception('Must provide the same number of timestamps and spike events')
            else:
                # TODO: add check when we have DataChunkIterators
                pass
        super(SpikeEventSeries, self).__init__(name, data, electrodes, **kwargs)
github NeurodataWithoutBorders / pynwb / src / pynwb / ecephys.py View on Github external
            *get_docval(TimeSeries.__init__, 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate',
                        'comments', 'description', 'control', 'control_description'))
    def __init__(self, **kwargs):
        name, electrodes, data, channel_conversion = popargs('name', 'electrodes', 'data', 'channel_conversion', kwargs)
        super(ElectricalSeries, self).__init__(name, data, 'volts', **kwargs)
        self.electrodes = electrodes
        self.channel_conversion = channel_conversion
github NeurodataWithoutBorders / pynwb / src / pynwb / image.py View on Github external
            *get_docval(ImageSeries.__init__, 'external_file', 'starting_frame', 'bits_per_pixel',
                        'dimension', 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate', 'comments',
                        'description', 'control', 'control_description'))
    def __init__(self, **kwargs):
        distance, field_of_view, orientation = popargs('distance', 'field_of_view', 'orientation', kwargs)
        super(OpticalSeries, self).__init__(**kwargs)
        self.distance = distance
        self.field_of_view = field_of_view
        self.orientation = orientation
github NeurodataWithoutBorders / pynwb / src / pynwb / ophys.py View on Github external
            *get_docval(ImageSeries.__init__, 'data', 'unit', 'format'),
            {'name': 'field_of_view', 'type': (Iterable, TimeSeries), 'shape': ((2, ), (3, )),
             'doc': 'Width, height and depth of image, or imaged area (meters).', 'default': None},
            {'name': 'pmt_gain', 'type': 'float', 'doc': 'Photomultiplier gain.', 'default': None},
            {'name': 'scan_line_rate', 'type': 'float',
             'doc': 'Lines imaged per second. This is also stored in /general/optophysiology but is kept '
                    'here as it is useful information for analysis, and so good to be stored w/ the actual data.',
             'default': None},
            *get_docval(ImageSeries.__init__, 'external_file', 'starting_frame', 'bits_per_pixel',
                        'dimension', 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate',
                        'comments', 'description', 'control', 'control_description'))
    def __init__(self, **kwargs):
        field_of_view, imaging_plane, pmt_gain, scan_line_rate = popargs(
            'field_of_view', 'imaging_plane', 'pmt_gain', 'scan_line_rate', kwargs)
        call_docval_func(super(TwoPhotonSeries, self).__init__, kwargs)
        self.field_of_view = field_of_view
        self.imaging_plane = imaging_plane
github NeurodataWithoutBorders / pynwb / src / pynwb / ophys.py View on Github external
            *get_docval(ImageSeries.__init__, 'external_file', 'starting_frame', 'bits_per_pixel',
                        'dimension', 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate',
                        'comments', 'description', 'control', 'control_description'))
    def __init__(self, **kwargs):
        field_of_view, imaging_plane, pmt_gain, scan_line_rate = popargs(
            'field_of_view', 'imaging_plane', 'pmt_gain', 'scan_line_rate', kwargs)
        call_docval_func(super(TwoPhotonSeries, self).__init__, kwargs)
        self.field_of_view = field_of_view
        self.imaging_plane = imaging_plane
        self.pmt_gain = pmt_gain
        self.scan_line_rate = scan_line_rate
github NeurodataWithoutBorders / pynwb / src / pynwb / misc.py View on Github external
            *get_docval(TimeSeries.__init__, 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate',
                        'comments', 'description', 'control', 'control_description'))
    def __init__(self, **kwargs):
        name, data, features, feature_units = popargs('name', 'data',
                                                              'features', 'feature_units', kwargs)
        super(AbstractFeatureSeries, self).__init__(name, data, "see 'feature_units'", **kwargs)
        self.features = features
        self.feature_units = feature_units