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


Python Dataset.a["mapper"]方法代码示例

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


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

示例1: _fill_in_scattered_results

# 需要导入模块: from mvpa2.datasets import Dataset [as 别名]
# 或者: from mvpa2.datasets.Dataset import a["mapper"] [as 别名]
def _fill_in_scattered_results(sl, dataset, roi_ids, results):
    """this requires the searchlight conditional attribute 'roi_feature_ids'
    to be enabled"""
    import numpy as np
    from mvpa2.datasets import Dataset

    resmap = None
    probmap = None
    for resblock in results:
        for res in resblock:
            if resmap is None:
                # prepare the result container
                resmap = np.zeros((len(res), dataset.nfeatures), dtype=res.samples.dtype)
                if "null_prob" in res.fa:
                    # initialize the prob map also with zeroes, as p=0 can never
                    # happen as an empirical result
                    probmap = np.zeros((dataset.nfeatures,) + res.fa.null_prob.shape[1:], dtype=res.samples.dtype)
                observ_counter = np.zeros(dataset.nfeatures, dtype=int)
            # project the result onto all features -- love broadcasting!
            resmap[:, res.a.roi_feature_ids] += res.samples
            if not probmap is None:
                probmap[res.a.roi_feature_ids] += res.fa.null_prob
            # increment observation counter for all relevant features
            observ_counter[res.a.roi_feature_ids] += 1
    # when all results have been added up average them according to the number
    # of observations
    observ_mask = observ_counter > 0
    resmap[:, observ_mask] /= observ_counter[observ_mask]
    result_ds = Dataset(resmap, fa={"observations": observ_counter})
    if not probmap is None:
        # transpose to make broadcasting work -- creates a view, so in-place
        # modification still does the job
        probmap.T[:, observ_mask] /= observ_counter[observ_mask]
        result_ds.fa["null_prob"] = probmap.squeeze()
    if "mapper" in dataset.a:
        import copy

        result_ds.a["mapper"] = copy.copy(dataset.a.mapper)
    return result_ds
开发者ID:neurosbh,项目名称:PyMVPA,代码行数:41,代码来源:cmd_searchlight.py


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