User:Jadrian Miles/Thesis manifesto: probabilistic worldview: Difference between revisions

From VrlWiki
Jump to navigation Jump to search
Jadrian Miles (talk | contribs)
\chi^2 Fitting: refined the writeup about chi-square statistic and Q
Jadrian Miles (talk | contribs)
 
(18 intermediate revisions by the same user not shown)
Line 20: Line 20:
Imagine that we knew the true, measurement-error-free value of every observation; let's call that <math>\bar{y}_i</math>.  Imagine also that our reckoning of the measurement error distributions (that is, that each one is Gaussian with mean <math>\bar{y}_i</math> and standard deviation <math>\sigma_i</math>) is exactly correct.  Then each noisy observation <math>y_i</math> is made from a Gaussian distribution, and we can normalize this observation to a z-score (standard normal variate) by <math>z_i = (y_i - \bar{y}_i)/\sigma_i</math>.  Note, then, that the sum of the squares of all the <math>z_i</math> is a <math>\chi^2</math> statistic.  The sum of the squares of <math>k</math> independent standard normal random variables itself forms a probability distribution, and this distribution has a name: [[w:Chi-square distribution|the <math>\chi^2</math> distribution with <math>k</math> degrees of freedom]].
Imagine that we knew the true, measurement-error-free value of every observation; let's call that <math>\bar{y}_i</math>.  Imagine also that our reckoning of the measurement error distributions (that is, that each one is Gaussian with mean <math>\bar{y}_i</math> and standard deviation <math>\sigma_i</math>) is exactly correct.  Then each noisy observation <math>y_i</math> is made from a Gaussian distribution, and we can normalize this observation to a z-score (standard normal variate) by <math>z_i = (y_i - \bar{y}_i)/\sigma_i</math>.  Note, then, that the sum of the squares of all the <math>z_i</math> is a <math>\chi^2</math> statistic.  The sum of the squares of <math>k</math> independent standard normal random variables itself forms a probability distribution, and this distribution has a name: [[w:Chi-square distribution|the <math>\chi^2</math> distribution with <math>k</math> degrees of freedom]].


Now flip this concept around: rather than knowing true, error-free <math>\bar{y}_i</math> values and talking about the probability distribution of the <math>y_i</math> values, what we know is the <math>y_i</math>s and we want to evaluate the probability that our model has estimated the <math>\bar{y}_i</math>s correctly.  The sum of the squares of the normalized differences between <math>y(x_i|a)</math> and <math>y_i</math> should follow the same <math>\chi^2</math> distribution as above, if the model estimated <math>\bar{y}_i</math> correctly.  For every degree of freedom in our model (<math>M</math>), though, we have to eliminate one degree of freedom (that is, consideration one observation) from the <math>\chi^2</math> distribution, since theoretically we could've devoted that one degree of freedom to exactly reproducing one noisy observation that we made.
Now flip this concept around: rather than knowing true, error-free <math>\bar{y}_i</math> values and talking about the probability distribution of the <math>y_i</math> values, what we know is the <math>y_i</math>s and we want to evaluate the probability that our model has estimated the <math>\bar{y}_i</math>s correctly.  The sum of the squares of the normalized differences between <math>y(x_i|a)</math> and <math>y_i</math> should follow the same <math>\chi^2</math> distribution as above, if the model estimated <math>\bar{y}_i</math> correctly.  For every degree of freedom in our model (<math>M</math>), though, we have to eliminate one degree of freedom (that is, consideration of one observation) from the <math>\chi^2</math> distribution, since theoretically we could've devoted that one degree of freedom to exactly reproducing one noisy observation that we made.


What we've arrived at is '''<math>\chi^2</math> model selection'''.  Given a value <math>\chi^2</math> as computed above, the probability <math>Q</math> of seeing an error as bad or worse than the observed <math>\chi^2</math> under a different set of observations drawn from the same underlying distribution, given the degrees of freedom <math>\nu \equiv N - M</math>, is:
What we've arrived at is '''<math>\chi^2</math> model selection'''.  Given a value <math>\chi^2</math> as computed above, the probability <math>Q</math> of seeing an error as bad or worse than the observed <math>\chi^2</math> under a different set of observations drawn from the same underlying distribution, given the degrees of freedom <math>\nu \equiv N - M</math>, is:
Line 48: Line 48:


===Bundle Adjustment===
===Bundle Adjustment===
 
* <math>N</math> is the number of voxels in all the DWIs that should be included in the model.  A given voxel should be included if it is part of a liberal white-matter mask or has any part of the bundle model passing through it.
** The point of this formalism is to avoid including background voxels unnecessarily; we could theoretically drown out the effects of anything interesting by creating an arbitrarily large FOV that included a huge volume of empty space.  Limiting the definition of voxels that we want to include in the goodness-of-fit measure keeps us honest and sensitive.
* <math>M</math> is the total number of degrees of freedom in the bundle model, which are difficult to count.  They include at least: 3 DOF per triangulation vertex, 3 DOF per triangle (vertex indices), 1 DOF per bundle (the newline separating lists of triangles from each other), and some DOF for the internal "microstructure" model in each bundle.
* <math>\sigma_i</math> is the background noise level.  We use it (see the section on microstructure fitting) to convert Rician-distributed random variables to equivalent standard Gaussian RVs.


===Microstructure Fitting===
===Microstructure Fitting===
* <math>N</math> is the number of voxels in the relevant region multiplied by the number of observations (diffusion weightings) in each. Each individual configuration (voxel and diffusion weighting) is an <math>x_i</math>. The observed intensity for each <math>x_i</math> is <math>y_i</math>.
* <math>N</math> is the number of voxels in the relevant region multiplied by the number of observations (diffusion weightings) in each. Each individual configuration (voxel and diffusion weighting) is an <math>x_i</math>. The observed intensity for each <math>x_i</math> is <math>y_i</math>.
* <math>M</math> is the number of control parameters in the space-filling microstructure model. Assuming that the microstructure instance for each voxel is determined by some sort of spline with sparse control points, <math>M</math> is 3 parameters for position plus the number of parameters actually controlling the microstructure model, multiplied by the number of control points.  <math>y(x_i|a_0 \dots a_{M-1})</math> is the reconstructed signal intensity in the voxel and diffusion weighting specified by <math>x_i</math>, given the model parameter values <math>a_0 \dots a_{M-1}</math>.
* <math>M</math> is the number of control parameters in the space-filling microstructure model. Assuming that the microstructure instance for each voxel is determined by some sort of spline with sparse control points, <math>M</math> is 3 parameters for position plus the number of parameters actually controlling the microstructure model, multiplied by the number of control points.  <math>y(x_i|a_0 \dots a_{M-1})</math> is the reconstructed signal intensity in the voxel and diffusion weighting specified by <math>x_i</math>, given the model parameter values <math>a_0 \dots a_{M-1}</math>.
* <math>\sigma_i</math> is known for all <math>i</math> by estimation of the Rician noise parameters from the DWIs.  But...
* <math>\sigma_i</math> is known for all <math>i</math> by estimation of the Rician noise parameters from the noise in the background of the DWIs.  But...


Unfortunately, we know that the noise on the <math>y_i</math>s is not Gaussian but rather Rician.  Therefore <math>(y_i-y(x_i|a))</math> is not normally-distributed, and so the <math>\chi^2</math> statistic is invalid in the form above.  We can, however, create a "fake" observation <math>\tilde{y}_i</math> from <math>y_i</math> for which <math>(\tilde{y}_i-y(x_i|a))</math> is normally distributed.  We do this by solving for the <math>\tilde{y}_i</math> that satisfies the following equality:
Unfortunately, we know that the noise on the <math>y_i</math>s is not Gaussian but rather Rician.  Therefore <math>(y_i-y(x_i|a))</math> is not normally-distributed, and so the <math>\chi^2</math> statistic is invalid in the form above.  We can, however, create a "fake" observation <math>\tilde{y}_i</math> from <math>y_i</math> for which <math>(\tilde{y}_i-y(x_i|a))</math> is normally distributed.  We do this by solving for the <math>\tilde{y}_i</math> that satisfies the following equality:


<math>\int_{-\infty}^{y_i}\mathbb{P}(y_i|y)\,\mathrm{d}y_i = \int_{-\infty}^{\tilde{y}_i}\mathbb{P}(\tilde{y}_i|y)\,\mathrm{d}\tilde{y}_i</math>
<math>\int_{-\infty}^{y_i}\mathbb{P}_{\mathrm{rice}}(x|y)\,\mathrm{d}x = \int_{-\infty}^{\tilde{y}_i}\mathbb{P}_{\mathrm{gauss}}(x|y)\,\mathrm{d}x</math>


The two sides of the equality are values of the cumulative distribution functions of, respectively, a Rician random variable and a gaussian random variable:
The two sides of the equality are values of the cumulative distribution functions of, respectively, a Rician random variable and a Gaussian random variable:


<math>1-Q_1\!\left(\frac{y}{\sigma_i},\frac{y_i}{\sigma_i}\right) = \frac{1}{2}\left(1+\mathrm{erf}\!\left(\frac{\tilde{y}_i-y}{\sqrt{2\sigma_i^2}}\right)\right)</math>
<math>1-Q_1\!\left(\frac{y}{\sigma_i},\frac{y_i}{\sigma_i}\right) = \frac{1}{2}\left(1+\mathrm{erf}\!\left(\frac{\tilde{y}_i-y}{\sqrt{2\sigma_i^2}}\right)\right)</math>


where <math>Q_1\,</math> is the first-order Marcum Q-function, and <math>\mathrm{erf}\,</math> is the Gauss error function.  Solving, we find:
where <math>Q_1\,</math> is the first-order Marcum Q-function<ref group="note">References for the Marcum Q-function: [[w:Marcum Q-function|Wikipedia]], [http://mathworld.wolfram.com/MarcumQ-Function.html Mathworld], [http://www.mathworks.com/help/toolbox/signal/marcumq.html Matlab]</ref>, and <math>\mathrm{erf}\,</math> is the Gauss error function.  Solving, we find:


<math>\tilde{y}_i = y + \sqrt{2\sigma_i^2}\;\mathrm{erf}^{-1}\!\left(1-2Q_1\!\left(\frac{y}{\sigma_i},\frac{y_i}{\sigma_i}\right)\right)</math>
<math>\tilde{y}_i = y + \sqrt{2\sigma_i^2}\;\mathrm{erf}^{-1}\!\left(1-2Q_1\!\left(\frac{y}{\sigma_i},\frac{y_i}{\sigma_i}\right)\right)</math>
Line 70: Line 73:


The inner loop of our algorithm is given a model with <math>M</math> degrees of freedom, and fits the <math>a_j</math>s to maximize <math>Q</math> (or equivalently, minimize <math>\chi^2</math>) for that model (see &sect;15.5 of NR).  The outer loop is a search over all models (some of which may have the same <math>M</math>) to find a global maximum in <math>Q</math>.  As mentioned above, we should never get an unrealistically high <math>Q</math> value, as that's really only achievable by either fudging the data or overestimating the <math>\sigma_i</math>s.
The inner loop of our algorithm is given a model with <math>M</math> degrees of freedom, and fits the <math>a_j</math>s to maximize <math>Q</math> (or equivalently, minimize <math>\chi^2</math>) for that model (see &sect;15.5 of NR).  The outer loop is a search over all models (some of which may have the same <math>M</math>) to find a global maximum in <math>Q</math>.  As mentioned above, we should never get an unrealistically high <math>Q</math> value, as that's really only achievable by either fudging the data or overestimating the <math>\sigma_i</math>s.
= Notes =
<references group="note" />

Latest revision as of 19:31, 20 January 2012

My dissertation involves solving three problems:

  1. Automatically clustering tractography curves together so that the resulting clusters are neither too small (low reconstruction error, high model complexity) nor too big (high reconstruction error, low model complexity)
  2. Automatically adjusting macrostructure elements to match input DWIs so that the elements' surfaces are neither too bumpy (low reconstruction error, high model complexity) nor too smooth (high reconstruction error, low model complexity)
  3. Automatically adjusting microstructure properties within a given region in space to match input DWIs so that the spatial frequency of the microstructure parameters is neither too high (low reconstruction error, high model complexity) nor too low (high reconstruction error, low model complexity)

In each case, our goal is to balance the tradeoff between reconstruction error and model complexity. In order to do so in a principled fashion, we must define, for each case, what is meant by reconstruction error and model complexity. What probabilistic tools are available for us to go about this?

χ2 Fitting

One apparent option is χ2 fitting. Given:

  • N observations yi at independent variables xi
  • The knowledge that the measurement error on each observation is Gaussian with standard deviation σi
  • A model instance with M parameters aj, which gives a reconstructed "observation" for a given independent variable as y(xi|a0aM1)

we define the χ2 statistic as follows:

χ2=i=0N1(yiy(xi|a0aM1)σi)2

This is essentially a normalized error score, and in itself tells us nothing about goodness of fit. We have some sense that a small χ2 means a good fit and a big one means a bad fit, but how small and how big? How good and how bad? A χ2 statistic must be interpreted in the context of the relative sizes of N and M. Obviously, if you allow M=N, then you have as many degrees of freedom in your model as there are observations to test its fit, and so it's trivial to get χ2=0 in this case.

Imagine that we knew the true, measurement-error-free value of every observation; let's call that y¯i. Imagine also that our reckoning of the measurement error distributions (that is, that each one is Gaussian with mean y¯i and standard deviation σi) is exactly correct. Then each noisy observation yi is made from a Gaussian distribution, and we can normalize this observation to a z-score (standard normal variate) by zi=(yiy¯i)/σi. Note, then, that the sum of the squares of all the zi is a χ2 statistic. The sum of the squares of k independent standard normal random variables itself forms a probability distribution, and this distribution has a name: the χ2 distribution with k degrees of freedom.

Now flip this concept around: rather than knowing true, error-free y¯i values and talking about the probability distribution of the yi values, what we know is the yis and we want to evaluate the probability that our model has estimated the y¯is correctly. The sum of the squares of the normalized differences between y(xi|a) and yi should follow the same χ2 distribution as above, if the model estimated y¯i correctly. For every degree of freedom in our model (M), though, we have to eliminate one degree of freedom (that is, consideration of one observation) from the χ2 distribution, since theoretically we could've devoted that one degree of freedom to exactly reproducing one noisy observation that we made.

What we've arrived at is χ2 model selection. Given a value χ2 as computed above, the probability Q of seeing an error as bad or worse than the observed χ2 under a different set of observations drawn from the same underlying distribution, given the degrees of freedom νNM, is:

Q(χ2|ν)=χ2f(ψ,ν)dψ=1F(χ2|ν)

where f(ψ|ν) is the PDF of the χ2 distribution and F(ψ|ν) is of course its CDF. Here's how to interpret Q:

  • Really low (Q<0.001) means that you can't do a much worse job describing the data than you did with your model instance. This means either that your fit is bad (χ2 is really high) or that your model has so many degrees of freedom (and thus ν is so small) that even a low χ2 isn't convincing.
  • Really high (Q1) means that it's almost impossible to get a better fit to the observations, even given the number of degrees of freedom. High values are actually sort of suspicious, and either indicate that the σis were overestimated, M was underestimated, or the data were actually fudged to get a better result.

This means that maximizing Q over all values of M (from very simple to very complex models) should find the "happy medium" model that maximizes explanatory power (low χ2) while minimizing model complexity (low M).

Let's consider the meaning of all these variables for each of the problems defined above:

Curve Clustering

  • N is the number of vertices in all the curves in the tractography set. Each xi therefore represents the selection of a single vertex (by two parameters: the index of the curve in the curve set, and the index or arc-length distance of the desired vertex along this curve). yi isn't particularly well-defined in this case (see below), but amounts to the description of the curve near xi: the vertex's position and the angle between the consecutive segments, maybe.
  • M is the total number of curves that form the skeletons of the shrink-wrap polyhedra for the model, plus the total number of bundles/polyhedra. Note that even in the most "complicated" model, M is smaller than N by a factor of half the average number of xis per curve. y(xi|a0aM1) is the description of the reconstructed curve specified by xi at the specified position along it, given the association of curves with bundles specified by the model parameter values a0aM1.
  • σi is defined according to the definition of the difference (yiy(xi|a0aM1)) that we choose (see below).

Let's assume that for comparing the reconstruction (y(xi|a0aM1), which we will just call y) with the observation (yi), we want to incorporate both a position and angle reconstruction error. Then we must define some sort of scalar pseudo-difference function

f(y,yi)=α×dp(y,yi)+(1α)×dθ(y,yi)

where dp is the difference in positions (Euclidean distance) between the vertices, and dθ is some difference between angles, perhaps one minus the dot product. α may either be hand-tuned or solved for in the course of the optimization; in this latter case, M must be increased by one.

The σis must be determined experimentally (with synthetic phantoms, for example). It remains for these experiments to demonstrate that the errors are normally distributed. If not, some wacky transform might be necessary to shoehorn it into the χ2 regime, or Monte-Carlo simulation of the error distribution might allow for a different but equivalent approach (see §15.6 of NR).

Bundle Adjustment

  • N is the number of voxels in all the DWIs that should be included in the model. A given voxel should be included if it is part of a liberal white-matter mask or has any part of the bundle model passing through it.
    • The point of this formalism is to avoid including background voxels unnecessarily; we could theoretically drown out the effects of anything interesting by creating an arbitrarily large FOV that included a huge volume of empty space. Limiting the definition of voxels that we want to include in the goodness-of-fit measure keeps us honest and sensitive.
  • M is the total number of degrees of freedom in the bundle model, which are difficult to count. They include at least: 3 DOF per triangulation vertex, 3 DOF per triangle (vertex indices), 1 DOF per bundle (the newline separating lists of triangles from each other), and some DOF for the internal "microstructure" model in each bundle.
  • σi is the background noise level. We use it (see the section on microstructure fitting) to convert Rician-distributed random variables to equivalent standard Gaussian RVs.

Microstructure Fitting

  • N is the number of voxels in the relevant region multiplied by the number of observations (diffusion weightings) in each. Each individual configuration (voxel and diffusion weighting) is an xi. The observed intensity for each xi is yi.
  • M is the number of control parameters in the space-filling microstructure model. Assuming that the microstructure instance for each voxel is determined by some sort of spline with sparse control points, M is 3 parameters for position plus the number of parameters actually controlling the microstructure model, multiplied by the number of control points. y(xi|a0aM1) is the reconstructed signal intensity in the voxel and diffusion weighting specified by xi, given the model parameter values a0aM1.
  • σi is known for all i by estimation of the Rician noise parameters from the noise in the background of the DWIs. But...

Unfortunately, we know that the noise on the yis is not Gaussian but rather Rician. Therefore (yiy(xi|a)) is not normally-distributed, and so the χ2 statistic is invalid in the form above. We can, however, create a "fake" observation y~i from yi for which (y~iy(xi|a)) is normally distributed. We do this by solving for the y~i that satisfies the following equality:

yirice(x|y)dx=y~igauss(x|y)dx

The two sides of the equality are values of the cumulative distribution functions of, respectively, a Rician random variable and a Gaussian random variable:

1Q1(yσi,yiσi)=12(1+erf(y~iy2σi2))

where Q1 is the first-order Marcum Q-function[note 1], and erf is the Gauss error function. Solving, we find:

y~i=y+2σi2erf1(12Q1(yσi,yiσi))

This function re-maps a Rician random variable yi into a Gaussian random variable y~i with the same σi and central value y, and so we may use this y~i in place of yi in the summation for the χ2 statistic.

The inner loop of our algorithm is given a model with M degrees of freedom, and fits the ajs to maximize Q (or equivalently, minimize χ2) for that model (see §15.5 of NR). The outer loop is a search over all models (some of which may have the same M) to find a global maximum in Q. As mentioned above, we should never get an unrealistically high Q value, as that's really only achievable by either fudging the data or overestimating the σis.

Notes

  1. References for the Marcum Q-function: Wikipedia, Mathworld, Matlab