The object-creating scripts call on perl scripts which do the actual extraction. The perl scripts from whole brain (cortical_surface.pl), hemisphere (medial_cortical_surface_final_target.pl), and cerebellum (pauls_cerebellar_surface.pl) extractions differ only in one way - the target on which they call. This target can be found in after the "$model_file" in each script. A copy of each of these scripts, and the existing targets for the whole brain (avg_model_64.obj), hemisphere (target.obj), and cerebellum (test_CBL_8192.obj) can be found in /loni/edevel/bin/SURFACE_EXTRACTION.
Creating A New Target
When a project modeling a new piece of anatomy is started, a new target will have to be created in order for object models to be made. The target should fall onto each individual's volume just inside the surface that is to be modeled. The following figures illustrate relationships between targets and volumes that have led to acceptable object models: whole brain hemisphere cerebellum. If the target and volume do not match well and the target falls too far below or above the surface to be modeled, distortion can be seen on the object models. Bumps on the surface ( bump1 bump2 ) and lines where the mesh has wrapped around itself ( line1 line2) are the most frequent issues. These distortions do not represent actual anatomy and can change how lines are drawn and how surfaces are flattened, so minimizing them is very important.
To create a new target, it is possible
to modify an existing target with an xfm. The target can be scanned
to a volume and filled in to create a volume following the steps below.
Display target.obj
volume.mnc
select R "Objects"
from the main menu then W "Scan Object to Vol" to get the ribbon of label
where the target would fall on the volume
select F "Segmenting"
from the main menu and hit 6 "Fill 3D" with the cursor inside the area
that should be filled in to color inside the ribbon
select T "File"
from the main menu and then W "Save Labels .mnc"
This volume can be registered to a representative
subject's volume using register, and the xfm can be saved and applied to
the target using the transform_objects command (transform_objects
input.obj transform.xfm output.obj).
An xfm can also be modified by hand in nedit. The first row of number
in an xfm controls scaling and movement in the left-right direction, the
middle row controls scaling and movement in the front-back direction, and
the last row controls scaling and movement in the up-down direction.
The leftmost parameter in the first row, second parameter in the second
row, and third parameter in the third row control scaling (1 keeps the
size the same, less than one decreases it, and more than 1 increases it).
The last column controls translation; a positive value in the first row
shifts right, a positive value in the second row shifts forward, and a
positive value in the last row shifts up. This
figure shows an xfm with explanations of what each parameter does.
Another approach to creating a new target
requires a label volume of the desired size and shape, usually a mask of
the structure which will be modeled. An existing target can has been modified
using an xfm to fall entirely within the volume. The small target
object can be scanned to a volume and filled in and saved as a label.
The idea of this process is to create a series of volumes through which
the small label is blown up into the big mask. For each volume, an
object will be created, with each object looking more and more like the
final target. The small volume is dilated, with the label of the
whole region specified as the "mask volume" so that only voxels that fall
within the big label will get filled in by the dilations (dilate_volume
small_label.mnc small_label_dil1.mnc 1 mask_volume.mnc 1 256).
Dilations should be done one at a time so that the target object is only
one dilation smaller than the volume to which it will be applied and no
distortion (bumps or lines) occurs on the targets. An object should
be created by specifying the small object as the target and the label dilated
once as the minc. The object created here will be used as the target
with the minc that has been dilated twice, and so on. A target object
is formatted slightly differently from a normal object, so the object created
from each successive blurring must be turned into a target by changing
it from ascii to binary and combining certain lines from the object with
standard text. The following commands will turn an object into a
target:
ascii_binary dil1.obj
head -n 4099
dil1.obj > temp1.txt
head -n 69638 dil1.obj
> temp2.txt
tail -n 4098 temp2.txt
> temp3.txt
tail -n 4098 temp1.txt
> temp7.txt
cat /loni/edevel/bin/SURFACE_EXTRACTION/temp4.txt
temp7.txt /loni/edevel/bin/SURFACE_EXTRACTION/temp5.txt temp3.txt /loni/edevel/bin/SURFACE_EXTRACTION/temp5.txt
/loni/edevel/bin/SURFACE_EXTRACTION/temp6.txt > TAR_dil1.obj
This process should be repeated for each
dilation, with the target being changed so that it is always one dilation
smaller than the volume to which it's being applied.
Once a final target has been created, one of the perl scripts should be modified to call on the new target, and a wrapper script should be written which calls on the new version of the perl script.
Correcting Object Surfaces
Even with an appropriate target, it is possible that the models for some subjects will still have problems related to the match between the target and the volume. These problems can be corrected by altering the target with an xfm.
An xfm can be created that will transform the target into a space that better matches the individual's volume. If a volume is created from the target by scanning object to volume and filling in in Display, this target volume and the subject's volume can be pulled up in register (register subject.mnc target.mnc). Tag points can be chosen that force the target minc to fall better within the subject's minc. The xfm can be saved and applied to the target object.
An xfm can be created in a more automated way by using AIR to align each subject to a subject for which the object model has been created successfully. The script /loni/edevel/bin/SURFACE_EXTRACTION/make_xfm_for_object_script.csh can be modified by changing paths, subject number, and filenames and setting the target equal to a subject for which the model is being created correctly. The output of this script is an xfm which would align the volume that is working well to the volume of the subject that is not working, so it should be inverted (xfminvert input.xfm inverted.xfm). This inverted xfm should align each subject to a subject for which the object model is created well.
The perl scripts that extract the objects
are set up to incorcorporate xfms; they transform the target by the xfm
before beginning the extraction. To use the xfm, modify the wrapper
script so that the xfm is specified after the threshold (cortical_surface.pl
volume.mnc output.obj threshold transform.xfm).