本文整理汇总了Python中neo.io.nestio.NestIO.read_spiketrain方法的典型用法代码示例。如果您正苦于以下问题:Python NestIO.read_spiketrain方法的具体用法?Python NestIO.read_spiketrain怎么用?Python NestIO.read_spiketrain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neo.io.nestio.NestIO
的用法示例。
在下文中一共展示了NestIO.read_spiketrain方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_t_stop_undefined_raises_error
# 需要导入模块: from neo.io.nestio import NestIO [as 别名]
# 或者: from neo.io.nestio.NestIO import read_spiketrain [as 别名]
def test_t_stop_undefined_raises_error(self):
"""
Tests if undefined t_stop, i.e., t_stop=None raises error.
"""
filename = get_test_file_full_path(
ioclass=NestIO,
filename='0gid-1time-1256-0.gdf',
directory=self.local_test_dir, clean=False)
r = NestIO(filenames=filename)
with self.assertRaises(ValueError):
r.read_spiketrain(gdf_id=1, t_start=400. * pq.ms, lazy=False,
id_column=0, time_column=1)
with self.assertRaises(ValueError):
r.read_segment(gid_list=[1, 2, 3], t_start=400. * pq.ms, lazy=False,
id_column_gdf=0, time_column_gdf=1)
示例2: test_read_spiketrain
# 需要导入模块: from neo.io.nestio import NestIO [as 别名]
# 或者: from neo.io.nestio.NestIO import read_spiketrain [as 别名]
def test_read_spiketrain(self):
"""
Tests reading files in the 4 different formats:
- without GIDs, with times as floats
- without GIDs, with times as integers in time steps
- with GIDs, with times as floats
- with GIDs, with times as integers in time steps
"""
filename = get_test_file_full_path(
ioclass=NestIO,
filename='0time-1255-0.gdf',
directory=self.local_test_dir, clean=False)
r = NestIO(filenames=filename)
r.read_spiketrain(t_start=400. * pq.ms, t_stop=500. * pq.ms, lazy=False,
id_column=None, time_column=0)
r.read_segment(t_start=400. * pq.ms, t_stop=500. * pq.ms, lazy=False,
id_column_gdf=None, time_column_gdf=0)
filename = get_test_file_full_path(
ioclass=NestIO,
filename='0time_in_steps-1257-0.gdf',
directory=self.local_test_dir, clean=False)
r = NestIO(filenames=filename)
r.read_spiketrain(t_start=400. * pq.ms, t_stop=500. * pq.ms,
time_unit=pq.CompoundUnit('0.1*ms'), lazy=False,
id_column=None, time_column=0)
r.read_segment(t_start=400. * pq.ms, t_stop=500. * pq.ms,
time_unit=pq.CompoundUnit('0.1*ms'), lazy=False,
id_column_gdf=None, time_column_gdf=0)
filename = get_test_file_full_path(
ioclass=NestIO,
filename='0gid-1time-1256-0.gdf',
directory=self.local_test_dir, clean=False)
r = NestIO(filenames=filename)
r.read_spiketrain(gdf_id=1, t_start=400. * pq.ms, t_stop=500. * pq.ms,
lazy=False, id_column_gdf=0, time_column_gdf=1)
r.read_segment(gid_list=[1], t_start=400. * pq.ms, t_stop=500. * pq.ms,
lazy=False, id_column_gdf=0, time_column_gdf=1)
filename = get_test_file_full_path(
ioclass=NestIO,
filename='0gid-1time_in_steps-1258-0.gdf',
directory=self.local_test_dir, clean=False)
r = NestIO(filenames=filename)
r.read_spiketrain(gdf_id=1, t_start=400. * pq.ms, t_stop=500. * pq.ms,
time_unit=pq.CompoundUnit('0.1*ms'), lazy=False,
id_column=0, time_column=1)
r.read_segment(gid_list=[1], t_start=400. * pq.ms, t_stop=500. * pq.ms,
time_unit=pq.CompoundUnit('0.1*ms'), lazy=False,
id_column_gdf=0, time_column_gdf=1)
示例3: test_read_spiketrain_can_return_empty_spiketrain
# 需要导入模块: from neo.io.nestio import NestIO [as 别名]
# 或者: from neo.io.nestio.NestIO import read_spiketrain [as 别名]
def test_read_spiketrain_can_return_empty_spiketrain(self):
"""
Tests if read_spiketrain returns an empty SpikeTrain if no spikes are in
time range.
"""
filename = get_test_file_full_path(
ioclass=NestIO,
filename='0gid-1time-1256-0.gdf',
directory=self.local_test_dir, clean=False)
r = NestIO(filenames=filename)
st = r.read_spiketrain(gdf_id=0, t_start=400. * pq.ms,
t_stop=1. * pq.ms)
self.assertEqual(st.size, 0)
示例4: test_read_spiketrain_annotates
# 需要导入模块: from neo.io.nestio import NestIO [as 别名]
# 或者: from neo.io.nestio.NestIO import read_spiketrain [as 别名]
def test_read_spiketrain_annotates(self):
"""
Tests if correct annotation is added when reading a spike train.
"""
filename = get_test_file_full_path(
ioclass=NestIO,
filename='0gid-1time-1256-0.gdf',
directory=self.local_test_dir, clean=False)
r = NestIO(filenames=filename)
ID = 7
st = r.read_spiketrain(gdf_id=ID, t_start=400. * pq.ms,
t_stop=500. * pq.ms)
self.assertEqual(ID, st.annotations['id'])
示例5: test_read_integer
# 需要导入模块: from neo.io.nestio import NestIO [as 别名]
# 或者: from neo.io.nestio.NestIO import read_spiketrain [as 别名]
def test_read_integer(self):
"""
Tests if spike times are actually stored as integers if they are stored
in time steps in the file.
"""
filename = get_test_file_full_path(
ioclass=NestIO,
filename='0time_in_steps-1257-0.gdf',
directory=self.local_test_dir, clean=False)
r = NestIO(filenames=filename)
st = r.read_spiketrain(gdf_id=None, t_start=400. * pq.ms,
t_stop=500. * pq.ms,
time_unit=pq.CompoundUnit('0.1*ms'),
lazy=False, id_column=None, time_column=0)
self.assertTrue(st.magnitude.dtype == np.int32)
seg = r.read_segment(gid_list=[None], t_start=400. * pq.ms,
t_stop=500. * pq.ms,
time_unit=pq.CompoundUnit('0.1*ms'),
lazy=False, id_column_gdf=None, time_column_gdf=0)
sts = seg.spiketrains
self.assertTrue(all([st.magnitude.dtype == np.int32 for st in sts]))
filename = get_test_file_full_path(
ioclass=NestIO,
filename='0gid-1time_in_steps-1258-0.gdf',
directory=self.local_test_dir, clean=False)
r = NestIO(
filenames=filename)
st = r.read_spiketrain(gdf_id=1, t_start=400. * pq.ms,
t_stop=500. * pq.ms,
time_unit=pq.CompoundUnit('0.1*ms'),
lazy=False, id_column=0, time_column=1)
self.assertTrue(st.magnitude.dtype == np.int32)
seg = r.read_segment(gid_list=[1], t_start=400. * pq.ms,
t_stop=500. * pq.ms,
time_unit=pq.CompoundUnit('0.1*ms'),
lazy=False, id_column_gdf=0, time_column_gdf=1)
sts = seg.spiketrains
self.assertTrue(all([st.magnitude.dtype == np.int32 for st in sts]))
示例6: test_adding_custom_annotation
# 需要导入模块: from neo.io.nestio import NestIO [as 别名]
# 或者: from neo.io.nestio.NestIO import read_spiketrain [as 别名]
def test_adding_custom_annotation(self):
"""
Tests if custom annotation is correctly added.
"""
filename = get_test_file_full_path(
ioclass=NestIO,
filename='0gid-1time-1256-0.gdf',
directory=self.local_test_dir, clean=False)
r = NestIO(filenames=filename)
st = r.read_spiketrain(gdf_id=0, t_start=400. * pq.ms,
t_stop=500. * pq.ms,
layer='L23', population='I')
self.assertEqual(0, st.annotations.pop('id'))
self.assertEqual('L23', st.annotations.pop('layer'))
self.assertEqual('I', st.annotations.pop('population'))
self.assertEqual({}, st.annotations)
示例7: test_read_float
# 需要导入模块: from neo.io.nestio import NestIO [as 别名]
# 或者: from neo.io.nestio.NestIO import read_spiketrain [as 别名]
def test_read_float(self):
"""
Tests if spike times are stored as floats if they
are stored as floats in the file.
"""
filename = get_test_file_full_path(
ioclass=NestIO,
filename='0gid-1time-1256-0.gdf',
directory=self.local_test_dir, clean=False)
r = NestIO(filenames=filename)
st = r.read_spiketrain(gdf_id=1, t_start=400. * pq.ms,
t_stop=500. * pq.ms,
lazy=False, id_column=0, time_column=1)
self.assertTrue(st.magnitude.dtype == np.float)
seg = r.read_segment(gid_list=[1], t_start=400. * pq.ms,
t_stop=500. * pq.ms,
lazy=False, id_column_gdf=0, time_column_gdf=1)
sts = seg.spiketrains
self.assertTrue(all([s.magnitude.dtype == np.float for s in sts]))
示例8: test_gdf_id_illdefined_raises_error
# 需要导入模块: from neo.io.nestio import NestIO [as 别名]
# 或者: from neo.io.nestio.NestIO import read_spiketrain [as 别名]
def test_gdf_id_illdefined_raises_error(self):
"""
Tests if ill-defined gdf_id in read_spiketrain (i.e., None, list, or
empty list) raises error.
"""
filename = get_test_file_full_path(
ioclass=NestIO,
filename='0gid-1time-1256-0.gdf',
directory=self.local_test_dir, clean=False)
r = NestIO(filenames=filename)
with self.assertRaises(ValueError):
r.read_spiketrain(gdf_id=[], t_start=400. * pq.ms,
t_stop=500. * pq.ms)
with self.assertRaises(ValueError):
r.read_spiketrain(gdf_id=[1], t_start=400. * pq.ms,
t_stop=500. * pq.ms)
with self.assertRaises(ValueError):
r.read_spiketrain(t_start=400. * pq.ms, t_stop=500. * pq.ms)