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


Python Parameters.items方法代码示例

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


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

示例1: spike_detection_from_raw_data

# 需要导入模块: from parameters import Parameters [as 别名]
# 或者: from parameters.Parameters import items [as 别名]
def spike_detection_from_raw_data(basename, DatFileNames, n_ch_dat, Channels_dat,
                                  ChannelGraph, probe, max_spikes):
    """
    Filter, detect, extract from raw data.
    """
    ### Detect spikes. For each detected spike, send it to spike writer, which
    ### writes it to a spk file. List of times is small (memorywise) so we just
    ### store the list and write it later.

    np.savetxt("dat_channels.txt", Channels_dat, fmt="%i")
    
    # Create HDF5 files
    h5s = {}
    h5s_filenames = {}
    for n in ['main', 'waves']:
        filename = basename+'.'+n+'.h5'
        h5s[n] = tables.openFile(filename, 'w')
        h5s_filenames[n] = filename
    for n in ['raw', 'high', 'low']:
        if Parameters['RECORD_'+n.upper()]:
            filename = basename+'.'+n+'.h5'
            h5s[n] = tables.openFile(filename, 'w')
            h5s_filenames[n] = filename
    main_h5 = h5s['main']
    # Shanks groups
    shanks_group = {}
    shank_group = {}
    shank_table = {}
    for k in ['main', 'waves']:
        h5 = h5s[k]
        shanks_group[k] = h5.createGroup('/', 'shanks')
        for i in probe.shanks_set:
            shank_group[k, i] = h5.createGroup(shanks_group[k], 'shank_'+str(i))
    # waveform data for wave file
    for i in probe.shanks_set:
        shank_table['waveforms', i] = h5s['waves'].createTable(
            shank_group['waves', i], 'waveforms',
            waveform_description(len(probe.channel_set[i])))
    # spikedetekt data for main file, and links to waveforms
    for i in probe.shanks_set:
        shank_table['spikedetekt', i] = main_h5.createTable(shank_group['main', i],
            'spikedetekt', shank_description(len(probe.channel_set[i])))
        main_h5.createExternalLink(shank_group['main', i], 'waveforms', 
                                   shank_table['waveforms', i])
    # Metadata
    n_samples = np.array([num_samples(DatFileName, n_ch_dat) for DatFileName in DatFileNames])
    for k, h5 in h5s.items():
        metadata_group = h5.createGroup('/', 'metadata')
        parameters_group = h5.createGroup(metadata_group, 'parameters')
        for k, v in Parameters.items():
            if not k.startswith('_'):
                if isinstance(v, bool):
                    r = int(v)
                elif isinstance(v, (int, float)):
                    r = v
                else:
                    r = repr(v)
                h5.setNodeAttr(parameters_group, k, r)
        h5.setNodeAttr(metadata_group, 'probe', json.dumps(probe.probes))
        h5.createArray(metadata_group, 'datfiles_offsets_samples',
                       np.hstack((0, np.cumsum(n_samples)))[:-1])
    
    ########## MAIN TIME CONSUMING LOOP OF PROGRAM ########################
    for (USpk, Spk, PeakSample,FracPeakSample,
         ChannelMask, FloatChannelMask) in extract_spikes(h5s, basename,
                                                          DatFileNames,
                                                          n_ch_dat,
                                                          Channels_dat,
                                                          ChannelGraph,
                                                          max_spikes,
                                                          ):
        # what shank are we in?
        nzc, = ChannelMask.nonzero()
        internzc = list(set(nzc).intersection(probe.channel_to_shank.keys()))
        if internzc:
            shank = probe.channel_to_shank[internzc[0]]
        else:
            continue
        # write only the channels of this shank
        channel_list = np.array(sorted(list(probe.channel_set[shank])))
        t = shank_table['spikedetekt', shank]
        t.row['time'] = PeakSample
        t.row['float_time'] = FracPeakSample
        t.row['mask_binary'] = ChannelMask[channel_list]
        t.row['mask_float'] = FloatChannelMask[channel_list]
        t.row.append()
        # and the waveforms
        t = shank_table['waveforms', shank]
        t.row['wave'] = Spk[:, channel_list]
        t.row['unfiltered_wave'] = USpk[:, channel_list]
        t.row.append()
        
    for h5 in h5s.values():
        h5.flush()

    # Feature extraction
    for shank in probe.shanks_set:
        X = shank_table['waveforms', shank].cols.wave[:Parameters['PCA_MAXWAVES']]
        if len(X) == 0:
            continue
#.........这里部分代码省略.........
开发者ID:beniamino38,项目名称:spikedetekt,代码行数:103,代码来源:core.py


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