[pymvpa] zscore clarification and question

Yaroslav Halchenko debian at onerussian.com
Wed Dec 1 15:25:26 UTC 2010


oh, but may be I should have made it clear: after all, zscoring per
volume is very easy to implement in pure Python:

var = ds.samples.std(axis=1)
ds.samples[var!=0] = (ds.samples[var!=0] - ds.samples[var!=0].mean(axis=1)[:, None])/var[var!=0][:, None]

little explanation:
var!=0  -- to avoid division by 0s so we do not get NaNs if some volumes
           manage to get no variance (implausible unless something else is screwed up)
[:, None] -- to add a degenerate second dimension (for features) 
             so broadcasting works across features

On Wed, 01 Dec 2010, Yaroslav Halchenko wrote:

> thank you Jo for kicking my butt for stopping checking my words in the
> code ("Talk is cheap show me your code" L. Torvalds)

> you are perfectly correct and I guess we do not have zscoring per
> volume atm... sorry for causing you to explain it in detail for us.
> Theoretically it should be just "axis" argument to make things clear and
> explicit (will be done in 0.6 I guess):
> 0 - per feature (as now pervoxel=True)
> 1 - per volume
> None - global (as now pervoxel=False)

> added
> https://github.com/PyMVPA/PyMVPA/issues/#issue/35
> so we do not forget ;)
-- 
=------------------------------------------------------------------=
Keep in touch                                     www.onerussian.com
Yaroslav Halchenko                 www.ohloh.net/accounts/yarikoptic



More information about the Pkg-ExpPsy-PyMVPA mailing list