[Neuroimaging] writing a 1D python array to 3D Nifti file

Yaroslav Halchenko lists at onerussian.com
Tue May 10 10:58:01 EDT 2022


On Tue, 10 May 2022, Christophe Pallier wrote:

>    Well there  are scenarios where it totally makes sense to transform to 1D,
>    for example to use some sklearn functions that require vectors.
>    In such cases, I find that nilearn's niftimaskers are a simple tool to go
>    from 3d (or 4d) to 1d (or 2d), and vice versa.

FAIR ENOUGH!  Indeed in those cases -- flattening might be
required and the use of tools for transformations of such kind is
advisable (especially whenever masking is involved).

I guess I just saw way too many unnecessary uses of flattening whenever
data could have been manipulated in their native ND form thanks to
super-powerful broadcasting numpy supports.

Cheers,
-- 
Yaroslav O. Halchenko
Center for Open Neuroscience     http://centerforopenneuroscience.org
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
WWW:   http://www.linkedin.com/in/yarik        



More information about the Neuroimaging mailing list