This is an automated email from the git hooks/post-receive script. yoh pushed a commit to annotated tag v0.1 in repository python-mne.
commit 581ad27f81f319d52e76fd8856e620513b052201 Author: Alexandre Gramfort <[email protected]> Date: Mon Apr 18 11:08:28 2011 -0400 ENH : making permutation_cluster_1samp_test more generic with stat_fun --- .../stats/plot_cluster_1samp_test_time_frequency.py | 6 +++--- mne/stats/__init__.py | 3 ++- mne/stats/cluster_level.py | 18 +++++++++++++----- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/examples/stats/plot_cluster_1samp_test_time_frequency.py b/examples/stats/plot_cluster_1samp_test_time_frequency.py index 03a7ba5..5503881 100755 --- a/examples/stats/plot_cluster_1samp_test_time_frequency.py +++ b/examples/stats/plot_cluster_1samp_test_time_frequency.py @@ -26,7 +26,7 @@ import numpy as np import mne from mne import fiff from mne.time_frequency import single_trial_power -from mne.stats import permutation_cluster_t_test +from mne.stats import permutation_cluster_1samp_test from mne.datasets import sample ############################################################################### @@ -85,9 +85,9 @@ epochs_power = np.log10(epochs_power) # take log of ratio ############################################################################### # Compute statistic -threshold = 2 +threshold = 2.5 T_obs, clusters, cluster_p_values, H0 = \ - permutation_cluster_t_test(epochs_power, + permutation_cluster_1samp_test(epochs_power, n_permutations=100, threshold=threshold, tail=0) ############################################################################### diff --git a/mne/stats/__init__.py b/mne/stats/__init__.py index d61f12e..68488ea 100755 --- a/mne/stats/__init__.py +++ b/mne/stats/__init__.py @@ -1,2 +1,3 @@ from .permutations import permutation_t_test -from .cluster_level import permutation_cluster_test, permutation_cluster_t_test +from .cluster_level import permutation_cluster_test, \ + permutation_cluster_1samp_test diff --git a/mne/stats/cluster_level.py b/mne/stats/cluster_level.py index 57e693b..c00ea1e 100755 --- a/mne/stats/cluster_level.py +++ b/mne/stats/cluster_level.py @@ -8,7 +8,7 @@ import numpy as np from scipy import ndimage -from scipy.stats import ttest_1samp +from scipy import stats from .parametric import f_oneway @@ -170,7 +170,15 @@ def permutation_cluster_test(X, stat_fun=f_oneway, threshold=1.67, permutation_cluster_test.__test__ = False -def permutation_cluster_t_test(X, threshold=1.67, n_permutations=1000, tail=0): +def ttest_1samp(X): + """Returns T-values + """ + T, _ = stats.ttest_1samp(X, 0) + return T + + +def permutation_cluster_1samp_test(X, threshold=1.67, n_permutations=1000, + tail=0, stat_fun=ttest_1samp): """Non-parametric cluster-level 1 sample T-test From a array of observations, e.g. signal amplitudes or power spectrum @@ -220,7 +228,7 @@ def permutation_cluster_t_test(X, threshold=1.67, n_permutations=1000, tail=0): shape_ones = tuple([1] * X[0].ndim) # Step 1: Calculate T-stat for original data # ------------------------------------------------------------- - T_obs, _ = ttest_1samp(X, 0) + T_obs = stat_fun(X) clusters, cluster_stats = _find_clusters(T_obs, threshold, tail) @@ -234,7 +242,7 @@ def permutation_cluster_t_test(X, threshold=1.67, n_permutations=1000, tail=0): X_copy *= signs # Recompute statistic on randomized data - T_obs_surr, _ = ttest_1samp(X_copy, 0) + T_obs_surr = stat_fun(X_copy) _, perm_clusters_sums = _find_clusters(T_obs_surr, threshold, tail) if len(perm_clusters_sums) > 0: @@ -250,7 +258,7 @@ def permutation_cluster_t_test(X, threshold=1.67, n_permutations=1000, tail=0): return T_obs, np.array([]), np.array([]), np.array([]) -permutation_cluster_t_test.__test__ = False +permutation_cluster_1samp_test.__test__ = False # if __name__ == "__main__": # noiselevel = 30 -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-mne.git _______________________________________________ debian-med-commit mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit
