当前位置: 首页>>代码示例>>Python>>正文


Python Formatter.writeDataWrap方法代码示例

本文整理汇总了Python中Formatter.writeDataWrap方法的典型用法代码示例。如果您正苦于以下问题:Python Formatter.writeDataWrap方法的具体用法?Python Formatter.writeDataWrap怎么用?Python Formatter.writeDataWrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Formatter的用法示例。


在下文中一共展示了Formatter.writeDataWrap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tagAction

# 需要导入模块: import Formatter [as 别名]
# 或者: from Formatter import writeDataWrap [as 别名]
TWO_SECS_DATA_AMOUNT = 2 * DATA_AMOUNT_PER_SEC
THREE_SECS_DATA_AMOUNT = 3 * DATA_AMOUNT_PER_SEC
FIVE_SECS_DATA_AMOUNT = 5 * DATA_AMOUNT_PER_SEC

def tagAction(channels, startTime, endTime, actionInterval, actingDuration):
    doNothing = [[] if channel else None for channel in channels]
    action = copy.deepcopy(doNothing)
    actionDataAmount = int(actingDuration * DATA_AMOUNT_PER_SEC)
    actionIntervalDataAmount = int(actionInterval * DATA_AMOUNT_PER_SEC)
    for dataPtr in xrange(int(startTime * DATA_AMOUNT_PER_SEC) + 1, int(endTime * DATA_AMOUNT_PER_SEC), actionIntervalDataAmount):
        for i, channel in enumerate(channels):
            if channel:
                action[i].extend(channel[dataPtr: dataPtr + actionDataAmount])
                doNothing[i].extend(channel[dataPtr + actionDataAmount: dataPtr + actionIntervalDataAmount])

    return doNothing, action

if __name__ == "__main__":
    channelsWrap = Formatter.format({"step": 1, "wink": 1}, [1, 2, 3, 4])
    winkDoNothing, wink = tagAction(channelsWrap["wink"][0], 10, 101, 5, 1)
    stepDoNothing, leftStep = tagAction(channelsWrap["step"][0], 4.87, 100.87, 5, 0.85)
    stepDoNothing2, rightStep = tagAction(channelsWrap["step"][0], 104.87, 200.87, 5, 0.85)
    channelsWrap.clear()
    channelsWrap["winkdonothing"] = [winkDoNothing]
    channelsWrap["wink"] = [wink]
    channelsWrap["stepdonothing"] = [stepDoNothing]
    channelsWrap["leftstep"] = [leftStep]
    channelsWrap["rightstep"] = [rightStep]
    channelsWrap = Sampler.sampleChannelsWrap(channelsWrap, 2)
    Formatter.writeDataWrap(channelsWrap, 3)
开发者ID:maeglin89273,项目名称:EEG-ML-Classification,代码行数:32,代码来源:Tagger.py

示例2: sampleChannelsStream

# 需要导入模块: import Formatter [as 别名]
# 或者: from Formatter import writeDataWrap [as 别名]
__author__ = 'maeglin89273'

import Formatter

DEFAULT_SAMPLING_RATE = 5


def sampleChannelsStream(channelData, samplingRate):

    sampledData = [[] if channel else None for channel in channelData]

    for (i, channelValues) in enumerate(zip(*filter(lambda channel: bool(channel), channelData))):
        if i % samplingRate == 0:
            for (j, channelNum) in enumerate((num for num in xrange(len(channelData)) if channelData[num])):
                sampledData[channelNum].append(channelValues[j])

    return sampledData


def sampleChannelsWrap(channelsWrap, samplingRate):
    for category in channelsWrap:
        for fileNum, channelData in enumerate(channelsWrap[category]):
            sampledData = sampleChannelsStream(channelData, samplingRate)
            channelsWrap[category][fileNum] = sampledData

    return channelsWrap

if __name__ == "__main__":
    channelsWrap = Formatter.format({"righthand": 4, "sleep": 1}, [1, 2, 3, 4, 8])
    Formatter.writeDataWrap(sampleChannelsWrap(channelsWrap, DEFAULT_SAMPLING_RATE), 2)
开发者ID:maeglin89273,项目名称:EEG-ML-Classification,代码行数:32,代码来源:Sampler.py


注:本文中的Formatter.writeDataWrap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。