本文整理汇总了Python中neo.core.Segment.filter方法的典型用法代码示例。如果您正苦于以下问题:Python Segment.filter方法的具体用法?Python Segment.filter怎么用?Python Segment.filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neo.core.Segment
的用法示例。
在下文中一共展示了Segment.filter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_read_nse_data
# 需要导入模块: from neo.core import Segment [as 别名]
# 或者: from neo.core.Segment import filter [as 别名]
def test_read_nse_data(self):
t_start, t_stop = None, None # in samples
nio = NeuralynxIO(self.sn, use_cache='never')
seg = Segment('testsegment')
for el_id, el_dict in nio.parameters_nse.iteritems():
filepath = nio.parameters_nse[el_id]['recording_file_name']
filename = filepath.split('/')[-1].split('\\')[-1].split('.')[0]
nio.read_nse(filename, seg, t_start=t_start, t_stop=t_stop,
waveforms=True)
spiketrain = seg.filter({'electrode_id': el_id},
objects=SpikeTrain)[0]
# target_data = np.zeros((500, 32))
# timestamps = np.zeros(500)
entries = []
with open(self.pd + '/%s.txt' % filename) as datafile:
for i, line in enumerate(datafile):
line = line.strip('\xef\xbb\xbf')
entries.append(line.split())
entries = np.asarray(entries, dtype=float)
target_data = entries[:-1, 11:]
timestamps = entries[:-1, 0]
timestamps = (timestamps * pq.microsecond -
nio.parameters_global['t_start'])
np.testing.assert_array_equal(timestamps.magnitude,
spiketrain.magnitude)
np.testing.assert_array_equal(target_data,
spiketrain.waveforms)
示例2: test_read_nev_data
# 需要导入模块: from neo.core import Segment [as 别名]
# 或者: from neo.core.Segment import filter [as 别名]
def test_read_nev_data(self):
t_start, t_stop = 0 * pq.s, 1000 * pq.s
nio = NeuralynxIO(self.sn, use_cache='never')
seg = Segment('testsegment')
filename = 'Events'
nio.read_nev(filename + '.nev', seg, t_start=t_start, t_stop=t_stop)
timestamps = []
nttls = []
names = []
event_ids = []
with open(self.pd + '/%s.txt' % filename) as datafile:
for i, line in enumerate(datafile):
line = line.strip('\xef\xbb\xbf')
entries = line.split('\t')
nttls.append(int(entries[5]))
timestamps.append(int(entries[3]))
names.append(entries[10].rstrip('\r\n'))
event_ids.append(int(entries[4]))
timestamps = (np.array(timestamps) * pq.microsecond -
nio.parameters_global['t_start'])
# masking only requested spikes
mask = np.where(timestamps < t_stop)[0]
# return if no event fits criteria
if len(mask) == 0:
return
timestamps = timestamps[mask]
nttls = np.asarray(nttls)[mask]
names = np.asarray(names)[mask]
event_ids = np.asarray(event_ids)[mask]
for i in range(len(timestamps)):
events = seg.filter({'nttl': nttls[i]}, objects=Event)
events = [e for e in events
if (e.annotations['marker_id'] == event_ids[i] and
e.labels == names[i])]
self.assertTrue(len(events) == 1)
self.assertTrue(timestamps[i] in events[0].times)
示例3: test_read_ncs_data
# 需要导入模块: from neo.core import Segment [as 别名]
# 或者: from neo.core.Segment import filter [as 别名]
def test_read_ncs_data(self):
t_start, t_stop = 0, 500 * 512 # in samples
nio = NeuralynxIO(self.sn, use_cache='never')
seg = Segment('testsegment')
for el_id, el_dict in nio.parameters_ncs.iteritems():
filepath = nio.parameters_ncs[el_id]['recording_file_name']
filename = filepath.split('/')[-1].split('\\')[-1].split('.')[0]
nio.read_ncs(filename, seg, t_start=t_start, t_stop=t_stop)
anasig = seg.filter({'electrode_id': el_id},
objects=AnalogSignal)[0]
target_data = np.zeros((16679, 512))
with open(self.pd + '/%s.txt' % filename) as datafile:
for i, line in enumerate(datafile):
line = line.strip('\xef\xbb\xbf')
entries = line.split()
target_data[i, :] = np.asarray(entries[4:])
target_data = target_data.reshape((-1, 1)) * el_dict['ADBitVolts']
np.testing.assert_array_equal(target_data[:len(anasig)],
anasig.magnitude)