本文整理汇总了Python中mvpa.datasets.base.Dataset.sa['chunks']方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.sa['chunks']方法的具体用法?Python Dataset.sa['chunks']怎么用?Python Dataset.sa['chunks']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mvpa.datasets.base.Dataset
的用法示例。
在下文中一共展示了Dataset.sa['chunks']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_featuregroup_mapper
# 需要导入模块: from mvpa.datasets.base import Dataset [as 别名]
# 或者: from mvpa.datasets.base.Dataset import sa['chunks'] [as 别名]
def test_featuregroup_mapper():
ds = Dataset(np.arange(24).reshape(3,8))
ds.fa['roi'] = [0, 1] * 4
# just to check
ds.sa['chunks'] = np.arange(3)
# correct results
csamples = [[3, 4], [11, 12], [19, 20]]
croi = [0, 1]
cchunks = np.arange(3)
m = mean_group_feature(['roi'])
mds = m.forward(ds)
assert_equal(mds.shape, (3, 2))
assert_array_equal(mds.samples, csamples)
assert_array_equal(mds.fa.roi, np.unique([0, 1] * 4))
# FAs should simply remain the same
assert_array_equal(mds.sa.chunks, np.arange(3))
示例2: test_featuregroup_mapper
# 需要导入模块: from mvpa.datasets.base import Dataset [as 别名]
# 或者: from mvpa.datasets.base.Dataset import sa['chunks'] [as 别名]
def test_featuregroup_mapper():
ds = Dataset(np.arange(24).reshape(3,8))
ds.fa['roi'] = [0, 1] * 4
# just to check
ds.sa['chunks'] = np.arange(3)
# correct results
csamples = [[3, 4], [11, 12], [19, 20]]
croi = [0, 1]
cchunks = np.arange(3)
m = mean_group_feature(['roi'])
mds = m.forward(ds)
assert_equal(mds.shape, (3, 2))
assert_array_equal(mds.samples, csamples)
assert_array_equal(mds.fa.roi, np.unique([0, 1] * 4))
# FAs should simply remain the same
assert_array_equal(mds.sa.chunks, np.arange(3))
# now without grouping
m = mean_feature()
# forwarding just the samples should yield the same result
assert_array_equal(m.forward(ds.samples),
m.forward(ds).samples)
# And when operating on a dataset with >1D samples, then operate
# only across "features", i.e. 1st dimension
ds = Dataset(np.arange(24).reshape(3,2,2,2))
mapped = ds.get_mapped(m)
assert_array_equal(m.forward(ds.samples),
mapped.samples)
assert_array_equal(mapped.samples.shape, (3, 2, 2))
assert_array_equal(mapped.samples, np.mean(ds.samples, axis=1))
# and still could map back? ;) not ATM, so just to ensure consistency
assert_raises(NotImplementedError,
mapped.a.mapper.reverse, mapped.samples)
# but it should also work with standard 2d sample arrays
ds = Dataset(np.arange(24).reshape(3,8))
mapped = ds.get_mapped(m)
assert_array_equal(mapped.samples.shape, (3, 1))