------------------------------------------------
 HOWTO hand pre-normalize an "orig" dataset
------------------------------------------------
In cases where the automatic normalization
results in an eroded-looking brain surface, you
may have to pre-normalize the "orig" data set by
hand, and then re-run the entire process starting
with Process Volume.

Load the "orig" Data Set

First, start up Medit with the "orig" data set.
You may first want to make a copy of the original
"orig":

  cd $SUBJECTS_DIR/marty/mri
  cp -r orig orig-orig

Medit Piecewise Linear Normalization Panel

Hit F3 in the medit tools window to bring up the
extended Medit panel (F2 goes back to the default
view).  The new subpanel on the right allows you
to test and then apply a piecewise linear ramp of
brightness correction factors (ffrac0-3) at four
control points (lim0-3).  For example, if you
click I/S (inferior/superior direction) and set
lim2 => 145, and ffrac2 => 1.2, this means
multiply the brightness value of pixels at
inferior/superior position 145 (0-255) by 1.2.
Thus, if the pixel value was 134 (view pixel
value in upper border of display window) the new
pixel value will be 134 * 1.2 = 161.

There are 4 control points (lim0-3, 0-255 pixel
coords) that can be applied to one of the 3 main
directions in the image: posterior/anterior,
inferior/superior, or right/left.  The correction
factors are linearly interpolated between the
control points, and remain flat beyond the first
and last control points.

Try Test Normalizations using the Back Buffer

The TEST1 button applies the piecewise linear
ramp to a single slice and puts the result into
the back buffer so that you can use COMPARE to
blink between it and the original image.  If you
change any settings, and hit TEST1 again, it will
redo the test normalization with the new
settings.

To make the eventual effect of the normalization
more obvious, it is best to turn on WMTRUNC (with
the low limit set to 90, which is the default for
mri_wmfilter), which truncated the image to black
below 90.

A <Return> in any of the lim? or frac? entries is
the same as hitting TEST1, so you quickly change
the scale factors or control points in small
steps and immediately see the effects.

For example, to brighten a dim superior sagittal
region, set one control point (e.g., lim3) to the
pixel coordinate of the top of the skull (e.g.,
around 210 -- look in the lower entry of each
pair to the right of the CORONAL, SAGITTAL and
HORIZONTAL buttons for the pixel coordinates).
Now set another control point (e.g., lim2) to the
pixel coordinate just inferior to the dimmed
region (that is, where no correction needs to be
applied, for example, around 180).  Turn on
WMTRUNC, set low=90, and gradually increase
ffrac3 above 1.0, hitting a <Return> each time in
ffrac3 to see the effects.  You can use COMPARE
to see what the truncated original looks like.

Normalize the Entire Data Set (front buffer)

Once you are satisfied with your settings, apply
them to all of the images in the front (editable)
buffer of Medit by clicking ALL.  The images have
not yet been saved, so if you want to go back,
quit without saving.

Save the Normalized Images

Finally, to save the modified images into the
$SUBJECTS_DIR/marty/mri/orig directory, hit
SAVEIMG.  You should now re-run the surface
reconstruction from the beginning, starting with
Process Volume.

Tips

You can apply several ramps in succession in
different directions (e.g., superior/inferior,
left/right), by hitting ALL several times (after
the proper setting of lim0-3 and ffrac0-3 for
each direction have are determined in
succession).

N.B.: since ALL replaces the front (editable)
buffer images with the normalized images, hitting
ALL twice with the same settings will apply that
ramp twice.  This is in contrast to the behavior
of TEST1, which applies the ramp just once and
stores (overwrites) the image into the back
buffer with the result.

N.B.: If you leave the COMPARE button set to the
back buffer (depressed) and change the slice, you
will generally see nothing unless you have
already pressed TEST1 for the other slice.  Also,
If you do one TEST1 in CORONAL and change planes
to, say, SAGITTAL with the COMPARE button
depressed, you will only see the single CORONAL
slice in edge view.  To get back to the front
buffer click COMPARE again (till it's raised).

