How to use the hdmf.utils.getargs 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 / src / pynwb / file.py View on Github external
def __init__(self, **kwargs):
        kwargs['name'] = 'subject'
        call_docval_func(super(Subject, self).__init__, kwargs)
        self.age = getargs('age', kwargs)
        self.description = getargs('description', kwargs)
        self.genotype = getargs('genotype', kwargs)
        self.sex = getargs('sex', kwargs)
        self.species = getargs('species', kwargs)
        self.subject_id = getargs('subject_id', kwargs)
        self.weight = getargs('weight', kwargs)
        date_of_birth = getargs('date_of_birth', kwargs)
        if date_of_birth and date_of_birth.tzinfo is None:
            self.date_of_birth = _add_missing_timezone(date_of_birth)
        else:
            self.date_of_birth = date_of_birth
github NeurodataWithoutBorders / pynwb / src / pynwb / core.py View on Github external
def get_ancestor(self, **kwargs):
        """
        Traverse parent hierarchy and return first instance of the specified data_type
        """
        neurodata_type = getargs('neurodata_type', kwargs)
        return super().get_ancestor(data_type=neurodata_type)
github NeurodataWithoutBorders / pynwb / src / pynwb / file.py View on Github external
ic_elec_val = kwargs.get('ic_electrodes', None)
            warn("Use of the ic_electrodes parameter is deprecated. "
                 "Use the icephys_electrodes parameter instead", DeprecationWarning)
        setattr(self, 'icephys_electrodes', ic_elec_val)

        experimenter = kwargs.get('experimenter', None)
        if isinstance(experimenter, str):
            experimenter = (experimenter,)
        setattr(self, 'experimenter', experimenter)

        related_pubs = kwargs.get('related_publications', None)
        if isinstance(related_pubs, str):
            related_pubs = (related_pubs,)
        setattr(self, 'related_publications', related_pubs)

        if getargs('source_script', kwargs) is None and getargs('source_script_file_name', kwargs) is not None:
            raise ValueError("'source_script' cannot be None when 'source_script_file_name' is set")

        self.__obj = None
github NeurodataWithoutBorders / pynwb / src / pynwb / core.py View on Github external
def __init__(self, **kwargs):
                    name, data = getargs('name', 'data', kwargs)
                    colnames = [i['name'] for i in columns]
                    super(cls, self).__init__(colnames, name, data)
github NeurodataWithoutBorders / pynwb / src / pynwb / misc.py View on Github external
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)
        self.waveform_unit = getargs('waveform_unit', kwargs)
        self.resolution = getargs('resolution', kwargs)
github NeurodataWithoutBorders / pynwb / src / pynwb / misc.py View on Github external
def get_unit_spike_times(self, **kwargs):
        index, in_interval = getargs('index', 'in_interval', kwargs)
        if type(index) in (list, tuple):
            return [self.get_unit_spike_times(i, in_interval=in_interval) for i in index]
        if in_interval is None:
            return np.asarray(self['spike_times'][index])
        else:
            st = self['spike_times']
            unit_start = 0 if index == 0 else st.data[index - 1]
            unit_stop = st.data[index]
            start_time, stop_time = in_interval

            ind_start = bisect_left(st.target, start_time, unit_start, unit_stop)
            ind_stop = bisect_right(st.target, stop_time, ind_start, unit_stop)

            return np.asarray(st.target[ind_start:ind_stop])
github NeurodataWithoutBorders / pynwb / src / pynwb / core.py View on Github external
def _func(self, **kwargs):
            name = getargs('name', kwargs)
            d = getattr(self, attr_name)
            ret = None
            if name is None:
                if len(d) > 1:
                    msg = "more than one element in %s of %s '%s' -- must specify a name" % \
                          (attr_name, cls.__name__, self.name)
                    raise ValueError(msg)
                elif len(d) == 0:
                    msg = "%s of %s '%s' is empty" % (attr_name, cls.__name__, self.name)
                    raise ValueError(msg)
                elif len(d) == 1:
                    for v in d.values():
                        ret = v
            else:
                ret = d.get(name)
                if ret is None:
github NeurodataWithoutBorders / pynwb / src / pynwb / file.py View on Github external
def get_scratch(self, **kwargs):
        '''Get data from the scratch space'''
        name, convert = getargs('name', 'convert', kwargs)
        ret = self._get_scratch(name)
        if convert:
            if isinstance(ret, DynamicTable):
                ret = ret.to_dataframe()
            elif isinstance(ret, ScratchData):
                ret = np.asarray(ret.data)
        return ret
github NeurodataWithoutBorders / pynwb / src / pynwb / base.py View on Github external
def add_data_interface(self, **kwargs):
        NWBDataInterface = getargs('NWBDataInterface', kwargs)
        warn(PendingDeprecationWarning('add_data_interface will be replaced by add'))
        self.add(NWBDataInterface)