.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_ttest.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_ttest.py: Tutorial 03: Plot of mean and statistical data (t-test) ======================================================= Example script to plot both mean data and statistics, e.g. from paired or unpaied t-test with two groups. .. GENERATED FROM PYTHON SOURCE LINES 6-51 .. code-block:: Python from surface_plot import plot_mean_stats import numpy as np outdir = 'data/paired_ttest/test_figures' clobber = False # Load data pval_left = np.loadtxt('https://www.dropbox.com/s/5g3sopvolf0qnot/left.pval?dl=1', skiprows=1) pval_right = np.loadtxt('https://www.dropbox.com/s/282xfgqk4wx2pka/right.pval?dl=1', skiprows=1) tval_left = np.loadtxt('https://www.dropbox.com/s/ku6wdm4nd8690rg/left.tval?dl=1', skiprows=1) tval_right = np.loadtxt('https://www.dropbox.com/s/oci987u02nwtgxf/right.tval?dl=1', skiprows=1) mean1_left = np.loadtxt('https://www.dropbox.com/s/htx0q2lm87nnlf1/baseline_left.mean?dl=1', skiprows=1) mean1_right = np.loadtxt('https://www.dropbox.com/s/mbe1a3v8vtgrlsx/baseline_right.mean?dl=1', skiprows=1) mean2_left = np.loadtxt('https://www.dropbox.com/s/f71pewt2748dag7/followup_left.mean?dl=1', skiprows=1) mean2_right = np.loadtxt('https://www.dropbox.com/s/8r8jfkqz9rxjrr3/followup_right.mean?dl=1', skiprows=1) tval = {'left': tval_left, 'right': tval_right} pval = {'left': pval_left, 'right': pval_right} mean1 = {'left': mean1_left, 'right': mean1_right} mean2 = {'left': mean2_left, 'right': mean2_right} # Define statistical threshold p_threshold = 0.01 # P value output = f'{outdir}/ttest_pval_p{p_threshold}.pdf' plot_mean_stats.plot_mean_stats(mean1, mean2, tval, output, pval=pval, vlim=[0, 4], p_threshold=p_threshold, cb_mean_title='Mean SUVR', mean_titles=['Baseline', 'Follow-up'], stats_titles=['Increase', 'Decrease'], clobber=clobber) output = f'{outdir}/ttest_pval_notitle_p{p_threshold}.pdf' plot_mean_stats.plot_mean_stats(mean1, mean2, tval, output, pval=pval, vlim=[0, 4], p_threshold=p_threshold, clobber=clobber) # T value output = f'{outdir}/ttest_tval_p{p_threshold}.pdf' plot_mean_stats.plot_mean_stats(mean1, mean2, tval, output, vlim=[0, 4], pval=pval, p_threshold=p_threshold, cb_mean_title='Mean SUVR', mean_titles=['Baseline', 'Follow-up'], stats_titles=['Change'], plot_tvalue=True, clobber=clobber) output = f'{outdir}/ttest_tval_notitle_p{p_threshold}.pdf' plot_mean_stats.plot_mean_stats(mean1, mean2, tval, output, pval=pval, vlim=[0, 4], p_threshold=p_threshold, plot_tvalue=True, clobber=clobber) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 16.165 seconds) .. _sphx_glr_download_auto_examples_plot_ttest.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_ttest.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_ttest.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_ttest.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_