0todd0000 / spm1dmatlab

One-Dimensional Statistical Parametric Mapping in Matlab.
GNU General Public License v3.0
27 stars 13 forks source link

8x16 matrix #77

Closed PatricioUQ closed 6 years ago

PatricioUQ commented 6 years ago

Hi Todd A bunch of basic questions here: We have high density EMG taken with a matrix of 8x16 electrodes. It would be really nice to use spm1 to compare changes in EMG RMS before - after our intervention, to see if there is a topographical shift in the areas with higher EMG RMS (something like you did with the foot pressure?) during an isometric contraction of 2 seconds. We would like also to create heat maps of the muscle in question.

This sounds like 2D – 1D, I am right?

What would be the best approach to use spm1 here?

Thanks for your time and wisdom

PPM

0todd0000 commented 6 years ago

Hi PPM,

This sounds like 2D – 1D, I am right?

Yes, if you use a summary metric across time like RMS. If not, then I think I'd call them "3D-1D", where time is the third dimension of the measurement domain.

What would be the best approach to use spm1 here? Use a multivariate JxQxI, where the vector components (I) are the x,y coordinates of the EMG electrodes?

This might work, but the main problem here is degrees of freedom (DF). As I increases the DF or sample size has to be increased to retain statistical power. Since the I electrodes are arranged in a spatial lattice, it is best to take advantage of that fact and regard the measurement as a single lattice measurement, where I=1. Another way to think of it is like this: Imagine that instead of an 8x6 lattice, you had a higher-density 800x600 lattice that covered precisely the same area. A standard multivariate approach (I=480,000) would require a prohibitively large sample size to test for a given effect. The SPM approach is a mass-univariate approach (I=1), and this allows you to retain statistical power for small sample sizes. Moreover, the 8x6 and 800x600 measurements would yield identical SPM results provided the former's spatial resolution is sufficiently large to avoid signal aliasing (i.e. larger than the Nyquist criterion). That is, SPM results are independent of sampling frequency provided it is sufficiently high.

Just “flatten” the 2D continua like you explain on question

Yes, I think this sounds like the best approach. Just make sure that you use nonparametric inference (spm1d.stats.nonparam). The non-parametric critical threshold is independent of measurement domain dimensionality. However, p value calculations for suprathreshold-clusters will not work using the current procedures in spm1d.stats.nonparam, which support only 1D inference at the moment. It should be possible to hack in some 2D calculations.

Use SMP12? (I am not keen to use SPM12, I am not sure how to input my matrix, since it seems that uses a format for image data)

An excellent idea, but a tough learning curve. SPM12 is immensely powerful, and endlessly useful, but it's not straightforward for use with 1D or 2D data. An expert in SPM12 could probably build an interface to 1D or 2D data in about an hour. Someone unfamiliar with the details of the SPM12 source code, but proficient with both MATLAB and SPM theory, could probably build an interface within a few days. Someone without expertise in MATLAB and/or SPM would require weeks or even months to build a solid, validated interface to SPM12.

Todd

PatricioUQ commented 6 years ago

Hi Todd,

Thank you for your quick answer!

What I understand from your answer and from this post (https://github.com/0todd0000/spm1d/issues/70) is that the statistical threshold for hypothesis testing will be OK, but the exact p values will be no accurate. Is there any way to present these results in a way that reviewers are happy for publication?

What do you mean with “It should be possible to hack in some 2D calculations”? (although with me being the most inexpert person in statistics and programing, it is probably that I am not able to hack it)

What if I calculate something that represents the change in activity of the muscle? (e.g. centre of mass (CoM) of the signal in x and y). In this way, I will end up with two 1D vectors (CoMx and CoMy) vs time, and then use spm1 to hypothesis testing? It is a multivariate approach more appropriate in this case? am I chasing my tail here?

Thanks

PPM (Patricio)

0todd0000 commented 6 years ago

What I understand from your answer and from this post (0todd0000/spm1d#70) is that the statistical threshold for hypothesis testing will be OK,

Yes.

but the exact p values will be no accurate.

Yes, but it's somewhat worse than inaccurate: they will be complete nonsense. The p values are computed based on a geometrical feature of a supra-threshold cluster, like extent as pictured below:

fig_upcrossing

spm1d supports calculation for 1D geometrical features but not 2D or 3D geometrical features. So if you flatten your 2D data into 1D arrays, and then use spm1d to calculate cluster-specific p values, you will be computing geometric features in some weird, warped, flattened 1D space. Those p values will be nonsense and unrelated to the real 2D geometry. To compute sensible p values you'd need to adapt the spm1d inference routines to compute 2D geometrical features instead of 1D geometrical features.

Is there any way to present these results in a way that reviewers are happy for publication?

I think "p < alpha", "p > alpha" is probably fine. You could supplement that with an explanation something like this:

The probability that random 2D fields would produce a 2D test statistic field which reaches the critical threshold is alpha. This is equivalent to the probability of observing one supra-threshold cluster with an infinitesimally small size. Cluster-specific probability values become exponentially smaller as cluster size grows.

This means that the probability of observing a large cluster is extremely small.

What do you mean with “It should be possible to hack in some 2D calculations”?

It means that you'd have to go into the spm1d source code and adjust it for your own purposes. If you're not comfortable (re-)programming then I'd recommend avoiding source code changes.

What if I calculate something that represents the change in activity of the muscle? (e.g. centre of mass (CoM) of the signal in x and y). In this way, I will end up with two 1D vectors (CoMx and CoMy) vs time, and then use spm1 to hypothesis testing? It is a multivariate approach more appropriate in this case? am I chasing my tail here?

Although I can't comment one the appropriateness of reducing the data to a two-component CoM trajectory, if that variable is relevant to your hypothesis then it would certainly be possible to analyze using existing spm1d procedures. And yes, multivariate procedures would be appropriate. The data would be need to be arranged as a (J x Q x I) array, where J is the number of observations, Q is the number of continuum nodes (number of time points in your case), and I is the number of vector components (2 in your case). You could then submit these data to any multivariate procedure in spm1d.

0todd0000 commented 5 years ago

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