0todd0000 / spm1d

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

One sample t test to data with positive and negative values #200

Closed PatricioUQ closed 2 years ago

PatricioUQ commented 2 years ago

Hi Todd,

I have been running some one-sample t (mu=0) test on a waveform that starting from 0, first takes some negative values, then, some positive values (see figure, which represents the mean of the sample). What I want to achieve is to detect the phase with positive values but it seems that the initial negative phase affects the calculations since no suprathreshold cluster appears: If I omit this initial negative phase (let's say running the analysis between bins 30 - 110), the statistical tests start to detect what I need. What do you think should be the appropriate approach to achieve this? Using some kind of RoI? (but defined posteriori?) just run the test without the negative phase and report what I did? changing the data?, or it’s just not possible? (for whatever reason).

Thanks,

PPM Test_fig

0todd0000 commented 2 years ago

This sounds like a threshold detection problem, where the goal is to calculate the point at which the process crosses some critical value (like 1 or 2 for these data). SPM can indeed be used for this type of problem, but as you've noticed the main difficulty is the length of the pre-threshold data. SPM assumes that all data are of empirical interest, and the longer the dataset, the longer the threshold. SPM does not aim to detect a single threshold, it instead aims to test the null hypothesis across the entire 1D domain.

Without more details regarding the motivation for the analysis, it is difficult to know what to suggest, but my suspicion is that a threshold-crossing approach might work better. These methods produce generally stable results, regardless of the length of the pre-threhsold data. One approach is Bayesian modeling of a deviation process. There is an excellent description of this approach in Bayesian Methods for Hackers; see this example for a similar problem.

PatricioUQ commented 2 years ago

Thanks for your answer. I understand your point, Bayesian methods might be the best approach to solve the issue. However, this may be come to put complexity into a methods section that is already complex (and with a limitation in the number of words). Maybe if I give you a bit more of context around the data set that we have, we may end up finding a better way to apply SPM.

I have data of muscle length across time (normalised to a cycle 110 bins) for a series of participants. The aim of this analysis is to detect if the muscle lengthens significantly (and when is lengthening). To make the data more homogeneous (since every participant has a different starting muscle length due to anthropometry), I thought in calculating change in muscle length, so that the start of the cycle is 0. This means that negative numbers are muscle shortening and positive numbers is lengthening. I believe the lengthening is real, because you see it when you plot individual data.

The key may be selecting an appropriate mu for the data in the format of raw muscle length (?), like getting an individual mu for each participant (?). Another issue may be that the lengthening starts at slightly different times of the cycle for each participant (which is interesting by itself), so the start of the lengthening phase is blurred when you plot mean and SD.

Just wondering if we can still use SPM to detect if the muscle lengthening.

Cheers, P

0todd0000 commented 2 years ago

If lengthening is the main variable of interest, how about calculating the time derivative of muscle length? This may more clearly show when the length change is positive vs. negative.

PatricioUQ commented 2 years ago

That's a really good point. Thanks Todd. I think that it will be useful to detect when the muscle starts to lengthen.

What If I wanted to implement an specific mu value for each participant, to check cross-subject differences :

https://github.com/0todd0000/spm1d/issues/53#issuecomment-239775983

I was reading this and makes some sense. Although not sure of how to implement this (or if it is appropriate).

Do you think that does this would make any difference?

0todd0000 commented 2 years ago

That approach would be appropriate provided you have an a priori justification for separate-participant mu values.

PatricioUQ commented 2 years ago

Always a pleasure to talk with you.

Thanks Todd!