Giter Site home page Giter Site logo

spm1d's Introduction

Python Numpy Scipy License: GPL v3 version

spm1d

One-Dimensional Statistical Parametric Mapping in Python and MATLAB.

spm1d uses Random Field Theory expectations regarding the behavior of smooth, one-dimensional Gaussian fields to make statistical inferences regarding a set of one-dimensional continua.

Software documentation: www.spm1d.org

MATLAB source code: https://github.com/0todd0000/spm1dmatlab

Issues

Please report software bugs or other problems by searching existing issues or creating a new issue here.

License

spm1d is a package for one-dimensional Statistical Parametric Mapping (SPM). spm1d uses random field theory expectations regarding smooth, one-dimensional (random) Gaussian fields to make statistical inferences regarding a set of 1D measurements.

Copyright (C) 2023  Todd Pataky

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

spm1d's People

Contributors

0todd0000 avatar aalhossary avatar jakirkham avatar m-a-robinson avatar mrrezaie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spm1d's Issues

Missing negative critical threshold in figures?

figure_1

My figure shows spm crossing the positive threshold, but it clearly exceeds the same value in the negative side. No thresholds were printed, and clusters were not printed.

 for n in range(0,3):
    post_power_ti0 = post_power_t[n].inference(0.05/3, two_tailed=False, interp=True)
    post_power_ti.append(post_power_ti0)
    print post_power_ti[n].clusters

ax = [0,0,0,0,0,0]
pyplot.close('all')
fig1 = pyplot.figure(figsize=(9,7))
for i in range(3):
    ax[i] = pyplot.subplot(2,3,i+1)
    spm1d.plot.plot_mean_sd(d[1][:,:,i],linecolor='r',facecolor=(1,0.7,0.7), edgecolor='r', label='0%')
    spm1d.plot.plot_mean_sd(d[2][:,:,i],linecolor='b',facecolor=(0.7,0.7,1), edgecolor='b', label='10%') 
    spm1d.plot.plot_mean_sd(d[3][:,:,i],linecolor='g',facecolor=(1.0,0.7,1), edgecolor='g', label='20%')
    pyplot.title(titles[i])
    pyplot.ylabel('JOINT POWER')
    pyplot.xlabel('Stance phase (%)')
    ax[i].axhline()
    #handles, labels = ax[i].get_legend_handles_labels()
    #ax[i].legend(handles, labels)

    ax[i] = pyplot.subplot(2,3,i+4)
    post_power_ti[i].plot()
    post_power_ti[i].plot_threshold_label(fontsize=8)
    post_power_ti[i].plot_p_values(size=6)
    pyplot.title(titles[i+3])
    pyplot.ylabel('SPM{t}')
    pyplot.xlabel('Stance phase (%)')

pyplot.tight_layout()
pyplot.show()

Why is this so Todd?

Many thanks

anova1 with different number of row within group

Hi Todd.

In spm 0.2 , i succeeded to run a spm anova1 with this syntax
spm1d.stats.anova1( (Y1,Y2,Y3), equal_var=False )
in which, Y1, Y2, Y3 had different size.
It doesn t work now with spm 0.3

is it normal ?

Testing assumptions

Hi Todd,

I would ask your help in understanding how to analyse some experimental data using the spm1d package.
Lets say that I have time-series corresponding to the accelerations of a body region in one specific spatial direction. These accelerations have been collected from 20 participants, and each participant performed the same test several times varying some experimental conditions in random order. I wish to look at the portions of the actions performed where the experimental conditions differs from each other. Thus, I thought to use paired t-tests between the experimental conditions pairs that I wish to compare. However, because of the multiple statistical tests performed, I would correct the p values for multiple comparisons using the Bonferroni method (or other approaches). The collected data have been interpolated to 101 points, therefore, for each experimental condition, I have a 10 x 101 matrix. Thus, in order to apply a paired t-test between each combination of experimental conditions, should I check the homogeneity of variance and the normality of the distribution for each column of these matrices?
I'm not a statistician, thus I would know if this procedure could be valid and, if not, could you be so kind to provide me another viable approach for the analysis of these data?

Many thanks,
Luca.

Choice of multivariate vs repeated measures

Dear Todd,

Sorry I have been opening up to many issues, but I am actively using SPM for myself and other studies too, so they have been posing interesting questions. The issue is not SPM per se, but may be more pertinent with spm1d. The data I have that we are interested in has 6 dependent variables: 1) hip angle (xyz) and knee angle (xyz). This was a single group repeated measures on two factors: 1) speed (3,6) and 2) tape (1,2,3).

The choice I am deciding between is 1) do 2wayRM anova on each of 6 dependent variables, or 2) do a hotelling paired t test on each hip and knee vector, for each pair wise factor comparison.

What should my decision be based on? My initial thinking was to choose the one that will require least repeated stats testing. But I am interested in how tape influences the covariation of hip angles in three planes. Any advice??

Regards,
Bernard

Graphs in two way repeated measures anova

figure_1

Hello Todd,

With respect to the "heat map" (think this is what it is called?) produced by the two way repeated measure code, how do we interpret it? In addition, can we produce a typical spm{F} curve similar to that in simpler spm tests.

Regards,
Bernard

Difference in results between spm1d.stats.regress and spm1d.stats.ttest_paired

Dear Todd,

I am currently doing post hoc analysis using CCA and hotelling's paired ttest, using .regress and ttest_paired, respectively. I performed both using the same data, with slightly different means.

I have a vector of three components. I have three load (0,10,20) and three speed (3,4,5) combinations. For the CCA and post hoc, I wanted to answer "what is the effect of incremental load on the vector and if significant its components'. So I essentially analysed the load, independent of speed.

For the hotelling's I also wanted to answer "what is the effect of incremental load on the vector and if significant its components'. However, this time I performed one hotelling test per speed e.g. (3_0 vs 3_20), ... (5_0 vs 5_20).. If significant than I performed a paired ttest. Can I ask why this test seem to have greater power than the .regress in detecting significance for the vector's components?

Many thanks
Bernard

no module found

dear todd
spm1d module not found if i follow the installation guidelines.
Same result, if i add the spm1d dir to my pythonpath.
Generally, that's run.
for more information, i am on Xp with python 2.7 and i usually use Spyder through Anaconda Suite.
Regards

Fabien

Two-way mixed ANOVA or linear mixed model possible with SPM1D ?

Hi Todd,

I am successfully analyzing EMG and kinematical signals with SPM1d (Spyder 2.3.4/ Python 2.7) and two-way ANOVAs (factor “group” 2 levels and factor “speed” 3 levels). I therefore use only one cycle per subject (no repeated measures).

However, I would like to perform a more thorough analysis and take into account every recorded cycle for every subject, so add a random variable “subject” into the analysis.

Furthermore, if possible, I would like to take into account the factor “speed” as a continuous variable and not as a categorical variable.

In conclusion I would like to know if a linear mixed model is possible with SPM1D, or at least a two-way mixed ANOVA (if I keep the factor “speed” as a categorical variable)… I have seen the “repeated measures ANOVA” issue opened on 6 August 2014, and I was wondering if any updates were available since.

Thanks!
Best regards,
Aurelie

error in example : ex_anova1_posthoc.py

hi

i have notice a small error in ex_anova1_posthoc.py.

you have to replace the line
Y0,Y1,Y2 = [Y[A==u] for u in np.unique(A)]
by
Y1,Y2,Y3 = [Y[A==u] for u in np.unique(A)]

regards

fabien

Random effects analysis (unable to print examples) question

Dear Todd,

I am helping someone to perform SPM on their dataset, and couldn't really see the figures on the spm1d's section on random effects. In addition, the link to the codes does not seem to be present in my spm1d folder. I hope you can assist with the following.

Experiment: Two groups (typical (T) and non typical (NT) children) repeated measures (jog, run, sprint) running lab study. Each group has 15 children. Speed was not fixed but was categorically classified as above. So I would have within subject variation in their self-determined speed, within group (between subject) variation in their self determined speed, and between group variation.

Research Qn: How does speed influence running joint power? Is the effect of speed on joint power different from NT kids compared to T?

Analysis:

  1. Do a regression for each subject (all 30) on the effects of speed on the DV, to get a beta value
  2. Compile the beta values for each group (2 sets of 15) e.g. BetaT and Beta NT
  3. Do a two sample t test between betaT and betaNT

Dilemma: My proposed steps do not seem to account within group variation. We think that especially in the NT kids, between subject variability may significant.

Your views are very much appreciated.

Regards,
Bernard

How to calculate Power for SPM tests

First I'd like to thank you for the v0.3 update. It is greatly appreciated to have access to more tests as a matlab user.

I was just wondering how, if possible, to calculate the power of these different tests? I don't see anything in the provided scripts. If there are no provided power calculations, how correct (or wrong) is it to use the traditional way of taking a discrete time point, finding the effect size at that point and use the critical t and sample size to calculate power. I assume there are issues with this since the critical t is calculated with RFT...

Any help would be greatly appreciated!

-Kenneth

RFX analysis

Dear Todd,

I am wanting to ask some help on RFT analysis.

Study. I have 32 participants [17 normal and 15 hypermobile kids], doing a cut task at their self selected speed. We wanted to use RFT rather than a standard two sample T test or even a hotelling’s, as each subject speed was self selected. This means there is intertrial and inter subject variation. In addition to speed, although cut angle was prescribed at 45 deg, we found significant variation away from that. Hence, there is inter-trial and inter-subject variation in angle.

My RFT analysis on knee X moment did not produce significance at a level two analysis. But when I used a normal 2 way t test, there was.

I tried both random effect of speed (ie x= SPEED) and ang (ie x = ANG)

Qn: I first like to know if my codes are right. Second, I was wondering what accounts for the difference between random and non-random effects analysis. I always thought random effects analysis are more powerful.

I will follow this up with an email with data attached.

Many thanks for your help.

Regards,
Bernard

explanation on anova posthoc test

Dear Todd

Your library is awesome .
I would like you to confirm me this point.

  1. If I look your article : Vector field statistical analysis of kinematic and force trajectories" in JoB, epecially section 3.2 dedicated to muscles forces.
    You found a significant effect over the entire cycle ( figure 7), because you hypothesize ALL muscle forces were similar ? this result seems to me obvious.
    After post-hoc, you focused on the difference with control. Then you found less significant regions. only the medgastroc was significant.

  2. Now imagine this case, your anova will show a significant region during the swing phase only. But after post-hoc, you will also find a small significant region during the stance phase.
    should i interpret this former region ?

regards

Fabien

The Neptune 1999 example

Hi,

I am not usually a Python user, but I manage to run your python Neptune example.
However, I got the following result
print T2.inference(0.05)
SPM{T2} inference field
SPM.z : (1x101) raw test stat field
SPM.df : (3.0, 7.0)
SPM.fwhm : 19.28245
SPM.resels : (1, 5.18606)
Inference:
SPM.alpha : 0.050
SPM.zstar : 106.09209
SPM.h0reject : False
SPM.p_set : 1.000
SPM.p_cluster : ()

The critical threshold is 106 which is not quite the 30 I was expecting. Can you tell me what's wrong?

P values and effect sizes

Hi Todd,

Just had a couple of questions:

  1. Is it possible to return a p-value for a test statistic (e.g. F in repeated measures ANOVA) where there are no clusters? I only ask because generally speaking, I would prefer to report the actual p value wherever possible e.g. p=0.58 vs p >= 0.05. Is that possible?
  2. What is the best way to go about returning/reporting an effect size? Obviously, the SPM graphs show the test statistic across the waveform, but from a publication standpoint, these SPM graphs may be moved to supplementary material, and I would like to include some measure of the effect magnitude (in some way) within the main manuscript. I have thought of the following options:

a) Take the peak F or T statistic for a given cluster
b) Take the average F or T statistics for a given cluster
c) Report the F or T range (the lower end being the critical threshold, upper end being the peak)
d) Compute a paired Cohen's d (for my post-hoc paired t-tests) for each node across the waveform, and then take either the peak, average, or range (within the suprathreshold cluster period) as described previously.

Is there any particular method you see as the most valid and/or acceptable?

Cheers,
Nirav

Difference in results between spm1d.stats.regress and spm1d.stats.ttest_paired

Dear Todd,

I am currently doing post hoc analysis using CCA and hotelling's paired ttest, using .regress and ttest_paired, respectively. I performed both using the same data, with slightly different means.

I have a vector of three components. I have three load (0,10,20) and three speed (3,4,5) combinations. For the CCA and post hoc, I wanted to answer "what is the effect of incremental load on the vector and if significant its components'. So I essentially analysed the load, independent of speed.

For the hotelling's I also wanted to answer "what is the effect of incremental load on the vector and if significant its components'. However, this time I performed one hotelling test per speed e.g. (3_0 vs 3_20), ... (5_0 vs 5_20).. If significant than I performed a paired ttest. Can I ask why this test seem to have greater power than the .regress in detecting significance for the vector's components?

Many thanks
Bernard

matplot

Dear Todd,

I have tried to copy some aspect of plotting from your example but couldn't get it to work as nicely as it should. Essentially, I wish to 1) add a legend which shows the label of a colored line e.g. red line = run; 2) Have an arrow that points to a significant cluster showing the p-value

My code is this (this is a loop):

ax = [0,0,0,0,0,0]
pyplot.close('all')
fig1 = pyplot.figure(figsize=(7,4))
for i in range(3):
ax[i] = pyplot.subplot(2,3,i+1)
spm1d_02.plot.plot_mean_sd(hip0[ang[i]],linecolor='k') #model 1(Cluster)
spm1d_02.plot.plot_mean_sd(hip1[ang[i]],linecolor='b') #model 2(CUWA)
pyplot.title(titles[i])
pyplot.ylabel('Angle')
pyplot.ylim([-20,40])
ax[i].axhline()
ax[i] = pyplot.subplot(2,3,i+4)
hip_ti[i].plot()
hip_ti[i].plot_threshold_label(fontsize=10)
pyplot.ylabel('SPM{t}')
pyplot.ylim([-8,8])
pyplot.tight_layout()
pyplot.show()

I tried to add "ax.legend( loc='lower left', fontsize=9 )" for the legend, but it wouldn't pop out.

Looking forward to your input.

Bernard

RuntimeWarning: invalid value encountered in double_scalars

The error described below is copied from issue #19 as a separate issue.

Another notice: When I ran the old anova2RM code on another dataset, laid out in same format, albeit on a subset of the original population, this came up...

C:\Users\14342453\AppData\Local\Enthought\Canopy\User\lib\site-packages\spm1d\stats\anova\solvers.py:117: RuntimeWarning: divide by zero encountered in divide
MS,MSE = (SS/df), (SSE/dfE)
C:\Users\14342453\AppData\Local\Enthought\Canopy\User\lib\site-packages\scipy\stats_distn_infrastructure.py:767: RuntimeWarning: invalid value encountered in greater
cond = logical_and(cond, (asarray(arg) > 0))
C:\Users\14342453\AppData\Local\Enthought\Canopy\User\lib\site-packages\rft1d\prob.py:69: RuntimeWarning: invalid value encountered in double_scalars
p = Q * (pn)
C:\Users\14342453\AppData\Local\Enthought\Canopy\User\lib\site-packages\rft1d\prob.py:352: RuntimeWarning: invalid value encountered in double_scalars
fn = lambda x : (rft(1, 0, STAT, x[0], df, resels, n, Q, False, version)[0] - aaa)2
C:\Users\14342453\AppData\Local\Enthought\Canopy\User\lib\site-packages\scipy\optimize\optimize.py:460: RuntimeWarning: invalid value encountered in absolute
if (numpy.max(numpy.ravel(numpy.abs(sim[1:] - sim[0]))) <= xtol and
C:\Users\14342453\AppData\Local\Enthought\Canopy\User\lib\site-packages\rft1d\geom.py:475: RuntimeWarning: invalid value encountered in greater_equal
L,n = bwlabel(y >= u, merge_wrapped=wrap)

spm1d FWHM

Hello,

I am Bernard, a PhD student from Curtin, (Western Australia). I am new to python, programming and spm in general and need further help in understanding spm1d. The documentation at spm1d.org and papers on spm mentions smoothing a 1d curve. I would like to know what 'cut-off' is used to smooth the curve? Essentially, what determines the cut-off value?

Regards,
Bernard

anova significant but not post-Hoc

Hi
this figure despicts my problem.
spm anaova and posthoc test
i have just carried out a spm one-way anova with 3 indepedant variables (TD,PL,HL)
The Ftest indicated a significant difference at frames 80 to 90 but not the posthoc test. are posthoc comparison too conservative of H0 hypothesis ? is the reason ?

regards

Fabien

Post-hoc for vector field paired Hottelling's T

Hello Todd,

I have a question on the above, and I acknowledge that it might have been asked previously (see #3). I do not however feel I understood the answer

I am doing multiple paired SPM T2 on a vector with three components in gait. The test demonstrate 2 significant clusters. I proceeded to do post hoc using paired t test. I detected significance in the scalar post-hoc in phases of gait where the vector did not show a significant cluster.

Can I ask the meaning of this and how one should interpret (of if it is wrong iin the first place)

Regards,
Bernard

Vector field analysis and joint coordinate system

Dear Todd,

I read with interest the paper "Vector field statistics for objective center-of-pressure trajectory analysis during gait, with evidence of scalar sensitivity to small coordinate system rotations".

One can define angles/moments based on the proximal, distal, joint, lab coordinate system. Based on the CS used, one can lead to varying conclusions. Can vector field help in this case?

I appreciate your help :)

Regards,
Bernard

spm1d feature requests

The following functionality is being developed for future versions of spm1d:

STATISTICS

  • P values for non-significant results
  • Direction selection ("positive" or "negative") for one-tailed tests
  • Post hoc tests (for ANOVA)
  • Post hoc tests (for multivariate analyses)
  • ANOVA: unbalanced designs (currently only possible for one-way ANOVA)
  • ANOVA: SS and MS terms
  • Reliability: ICC
  • Power analysis (including sample size calculation)
  • Effect size, CV, SEM
  • Equivalence tests
  • Support for circular data (0 to 360 deg)
  • False discovery rate procedures
  • Multiple regression
  • Multivariate analysis: two- and three-way MANOVA
  • Multivariate analysis: CCA for multivariate independent variables
  • ANOVA: improved non-sphericity corrections
  • ANCOVA and MANCOVA
  • ANOVA: support for string labels
  • Bayesian inference
  • Meta-analysis (heterogeneity, etc.)
  • MATLAB interface to SPM12, SPM8

GENERAL

  • Plotting: improved customization (e.g. line and cloud style specifications for mean / SD plotting)

COMPLETED

The following features (previously listed above) are available in spm1d 0.4 (released 01 October 2016):

  • Non-parametric inference
  • Confidence intervals
  • Normality testing
  • Python 3.X compatibility

Please reply to this post or create a new issue if you have any additional feature requests.

Stats results different based on order loaded into model

Hi Todd,

When performing a two way repeated measures SPM anova 1d, I realised that

  1. FF = spm1d.stats.anova2rm(Y, B, A, SUBJ,equal_var=True)
  2. FF = spm1d.stats.anova2rm(Y, A, B, SUBJ,equal_var=True)

gives different results.Does this have to do with the type of sum of squares usually explained in 0d ANOVA?

Regards,
Bernard

SPM and effect sizes (with example)

(Below is a summary of correspondence regarding effect size that recently took place elsewhere, please feel free to comment. Thank you for raising this issue Clint!)

Q. In preparing data for discussion with clinicians the "absolute values" were presented, followed by the SPM statistics and then the effect sizes (basically (mean1-mean2)/mean(std1 and std2)), as depicted in the figure below. Is this approach acceptable?

A. For conceptualizing experimental results effect sizes are fantastic. In simple experiments effect sizes are more or less the same thing as the test statistic, as is apparent in the attached figure. Compared to effect sizes the main benefits of using test statistics are: (1) they are useful for arbitrarily complex experiments involving arbitrarily complex dependent variables, and (2) they are more closely associated with probability, so are generally more useful for making statistical inferences. I'd say: try using both effect sizes and test statistics in a number of different situations and studies, and decide which is most valuable for a particular application.

Todd

gastroc

Figures for multi-cluster SPM

Dear Todd,

I like to inquire two things on printing figures for SPM. Sample code

ax3 = plt.subplot2grid((6,5), (4, 0), colspan=5)
vectors_ti[2].plot()
vectors_ti[2].plot_threshold_label(fontsize=10)
vectors_ti[2].plot_p_values(size=10, offsets=[(0,0.3)])
pyplot.title(titles[2])
pyplot.ylabel('SPM{F}')
pyplot.xlabel('Stance phase (%)')

If there are multiple clusters, this only prints the p values on one cluster. How can I get them to print all the clusters at the respective cluster position.

The critical threshold position, how can I offset its position, since it is often blocked by the pvalues or the graphs itself?

Regards,
Bernard

3-way RM-ANOVA effects order

Hi Todd,
I am dealing with a 3-way RM-ANOVA of some EMG data using the following code:

from spm1d.stats.anova.ui import anova3rm

anova = anova3rm(data,A,B,C,SUBJ,True)

As I have understood, the output coming out from each element within the "anova" variable reflects the tests for the factors A,B,C and their interaction. The anova variable is a list with 7 elements, thus I guess that the first three values reflect the tests for the main effects for the factors A, B and C, respectively. However, I don't know the index corresponding to the A*B (or any other) interaction. Therefore my question is: How the interaction effects are sorted?
I had a look at previous posts and at the documentation but I did not find an answer to my question.

Many thanks,
Luca.

Dataframe preparation for spm 1D two and three way repeated measures.

Dear Todd,

I don't think I could find examples of dataframe preparation to 1D 2 and 3 way repeated measures ANOVA. Maybe I can give a context using my study design. I have 20 subjects performing gait over 2 repeated factors LOAD (0,10,20kg) and SPEED (1,2,3m/s), thus 9 combinations. I want to measure joint power normalised to 101 points. My thoughts:

  1. create one data frame of 180 x 101 array. The first 9 rows represent first subject... etc..
  2. for each subject arrange the rows in order of load/speed combination e.g. (0/1,0/2,0/3,...20/1,20/2,20/3) or vice -versa speed/load.
  3. Create another 180 x 1 array listing the order of load (A)
  4. create 180 x 1 array listing the order of speed (B)
  5. create 180 x 1 array of SUBJ..

Is that right?

Regards,
Bernard

Sphericity

Hi Todd,

First off, thanks for your terrific python package. I have read almost all of your papers related to SPM, and I had a couple of queries regarding the Python package that I was hoping you could answer.

In short, I am comparing 3D kinematics and kinetics of participants across 5 different tasks. I am primarily interested in the knee joint injury implications, but am also looking at the hip and ankle joints.

My plan is to conduct a repeated measures ANOVA (is there a vector field equivalent? Can Hotelling's be applied for multiple groups?) for each variable of interest for the 5 tasks, then conduct post-hoc paired t-tests with a Bonferroni correction for the comparisons. If this seems reasonable to you, I guess I would ask:
1.Given that the non-sphericity correction is approximate and has yet to be verified, what does this mean for publication outcomes? Would you recommend I use another method if sphericity is violated?
2.Is there a simple way to test for sphericity with these sorts of datasets? (Is there an SPM specific method for assumption testing e.g. sphericity or normality at each node?)
3.Finally, is it simply good practice to interpolate to ~100 data points? Some of my data is based on time, thus each participants data already has the same number of nodes. My concern is that the low number of time nodes (sometimes less than 20) might be influencing RFT related corrections.

Hope that all makes sense. Again, any help you can provide would be much appreciated given your expertise in the area.

Mixed models with random intercept

Hi Todd,

I wonder if it is possible to perform a mixed model analysis considering only random intercept using spm1d. My model of interest would be:

 Y = aX * bX * cX + i | subjects

where Y is my variable of interest. a, b, c are the (fixed) factors and i is the intercept.

The model comes out from my experiemental hypothesis that the effects of the factors are somehow the same between subjects, but each subject has his/her own baseline level of Y. Thus, I assume that a mixed model where my factors are kept as fixed and the intercepts are allowed to be random across the subjects is what I am looking for. Am I right?
I had a look to the documentation about Random Effects Analysis, but I don't think that it suit my case.

Many thanks,
Luca

Two-sample Hotelling’s T2 test plots

Dear Todd Pataky,

I am trying to use the function "Two-sample Hotelling’s T2 test". Based on the example "./spm1d/examples/stats1d/ex_hotellings2_Besier2009muscleforces.py", I prepared the following code:

import os,sys
import pandas as pd
from matplotlib import pyplot
import spm1d

(0) Load data:

args=[]
for arg in sys.argv:
args.append( arg)
YA = pd.read_csv(args[1]).as_matrix().T
YB = pd.read_csv(args[2]).as_matrix().T

(1) Conduct test:

alpha = 0.05
T2 = spm1d.stats.hotellings2(YA, YB)
T2i = T2.inference(0.05)

(2) Plot:

pyplot.close('all')
T2i.plot()
pyplot.show()

However, I get the error "AttributeError: 'SPM0Di_T2' object has no attribute 'plot' ".

Could you help me solving this problem and perform this test?

Best regards,
Florent Moissenet.

multivariate statistics Vs anova

Hi
I open a new discussion, as required
it might be basic but help another users.

I hesitate between 3 statistical process !

I have only on dependant variable for multiple conditions.
Initially i choose to carry out an spm-anova for examining the mean equality betwwen all independant variables
mean_1=mean2=mean3=mean4=mean 5=mean 6
the spm anova showed significant regions. Then i stated 3 posthoc tests only :
mean_1=mean2
mean_3=mean4
mean_5=mean6
I set aside other comparisons because they are not relevant according my research question
I found no significant difference.

So, i wonder if a multivariate anova would be more adapted. This multivariate would consider two vectors collecting (mean1,mean3,mean5) and (mean2,mean4,mean6) separatly.
But, for me, there is no reason to think that mean1 covariates with mean3 and mean 5 ! these componants could be assumed as indepedants. in this case : is multiple ttest comparison better suited?

What do you think about that ?

regards

Fabien
Fabien

Getting Started in Python

When trying to import the spm1d folder into Canopy, an import error arises where it can't find the 'tables' module in io.py

importing spm1d

post hoc for n-way repeated measures ANOVA

Hi Todd,

I’m trying to analyse some surface elecromyographic (EMG) data collected during walking trials by SPM1D. The aim is to detect the phase of the gait cycle (if any) at which the same muscles change their activation amplitude because of different ground grades or speeds. I’m going to use the anova2rm function provided by the SPM1D package (the python version) to investigate the grade and speed main and interaction effects. I’m using a repeated measures approach because my participants performed all the grade/speed combination trials (in random order).
My concern is about how to perform post-hoc analyses. I’m not a statistician, but I think that using t-tests with Bonferroni corrected p values would not be a valid approach because of the repeated measures design. Since the SPM1D package actually does not allow for pairwise contrasts / dependent samples t-tests, I would like to perform 1-way repeated measures ANOVA (RM-ANOVA) with Bonferroni corrected p values with each combination of grade and speed used as factor. For instance, to compare the Grade_A-Speed_A combination vs. the Grade_A-Speed_B combination, I would create a factor where these combinations are defined by two values (e.g. 0 and 1 respectively). Then I would perform the 1-way RM-ANOVA to compare these combinations. However, I have never read a paper reporting this approach for post-hoc analyses, therefore I would be very much interested in your opinion about this.
If you have valid alternatives that could suit my analyses I will really appreciate any help.
Thank you in advance for your time and consideration.

Many thanks,
Luca.

Aproximated residuals in repeated-measures ANOVA

Hi Todd,
Just a quick question/ clarification about version 0.3.1 release notes which state the following:

WARNING: Repeated-measures ANOVA
• IF (a) the data are 1D and (b) there is only one observation per subject and per condition...
• THEN inference is approximate, based on approximated residuals.
• TO AVOID THIS PROBLEM: use multiple observations per subject per condition, and the same number of observations across all subjects and conditions.

If I interpret this correctly, rather than just providing subject means for each condition I would also include all of the trial data e.g. 5 trials per subject. If there are plenty of subjects and plenty of mean trials within RM conditions, why is having multiple trials necessary/why is inference approximate?
Is this a 1D rather than 0D issue because trial data would not typically be needed for a 0D SPSS mixed design ANOVA for example?

Thanks in advance,
Regards
Mark

Partially overlapped post-hoc scalars and primary vectors (field smoothness)

Dear Todd,

I am writing this on the same issue that was touched on previously (#38). I am inquiring on this due to a second comment from a reviewer of a paper. Let me repose the same hypothetical scenario

**"Say I did a vector field and significance was found in 50% to 90% of gait.

If significance in post hoc at scalar level was found in:
e.g 1) 49% to 90%
e.g 2) 50% to 91%
e.g 3) 49% to 91%

In e.g 1-3, can we say post hoc was significant only in the region where primary analysis was significant? Or if the bounds is exceeded, we should say we cannot interpret the post hoc results."**

In addition to the answer you provided, can it be said that because the inference was made on smoothed residuals, and smoothing of a signal in fact means discrete points no longer exist, a significant scalar field cluster can only either contribute or not contribute to the primary vector field (at the approximate period). To act on the conservative side (avoid Type 2 error), we consider that the scalar field did contribute to the vector field at that time period, but this should provide grounds for specific discrete time point hypothesis testing.

Would you agree with the above comment or maybe you could provide a more refined additional explanation?

Really appreciate the help.

Regards,
Bernard

Three way repeated measures ANOVA 1D SPM and vector field.

Hi Todd,

From the website, the available three way rmANOVA (below), does not allow complete three way analysis?
-Three-way ANOVA
-Three-way nested ANOVA
-Three-way ANOVA with repeated-measures on two factors
-Three-way ANOVA with repeated-measures on one factor

Can I say that there is no function as yet in spm1d that can perform vector field analysis using >= 2 repeated measures?

Regards,
Bernard

Outliers

Hi Todd,

I would like to know your opinion about the outliers detection prior to calculate of the statistical parameteric maps. Particularly, I wonder if the use of a multivariate outliers detection technique such as the minimum covariance determinant approach might be useful in detecting those cases (i.e. rows in the data matrix) that appear significantly different from the others. Accordingly, I would also know your opinion about how to handle the detected outliers, especially within a repeated-measures analysis.

Thanks,
Luca.

ROI

Hi Todd,

I'm sorry if this question may appear somehow stupid, but I did not find relevant documentation explaining how to use it. My question is: What is the purpose of the roi analysis? Is it a way to analyse a specific range of the nodes within the analysed time-series? If this is the case, may I use it for post-hoc analyses?

Thanks,
Luca.

Post hoc scalar field analysis

Dear Todd,

How have you been? I wish to inquire on post hoc scalar field analysis. Say I did a vector field and significance was found in 50% to 90% of gait.

If significance in post hoc at scalar level was found in:

e.g 1) 60-90% (that would be easy and ok to interpret)
e.g 2) 49% to 90%
e.g 3) 50% to 91%
e.g 4) 49% to 91%

In e.g 2-4, can we say post hoc was significant only in the region where primary analysis was significant? Or if the bounds is exceeded, we should say we cannot interpret the post hoc results.

Regards,
Bernard

0D data analysis

Dear Todd,

I would like to use the SPM Hotelling's T2 test on 0D data.

In the website "spm1d.org", I can read "All spm1d.stats functions now support both 0D and 1D data data analysis.". However, when I try to use it on the Python version of SPM, I have the error "Shape of array too small to calculate a numerical gradient".

My vector field is a 9x70x1 matrix.

Is the Hotelling's T2 test available for 0D data?

Best regards,
Florent Moissenet.

One sample t-test

Hi Todd,

I would like to compare some time-series with a set of thresholds that are subject-dependent but not time-dependent. Since I would like to evaluate which region of the time series are above the thresholds, I wonder if the use of 1D paired t-tests to compare the time-series with the time-series created from the thresholds values (that have variance equal to 0 over time) would be a correct approach.

many thanks,
Luca.

Contributing...

Hi Todd

I saw the talk by Jos Vanrenterghem on spm in biomechanics. I was quite impressed, and I believe the tools fills a void in the field.

I was happy when I heard that the tools were implemented in Python, and your code looks impressive although I haven't had the chance to use it for real projects yet.

I have few concerns still, and some that may prevent it from beeing more widely adopted. Firstly, the code is based on legacy python, and I mostly use Python 3. I could probably port the code to a python2/3 compatible code base if you are interested. Secondly, the licence for the code is GPL. This makes it impossible to use in other open source project that doesn't also use GPL. Would you consider changing the license terms to for example LGPL or something more liberal? Most of the current open source scientific Python use BSD, Apache or MIT.

Regards,
Morten

Vector field analysis

Dear Todd,

I was wondering if vector field analysis can be performed in spm1d, similar to the EMG paper you published? If so, which is the module for it?

Regards,
Bernard

Installation of SPM1d.03- download location

Dear Todd,

I noticed that spm1d.03 is out. I was wondering where the zip file for download and installation is?

When installing v3, must I remove the old version and replace with the new file?

Regards,
Bernard

Repeated Measures ANOVA

Hi guys,

I'm hoping to run a repeated measures ANOVA on the following dataset. Is this possible with the current version of spm1d? I am running the MATLAB version of spm1d.

Independent variable: tester experience (session 1: experienced; session 2: inexperienced)
Dependent variable: elbow flexion/extension (time varying and normalised to 101 pts)
nSubjects = 10
nSessions = 2
nTasks = 1
nRepetitions = 12 per person per session

Thanks!

anova3rm

Hi Todd,

I'm using the anova3rm function to investigate the effect of 3 distinct parameters on the EMG activity of one muscle whilst performing a specific exercise (I'm a sport scientist).
The experimental design is rather simple: each participant (n = 20) performs the same exercise 8 times with distinct factors combinations (i.e. load lifted, speed, fatigued/not-fatigued). The order in which the parameters combinations were performed was randomized for each participant. Thus, I have 1 trial for each participant per investigated parameter combination. Since I want to investigate both the main and the interaction effects due to the investigated parameters on the EMG activity of one specific muscle, I decided to use the anova3rm function because all the trials have been performed by the same participants. However, a WARNING message is printed out with the following text:

_WARNING: Only one observation per subject found. Residuals and inference will be approximate. To avoid approximate residuals: (a) Add multiple observations per subject and per condition, and (b) ensure that all subjects and conditions have the same number of observations.

if (model.dim == 1) and ( design.check_for_single_responses() ):_

Therefore I wonder if a simple anova3 should be used instead of the anova3rm.

Thanks,
Luca.

Describing SPM1D

Hi Todd,
Not an issue but a quick question on describing the SPM1D analyses (hope this is the right area to ask). Can I make comments on the magnitude of the t values calculated - e.g. in the attached analysis can I say that although 100% of the time the two methods are different, the smallest differences are towards the start and the greatest differences are found at 90%?
Thanks
Denny
every trial

Statistical tests (main) ERROR - 'module' object has no attribute 'gam'

Hi,

I am new to both Python and SPM, and I am following the tutorial on your website http://www.spm1d.org/doc/Examples_stats_basic.html with the final objective to use SPM to compare EMG signals.

However, when trying to launch "./spm1d/examples/ex03_00_ttest.py" (or any statistical test with the function "inference"), I am encountering the following error:
"""
File "C:\Anaconda\spm1d_prob.py", line 128, in prob_rft
G = np.sqrt(pi)/(stats.distributions.gam(0.5*np.arange(1,D+1)))

AttributeError: 'module' object has no attribute 'gam'
"""

I am using Python 2.7.8 with Spyder 2.3.4.

Thanks a lot in advance,

Sincerely,
Aurelie Sarcher

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.