/usr/lib/python2.7/dist-packages/neuroshare/SegmentEntity.py is in python-neuroshare 0.9.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | from Entity import Entity
class SegmentSource(object):
"""Segment sources provide access to the metadata of individual sources
of a :class:`SegmentEntity`"""
def __init__(self, segment, source_id, info):
self._segment = segment
self._source_id = source_id
self._info = info
@property
def segment(self):
return self._segment
@property
def id(self):
return self._source_id
@property
def metadata_raw(self):
return self._info
@property
def min_value(self):
return self._info['MinVal']
@property
def max_value(self):
return self._info['MaxVal']
@property
def resolution(self):
return self._info['Resolution']
@property
def sub_sample_shift(self):
return self._info['SubSampleShift']
@property
def location_x(self):
"""x coordinate [in meters]"""
return self._info['LocationX']
@property
def location_y(self):
"""y coordinate [in meters]"""
return self._info['LocationY']
@property
def location_z(self):
"""z coordinate [in meters]"""
return self._info['LocationZ']
@property
def location_user(self):
"""Additional hardware specific location information"""
return self._info['LocationUser']
@property
def high_freq_corner(self):
return self._info['HighFreqCorner']
@property
def high_freq_order(self):
return self._info['HighFreqOrder']
@property
def high_filter_type(self):
return self._info['HighFilterType']
@property
def low_freq_corner(self):
return self._info['LowFreqCorner']
@property
def low_freq_order(self):
return self._info['LowFreqOrder']
@property
def low_filter_type(self):
return self._info['LowFilterType']
@property
def probe_info(self):
"""Additional information"""
return self._info['ProbeInfo']
class SourcesBag(object):
def __init__(self, segment, infos):
self._infos = infos
self._segment = segment
def __getitem__(self, key):
source_id = int(key)
source_info = self._infos[source_id]
return SegmentSource(self._segment, source_id, source_info)
def __iter__(self):
for x in range(0, len(self._infos)):
yield self[x]
class SegmentEntity(Entity):
"""Segment entities contain cutouts of continuously sampled analog signals from
one or more sources that are usually short in time. Most prominent example are
waveforms of action potentials from one ore more electrodes."""
def __init__(self, nsfile, eid, info):
from copy import copy
self._source_infos = info['SourceInfos']
pure_info = copy(info)
del pure_info['SourceInfos']
super(SegmentEntity, self).__init__(eid, nsfile, pure_info)
@property
def max_sample_count(self):
"""Maximum number of samples in each data item"""
return self._info['MaxSampleCount']
@property
def source_count(self):
"""Number of sources for this segment entity."""
return self._info['SourceCount']
@property
def sources(self):
"""Property that provides access to the metadata of the individual
sources of this entity.
Returns a sequence of objects of type :class:`SegmentSource`.
Metadata properties of a SegmentSource are analogous to the
:class:`AnalogEntity`."""
return SourcesBag(self, self._source_infos)
def get_data(self, index):
"""Retrieve the data at ``index``"""
lib = self.file.library
data = lib._get_segment_data(self, index)
return data
|