本文整理汇总了Python中neo.core.Block.file_datetime方法的典型用法代码示例。如果您正苦于以下问题:Python Block.file_datetime方法的具体用法?Python Block.file_datetime怎么用?Python Block.file_datetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neo.core.Block
的用法示例。
在下文中一共展示了Block.file_datetime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read_block
# 需要导入模块: from neo.core import Block [as 别名]
# 或者: from neo.core.Block import file_datetime [as 别名]
def read_block(self, **kargs):
if self.filename is not None:
self.axo_obj = axographio.read(self.filename)
# Build up the block
blk = Block()
blk.rec_datetime = None
if self.filename is not None:
# modified time is not ideal but less prone to
# cross-platform issues than created time (ctime)
blk.file_datetime = datetime.fromtimestamp(os.path.getmtime(self.filename))
# store the filename if it is available
blk.file_origin = self.filename
# determine the channel names and counts
_, channel_ordering = np.unique(self.axo_obj.names[1:], return_index=True)
channel_names = np.array(self.axo_obj.names[1:])[np.sort(channel_ordering)]
channel_count = len(channel_names)
# determine the time signal and sample period
sample_period = self.axo_obj.data[0].step * pq.s
start_time = self.axo_obj.data[0].start * pq.s
# Attempt to read units from the channel names
channel_unit_names = [x.split()[-1].strip('()') for x in channel_names]
channel_units = []
for unit in channel_unit_names:
try:
channel_units.append(pq.Quantity(1, unit))
except LookupError:
channel_units.append(None)
# Strip units from channel names
channel_names = [' '.join(x.split()[:-1]) for x in channel_names]
# build up segments by grouping axograph columns
for seg_idx in range(1, len(self.axo_obj.data), channel_count):
seg = Segment(index=seg_idx)
# add in the channels
for chan_idx in range(0, channel_count):
signal = pq.Quantity(
self.axo_obj.data[seg_idx + chan_idx], channel_units[chan_idx])
analog = AnalogSignal(signal,
sampling_period=sample_period, t_start=start_time,
name=channel_names[chan_idx], channel_index=chan_idx)
seg.analogsignals.append(analog)
blk.segments.append(seg)
blk.create_many_to_one_relationship()
return blk