0todd0000 / spm1d

One-Dimensional Statistical Parametric Mapping in Python
GNU General Public License v3.0
61 stars 21 forks source link

extending spm1d to more than 1d #70

Closed zof1985 closed 7 years ago

zof1985 commented 7 years ago

Hi Todd,

I'm aware of existing packages (such as the SPM package for Matlab) for the analysis of 2D or 3D data using statistical parametric mapping. However, since I'm used to spm1d in python, I would like to know if there is a quick way to extend its use to more than one dimension. I would like to perform a simple one-sample t-test on a parameter (Z) sampled from a 2d space (X, Y) and I wonder if there is any chance to use spm1d to perform such analysis.

Many thanks, Luca.

0todd0000 commented 7 years ago

Hi Luca,

Non-parametric procedures can be extended relatively easily to 2D and higher-dimensional data. To run the analyses first flatten each nD observation into a vector of length Q, then construct one or more (J x Q) data arrays, where J is the number of observations, then submit the data array(s) to an spm1d.stats.nonparam procedure. The result will appear 1D, but you can unflatten the test statistic vector into its original multi-dimensional shape. Note that the critical test statistic will be accurate, so you can conduct formal hypothesis testing, but the p values will be incorrect because they are based on 1D features like 1D cluster breadth. So as long as your don't require p values for supra-cluster thresholds the procedure will work.

Please note that spm1d's parametric procedures will not work. Parametric probabilities and smoothness (FWHM) estimates are implemented only for 1D data.

There is at least one other Python option that I know of, a package called "NiPY" (nipy.org) with source code here: https://github.com/nipy/nipy Similar to the SPM packages for MATLAB it implements comprehensive functionality for brain image analysis, and it should be possible to run analyses for both 2D and 3D data.

Todd

zof1985 commented 7 years ago

Thank you Todd,

The procedure you described will be very helpful for data interpretation. However I feel that almost any reviewer would like to see p-values... therefore I will have a look at the NiPY package.

Thank you again for your valuable support, Luca.

0todd0000 commented 5 years ago

Preliminary support for 2D data analysis has been added to spm1d! Example 2D analysis (Python) Example 2D analysis (MATLAB)