Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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)
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
def __init__(self, **kwargs):
name, data = getargs('name', 'data', kwargs)
colnames = [i['name'] for i in columns]
super(cls, self).__init__(colnames, name, data)
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)
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])
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:
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
def add_data_interface(self, **kwargs):
NWBDataInterface = getargs('NWBDataInterface', kwargs)
warn(PendingDeprecationWarning('add_data_interface will be replaced by add'))
self.add(NWBDataInterface)