<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="_dimgstats_8cpp">
<title>/Users/bernard/b20/bsoft/src/dimgstats.cpp File Reference</title>
<indexterm><primary>/Users/bernard/b20/bsoft/src/dimgstats.cpp</primary></indexterm>
<para>

<para>Calculates statistical measures within a set of images or between sets of images. </para>
 
</para>
<programlisting>#include &quot;Bstring.h&quot;
#include &quot;rwimg.h&quot;
#include &quot;img_combine.h&quot;
#include &quot;math_util.h&quot;
#include &quot;utilities.h&quot;
#include &quot;options.h&quot;
#include &quot;timer.h&quot;
#include &quot;Vector3.h&quot;
</programlisting><simplesect>
    <title>Functions    </title>
        <itemizedlist>
            <listitem><para>int <link linkend="_dimgstats_8cpp_1ae9d41de0e8ce588bb991545d316e93bf">img_fom_sqrt</link> (<link linkend="_class_bimage">Bimage</link> *p)</para>
</listitem>
            <listitem><para><link linkend="_class_bimage">Bimage</link> * <link linkend="_dimgstats_8cpp_1af9e7f3be1ad3c7a6a9c1ad4877242966">img_students_t_test</link> (int n, <link linkend="_class_bimage">Bimage</link> *p, vector&lt; double &gt; &amp;weight)</para>

<para>Applies the Student&apos;s t-test to one set of images. </para>
</listitem>
            <listitem><para><link linkend="_class_bimage">Bimage</link> * <link linkend="_dimgstats_8cpp_1ae38fd07c239f021304a26e720ad0d032">img_students_t_test_equal</link> (int set1, int set2, <link linkend="_class_bimage">Bimage</link> *p1, <link linkend="_class_bimage">Bimage</link> *p2, vector&lt; double &gt; &amp;weight)</para>

<para>Applies the Student&apos;s t-test to two sets of images, assumes the two distributions have approximately the same variance. </para>
</listitem>
            <listitem><para><link linkend="_class_bimage">Bimage</link> * <link linkend="_dimgstats_8cpp_1a5e5d3229090045986d48fb15384d3e3c">img_students_t_test_unequal</link> (int set1, int set2, <link linkend="_class_bimage">Bimage</link> *p1, <link linkend="_class_bimage">Bimage</link> *p2, vector&lt; double &gt; &amp;weight)</para>

<para>Applies the Student&apos;s t-test to two sets of images, assumes the two distributions have unequal variance. </para>
</listitem>
            <listitem><para><link linkend="_class_bimage">Bimage</link> * <link linkend="_dimgstats_8cpp_1aa125330626248b497eace1416f048199">img_f_test</link> (int set1, int set2, <link linkend="_class_bimage">Bimage</link> *p1, <link linkend="_class_bimage">Bimage</link> *p2, vector&lt; double &gt; &amp;weight)</para>

<para>Applies the F-test to two sets of images. </para>
</listitem>
            <listitem><para>int <link linkend="_dimgstats_8cpp_1a3c04138a5bfe5d72780bb7e82a18e627">main</link> (int argc, char **argv)</para>
</listitem>
        </itemizedlist>
</simplesect>
<simplesect>
    <title>Variables    </title>
        <itemizedlist>
            <listitem><para>int <link linkend="_dimgstats_8cpp_1a0b2caeb4b6f130be43e5a2f0267dd453">verbose</link></para>
</listitem>
            <listitem><para>const char * <link linkend="_dimgstats_8cpp_1a4de0ad4c7190962494815c0fa7f948df">use</link> []</para>
</listitem>
        </itemizedlist>
</simplesect>
<section>
<title>Detailed Description</title>

<para>Calculates statistical measures within a set of images or between sets of images. </para>

<para><formalpara><title>Author: </title>

<para>David Belnap and Bernard Heymann </para>
</formalpara>
<formalpara><title>Date: </title>

<para>Created: 20051213 </para>

<para>Modified: 20190208 (BH) </para>
</formalpara>
</para>
</section>
<section>
<title>Function Documentation</title>
<anchor xml:id="_dimgstats_8cpp_1aa125330626248b497eace1416f048199"/>    <section>
    <title>img_f_test()</title>
<indexterm><primary>img_f_test</primary><secondary>dimgstats.cpp</secondary></indexterm>
<indexterm><primary>dimgstats.cpp</primary><secondary>img_f_test</secondary></indexterm>
<para><computeroutput><link linkend="_class_bimage">Bimage</link> * img_f_test (int set1, int set2, <link linkend="_class_bimage">Bimage</link> * p1, <link linkend="_class_bimage">Bimage</link> * p2, vector&lt; double &gt; &amp; weight)</computeroutput></para><para>

<para>Applies the F-test to two sets of images. </para>
</para>

<para><formalpara><title>Author: </title>

<para>David Belnap </para>
</formalpara>

                <formalpara>
                    <title>
Parameters                    </title>
                    <para>
                    <table frame="all">
                        <tgroup cols="2" align="left" colsep="1" rowsep="1">
                        <colspec colwidth="1*"/>
                        <colspec colwidth="4*"/>
                        <tbody>
                            <row>
                                <entry>set1</entry>
                                <entry>
<para>number of files in set 1. </para>
</entry>
                            </row>
                            <row>
                                <entry>set2</entry>
                                <entry>
<para>number of files in set 2. </para>
</entry>
                            </row>
                            <row>
                                <entry>*p1</entry>
                                <entry>
<para>average image with variance (FOM), set 1 </para>
</entry>
                            </row>
                            <row>
                                <entry>*p2</entry>
                                <entry>
<para>average image with variance (FOM), set 2 </para>
</entry>
                            </row>
                            <row>
                                <entry>weight</entry>
                                <entry>
<para>list of weights. </para>
</entry>
                            </row>
                        </tbody>
                        </tgroup>
                    </table>
                    </para>
                </formalpara>
                <formalpara><title>Returns: </title>

<para>Bimage* F-test image and significance image (as FOM). <literallayout><computeroutput>The F value is computed for each pixel:
        F(i) = var1(i) / var2(i)

Variance (as FOM of an average image) is input.  The significance 
level is computed and stored as FOM of F-test image.  Output is
in floating point.
</computeroutput></literallayout> Reference: Press W.H. et al (1992) Numerical Recipes in C. </para>
</formalpara>
</para>
<para>
Definition at line 595 of file dimgstats.cpp.</para>
    </section><anchor xml:id="_dimgstats_8cpp_1ae9d41de0e8ce588bb991545d316e93bf"/>    <section>
    <title>img_fom_sqrt()</title>
<indexterm><primary>img_fom_sqrt</primary><secondary>dimgstats.cpp</secondary></indexterm>
<indexterm><primary>dimgstats.cpp</primary><secondary>img_fom_sqrt</secondary></indexterm>
<para><computeroutput>int img_fom_sqrt (<link linkend="_class_bimage">Bimage</link> * p)</computeroutput></para><para>
Definition at line 328 of file dimgstats.cpp.</para>
    </section><anchor xml:id="_dimgstats_8cpp_1af9e7f3be1ad3c7a6a9c1ad4877242966"/>    <section>
    <title>img_students_t_test()</title>
<indexterm><primary>img_students_t_test</primary><secondary>dimgstats.cpp</secondary></indexterm>
<indexterm><primary>dimgstats.cpp</primary><secondary>img_students_t_test</secondary></indexterm>
<para><computeroutput><link linkend="_class_bimage">Bimage</link> * img_students_t_test (int n, <link linkend="_class_bimage">Bimage</link> * p, vector&lt; double &gt; &amp; weight)</computeroutput></para><para>

<para>Applies the Student&apos;s t-test to one set of images. </para>
</para>

<para>
                <formalpara>
                    <title>
Parameters                    </title>
                    <para>
                    <table frame="all">
                        <tgroup cols="2" align="left" colsep="1" rowsep="1">
                        <colspec colwidth="1*"/>
                        <colspec colwidth="4*"/>
                        <tbody>
                            <row>
                                <entry>n</entry>
                                <entry>
<para>number of files in the set. </para>
</entry>
                            </row>
                            <row>
                                <entry>*p</entry>
                                <entry>
<para>average and variance of the set. </para>
</entry>
                            </row>
                            <row>
                                <entry>weight</entry>
                                <entry>
<para>list of weights. </para>
</entry>
                            </row>
                        </tbody>
                        </tgroup>
                    </table>
                    </para>
                </formalpara>
                <formalpara><title>Returns: </title>

<para>Bimage* significant level image (floating point). <literallayout><computeroutput>First, average (avg) and variance (var) images are calculated:
        var = [1/(N-1)] sum(x - avgx)^2
Second, the t value is computed and returned as an image:
        t = avg / sqrt[ var/N ]
Finally, the significance is calculated and returned as the FOM of the image:
        sig = betai(dof/2, 0.5, dof/(dof + t*t))
where dof (degrees-of-freedom) is calculated as:
        dof = ws*(1 - 1.0L/N)
and ws is the weight sum.
All images are converted to floating point.
</computeroutput></literallayout> Reference: Press W.H. et al (1992) Numerical Recipes in C. Milligan and Flicker (1987) J. Cell Biol. 105:29-39. </para>
</formalpara>
</para>
<para>
Definition at line 371 of file dimgstats.cpp.</para>
    </section><anchor xml:id="_dimgstats_8cpp_1ae38fd07c239f021304a26e720ad0d032"/>    <section>
    <title>img_students_t_test_equal()</title>
<indexterm><primary>img_students_t_test_equal</primary><secondary>dimgstats.cpp</secondary></indexterm>
<indexterm><primary>dimgstats.cpp</primary><secondary>img_students_t_test_equal</secondary></indexterm>
<para><computeroutput><link linkend="_class_bimage">Bimage</link> * img_students_t_test_equal (int set1, int set2, <link linkend="_class_bimage">Bimage</link> * p1, <link linkend="_class_bimage">Bimage</link> * p2, vector&lt; double &gt; &amp; weight)</computeroutput></para><para>

<para>Applies the Student&apos;s t-test to two sets of images, assumes the two distributions have approximately the same variance. </para>
</para>

<para><formalpara><title>Author: </title>

<para>David Belnap and Bernard Heymann </para>
</formalpara>

                <formalpara>
                    <title>
Parameters                    </title>
                    <para>
                    <table frame="all">
                        <tgroup cols="2" align="left" colsep="1" rowsep="1">
                        <colspec colwidth="1*"/>
                        <colspec colwidth="4*"/>
                        <tbody>
                            <row>
                                <entry>set1</entry>
                                <entry>
<para>number of files in set 1. </para>
</entry>
                            </row>
                            <row>
                                <entry>set2</entry>
                                <entry>
<para>number of files in set 2. </para>
</entry>
                            </row>
                            <row>
                                <entry>*p1</entry>
                                <entry>
<para>average image with variance (FOM), set 1 </para>
</entry>
                            </row>
                            <row>
                                <entry>*p2</entry>
                                <entry>
<para>average image with variance (FOM), set 2 </para>
</entry>
                            </row>
                            <row>
                                <entry>weight</entry>
                                <entry>
<para>list of weights. </para>
</entry>
                            </row>
                        </tbody>
                        </tgroup>
                    </table>
                    </para>
                </formalpara>
                <formalpara><title>Returns: </title>

<para>Bimage* t-test image and significance image (as FOM). <literallayout><computeroutput>Input average images for sets 1 and 2, with variance as FOM portion
of the images.  The numerator portion of the variance (Vn) is 
computed from the variance.  The &quot;standard error of the difference 
of the means&quot; is computed:
SD = sqrt[ ( (Vn1 + Vn2) / degrees_of_freedom ) * (1/set1 + 1/set2) ]

and used to compute the t value:
            t = ( avg1 - avg2 ) / SD

Finally, the significance level (probability) is computed.
</computeroutput></literallayout></para>
</formalpara>
Reference: Press W.H. et al (1992) Numerical Recipes in C. Milligan and Flicker (1987) J. Cell Biol. 105:29-39. </para>
<para>
Definition at line 439 of file dimgstats.cpp.</para>
    </section><anchor xml:id="_dimgstats_8cpp_1a5e5d3229090045986d48fb15384d3e3c"/>    <section>
    <title>img_students_t_test_unequal()</title>
<indexterm><primary>img_students_t_test_unequal</primary><secondary>dimgstats.cpp</secondary></indexterm>
<indexterm><primary>dimgstats.cpp</primary><secondary>img_students_t_test_unequal</secondary></indexterm>
<para><computeroutput><link linkend="_class_bimage">Bimage</link> * img_students_t_test_unequal (int set1, int set2, <link linkend="_class_bimage">Bimage</link> * p1, <link linkend="_class_bimage">Bimage</link> * p2, vector&lt; double &gt; &amp; weight)</computeroutput></para><para>

<para>Applies the Student&apos;s t-test to two sets of images, assumes the two distributions have unequal variance. </para>
</para>

<para><formalpara><title>Author: </title>

<para>David Belnap </para>
</formalpara>

                <formalpara>
                    <title>
Parameters                    </title>
                    <para>
                    <table frame="all">
                        <tgroup cols="2" align="left" colsep="1" rowsep="1">
                        <colspec colwidth="1*"/>
                        <colspec colwidth="4*"/>
                        <tbody>
                            <row>
                                <entry>set1</entry>
                                <entry>
<para>number of files in set 1. </para>
</entry>
                            </row>
                            <row>
                                <entry>set2</entry>
                                <entry>
<para>number of files in set 2. </para>
</entry>
                            </row>
                            <row>
                                <entry>*p1</entry>
                                <entry>
<para>average image with variance (FOM), set 1 </para>
</entry>
                            </row>
                            <row>
                                <entry>*p2</entry>
                                <entry>
<para>average image with variance (FOM), set 2 </para>
</entry>
                            </row>
                            <row>
                                <entry>weight</entry>
                                <entry>
<para>list of weights. </para>
</entry>
                            </row>
                        </tbody>
                        </tgroup>
                    </table>
                    </para>
                </formalpara>
                <formalpara><title>Returns: </title>

<para>Bimage* t-test image and significance image (as FOM). <literallayout><computeroutput>Input average images for sets 1 and 2, with variance as FOM portion
of the images.  The t value is computed:
        t = ( avg1 - avg2 ) / sqrt[ var1/ws1 + var2/ws2 ]

(ws = weighted sum, default = N).  The significance level 
(probability) is computed.  Output is in floating point.
</computeroutput></literallayout></para>
</formalpara>
Reference: Press W.H. et al (1992) Numerical Recipes in C. Milligan and Flicker (1987) J. Cell Biol. 105:29-39. </para>
<para>
Definition at line 521 of file dimgstats.cpp.</para>
    </section><anchor xml:id="_dimgstats_8cpp_1a3c04138a5bfe5d72780bb7e82a18e627"/>    <section>
    <title>main()</title>
<indexterm><primary>main</primary><secondary>dimgstats.cpp</secondary></indexterm>
<indexterm><primary>dimgstats.cpp</primary><secondary>main</secondary></indexterm>
<para><computeroutput>int main (int argc, char ** argv)</computeroutput></para><para>
Definition at line 81 of file dimgstats.cpp.</para>
</section>
</section>
<section>
<title>Variable Documentation</title>
<anchor xml:id="_dimgstats_8cpp_1a4de0ad4c7190962494815c0fa7f948df"/>    <section>
    <title>use</title>
<indexterm><primary>use</primary><secondary>dimgstats.cpp</secondary></indexterm>
<indexterm><primary>dimgstats.cpp</primary><secondary>use</secondary></indexterm>
<para><computeroutput>const char* use[]</computeroutput></para><para>
Definition at line 29 of file dimgstats.cpp.</para>
    </section><anchor xml:id="_dimgstats_8cpp_1a0b2caeb4b6f130be43e5a2f0267dd453"/>    <section>
    <title>verbose</title>
<indexterm><primary>verbose</primary><secondary>dimgstats.cpp</secondary></indexterm>
<indexterm><primary>dimgstats.cpp</primary><secondary>verbose</secondary></indexterm>
<para><computeroutput>int verbose</computeroutput></para></section>
</section>
</section>
