Пример #1
0
def vsource_tfce_map(effect, stat_map, p, statistic, max_statistic):
    brain = plot.GlassBrain(stat_map, show=False)
    cbar = brain.plot_colorbar(orientation='vertical', show=False, width=0.2, w=1.1, h=2.8)
    content = [brain.image(), cbar.image()]
    brain.close()
    cbar.close()

    caption = FMText([f"{effect}; ", fmtxt.eq(statistic, max_statistic, 'max'), ', ', fmtxt.peq(p)])
    return Figure(content, caption)
Пример #2
0
def test_eq():
    "Test equation factory"
    s = fmtxt.eq('t', 0.1234)
    eq_(str(s), "t = 0.12")
    eq_(html(s), "t = 0.12")
    eq_(tex(s), "$t = 0.12$")

    s = fmtxt.eq('t', 0.1234, 18)
    eq_(str(s), "t(18) = 0.12")
    eq_(html(s), "t<sub>18</sub> = 0.12")
    eq_(tex(s), "$t_{18} = 0.12$")

    s = fmtxt.peq(0.1299)
    eq_(str(s), "p = .130")
    eq_(html(s), "p = .130")
    eq_(tex(s), "$p = .130$")

    s = fmtxt.peq(0.0009)
    eq_(str(s), "p < .001")
    eq_(html(s), "p &lt; .001")
    eq_(tex(s), "$p < .001$")
Пример #3
0
def test_eq():
    "Test equation factory"
    s = fmtxt.eq('t', 0.1234)
    assert str(s) == "t = 0.12"
    assert html(s) == "t = 0.12"
    assert tex(s) == "$t = 0.12$"

    s = fmtxt.eq('t', 0.1234, 18)
    assert str(s) == "t(18) = 0.12"
    assert html(s) == "t<sub>18</sub> = 0.12"
    assert tex(s) == "$t_{18} = 0.12$"

    s = fmtxt.peq(0.1299)
    assert str(s) == "p = .130"
    assert html(s) == "p = .130"
    assert tex(s) == "$p = .130$"

    s = fmtxt.peq(0.0009)
    assert str(s) == "p < .001"
    assert html(s) == "p &lt; .001"
    assert tex(s) == "$p < .001$"
Пример #4
0
def test_eq():
    "Test equation factory"
    s = fmtxt.eq('t', 0.1234)
    eq_(str(s), "t = 0.12")
    eq_(html(s), "t = 0.12")
    eq_(tex(s), "$t = 0.12$")

    s = fmtxt.eq('t', 0.1234, 18)
    eq_(str(s), "t(18) = 0.12")
    eq_(html(s), "t<sub>18</sub> = 0.12")
    eq_(tex(s), "$t_{18} = 0.12$")

    s = fmtxt.peq(0.1299)
    eq_(str(s), "p = .130")
    eq_(html(s), "p = .130")
    eq_(tex(s), "$p = .130$")

    s = fmtxt.peq(0.0009)
    eq_(str(s), "p < .001")
    eq_(html(s), "p < .001")
    eq_(tex(s), "$p < .001$")
Пример #5
0
def source_tfce_pmap(effect, pmap, statmap, max_statistic, surfer_kwargs, brain, difference=None):
    if brain is None:
        brain = plot.brain.brain(pmap.source, **surfer_kwargs)
    else:
        brain.remove_data()

    brain.add_ndvar_p_map(pmap, statmap)
    cbar = brain.plot_colorbar(orientation='vertical', show=False, width=0.2, w=1.1, h=2.8)
    content = [brain.image(), cbar.image()]
    cbar.close()

    if difference is not None:
        brain.remove_data()
        brain.add_ndvar(difference)
        cbar = brain.plot_colorbar(orientation='vertical', show=False, width=0.2, w=1.1, h=2.8)
        content.append(brain.image())
        content.append(cbar.image())
        cbar.close()

    statistic = statmap.info['meas']
    p = pmap.min()
    caption = FMText([f"{effect}; ", fmtxt.eq(statistic, max_statistic, 'max'), ', ', fmtxt.peq(p)])
    fig = Figure(content, caption)
    return fig, brain
Пример #6
0
def pairwise(Y, X, match=None, sub=None,  # data in
             par=True, corr='Hochberg', trend=True,  # stats
             title='{desc}', mirror=False,  # layout
             ):
    """
    pairwise comparison according to factor structure

    """
    ct = celltable(Y, X, match=match, sub=sub)
    test = _pairwise(ct.get_data(), within=ct.all_within, parametric=par, corr=corr,  # levels=levels,
                     trend=trend)

    # extract test results
    k = len(ct)
    indexes = test['pw_indexes']
    statistic = test['statistic']
    _K = test[statistic]
    _P = test['p']
    if corr:
        _Pc = mcp_adjust(_P, corr)
    _df = test['df']
    _NStars = test['stars']
    symbols = test['symbols']

    # create TABLE
    table = fmtxt.Table('l' + 'l' * (k - 1 + mirror))
    title_desc = "Pairwise {0}".format(test['test'])
    table.title(title.format(desc=title_desc))
    table.caption(test['caption'])

    # headings
    table.cell()
    cell_labels = ct.cell_labels()
    for name in cell_labels[1 - mirror:]:
        table.cell(name)
    table.midrule()

    # tex_df = fmtxt.Element(df, "_", digits=0)
    if corr and not mirror:
        subrows = range(3)
    else:
        subrows = range(2)

    for row in range(0, k - 1 + mirror):
        for subrow in subrows:  # contains t/p
            # names column
            if subrow is 0:
                table.cell(cell_labels[row], r"\textbf")
            else:
                table.cell()
            # rows
            for col in range(1 - mirror, k):
                if row == col:
                    table.cell()
                elif col > row:
                    index = indexes[(row, col)]
                    if subrow is 0:
                        tex_cell = fmtxt.eq(statistic, _K[index], df=_df[index],
                                             stars=symbols[index],
                                             of=3 + trend)
                    elif subrow is 1:
                        tex_cell = fmtxt.eq('p', _P[index], fmt='%.3f', drop0=True)
                    elif subrow is 2:
                        tex_cell = fmtxt.eq('p', _Pc[index], df='c',
                                             fmt='%.3f', drop0=True)
                    table.cell(tex_cell)
                else:
                    if mirror and corr and subrow == 0:
                        index = indexes[(col, row)]
                        p = _Pc[index]
                        table.cell(p, fmt='%.3f', drop0=True)
                    else:
                        table.cell()
    return table