0todd0000 / spm1d

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

Is spm1d valid for the analysis of 2D data? #183

Closed eleonora-mont closed 2 years ago

eleonora-mont commented 3 years ago

Hi Todd,

I was wondering if you could clarify to me the use of SPM1D to analyse 2D pressure data, in particular the conditions that allow to undertake the SPM1D analysis onto 2D data sets.

Thanks, Eleonora

0todd0000 commented 3 years ago

Hi Eleonora,

Provided:

  1. the data are registered --- i.e., spatially aligned, and
  2. you use nonparametric inference

then yes, using spm1d is valid.

Considering these two issues separately...


  1. Registration

The data must be spatially aligned. Consider this figure which depicts means for two conditions:

means

Notice that the means retain the original foot shapes. If the data were not spatially registered, mean images like that would contain strange looking foot distortions.

2D data registration is not supported in spm1d, so you'd need to register your data elsewhere before using spm1d.


  1. Nonparametric inference

Parametric inference in spm1d is limited to 1D data; these parametric procedures estimate both 1D smoothness and 1D topological features like the Euler characteristic --- which is basically the number of supra-threshold clusters. For parametric analysis of 2D data one would need to implement 2D smoothness estimates and 2D topological feature estimates. These do not exist in spm1d but do exist in other packages including, for example: SPM12

Fortunately, calculating the critical threshold nonparametrically does not require these 2D calculations. For nonparametric inference, the critical threshold is based on the maximum test statistic value across the entire domain, regardless of whether the domain is 1D, 2D or nD. Note that flattening nD data into a 1D vector format does not affecting the maximum statistic value. Nonparametric inference in spm1d works by randomly permuting the observations, and building a numerical distribution of the maximum test statistic value, and it is this distribution from which the critical threshold is calculated, usually as the 95th percentile.

However, spm1d's cluster-level probabilities are NOT valid for 2D data. Calculating cluster-level p values for 2D data requires 2D geometry calculations (e.g. cluster area), and these are not available in spm1d.


A complete working example for 2D analysis is available here: https://spm1d.org/doc/Stats2D/ex2d.html Note that these data are pre-registered, and that only nonparametric inference is used.

eleonora-mont commented 3 years ago

Hi Todd,

Thanks for your clarification and to provide with some example. If the above conditions are satisfied, could you clarify to me the use of random field theory as multiple comparison correction technique? Does it depends on the type of data (1D,2D etc) or, by satisfying the above condition, the production of different corrections is interchangeable to nD data sets?

Thanks again,

Eleonora

0todd0000 commented 3 years ago

As a brief preface to my response below: Note that RFT corrections are parametric procedures, and thus that they not are directly relevant to the discussion above regarding nonparametric inference. Nevertheless, the nonparametric procedures in spm1d can be regarded as RFT-like procedures which do not require normally distributed data.

Does it depends on the type of data (1D,2D etc)

If you mean "does the RFT critical threshold depend on data dimensionality", then yes, but only marginally so. If the data are (a) uniformly sampled in nD space and/or if (b) smoothness is uniform across the domain, then the total number of domain points is more important than the domain dimensionality. If the data are not uniformly sampled in nD space then the answer is "yes, the critical threshold can depend heavily on data dimensionality, depending on the degree of sampling and smoothness nonuniformities".

the production of different corrections is interchangeable to nD data sets?

If you mean "is a single RFT correction valid for a given nD dataset, regardless of how one transforms that dataset (e.g., flattening the data into a 1D domain)", then generally, no: this does not hold unless (a) and/or (b) above hold.

eleonora-mont commented 3 years ago

I understand. Thank you very much for clarifying these to me!