Maverick/View Virtual Family Together: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
(Blanked the page)
Line 1: Line 1:
= Create a scene using the virtual family  =


First convert two members of the virtual family
VirtualFamilyTxtToMhdCsv Duke_34y_v5_2mm.txt Duke_34y_v5_2mm.raw Duke.mhd Duke.csv
VirtualFamilyTxtToMhdCsv Ella_26y_v2_2mm.txt Ella_26y_v2_2mm.raw Ella.mhd Ella.csv
This produces representations in the .mhd format. 
One wacky thing, the man is imaged head-first while the woman is imaged feet-first.  This can be made consistent by adding an orientation matrix and origin to the woman's header file.
vi Ella.mhd
Add the two lines below so that they appear before the last line of the file.
Origin = 0 0 1680
Orientation = 1 0 0 0 1 0 0 0 -1
This Orientation field is specifying a transform matrix for the data.  It must be a 3x3 matrix.  It can be used to swap right/left and front/back and (shown) top/bottom and to permute the axis (e.g., swap x-axis and y-axis) of the data.  In this case, the final -1 causes the z-axis to be flipped. 
The flipping now cause Ella to span the space from 0 to -1680 (she has 840 z-slices, each 2mm thick).  However, the virutal man is on the positive side of the z-axis (0 to 1900 or so).  So, we shift Ella's origin in the positive z direction to compensate for the z-axis flip.
The new Ella.mhd should look like this:
NDims = 3
DimSize = 265 150 840
HeaderSize = -1
ElementType = MET_UCHAR
ElementByteOrderMSB = True
ElementSpacing = 2 2 2
Origin = 0 0 1680
Orientation = 1 0 0 0 1 0 0 0 -1
ElementDataFile = Ella_26y_V2_2mm.raw
The current release of Maverick, however, requires the images to be in the .mha format.  So, perform the conversion using imageMath
imageMath Duke.mhd -W 3 Duke.mha
imageMath Ella.mhd -W 3 Ella.mha
Now Merlin can be used to create a scene containing these labelmaps and indexed via those .csv files.  Use the standard labelmap import process of Merlin to achieve this.
[[Image:Maverick-Merlin-DukeBrain.jpg|400px]]
= Create a new version of the woman that is shaped somewhat like the man =
To simulate different size people, the virtual woman (Ella) can be registered with the virtual man (Duke) using a deformable (BSpline) transform.  In this manner, the woman will take on aspects of the shape of the man.  The RegisterImages module accomplishes this
RegisterImages Duke.mha Ella.mha
    --registration PipelineBSpline --interpolation NearestNeighbor
    --minimizeMemory --controlPointSpacing 100 --bsplineSamplingRatio 0.02
    --resampledImage TallElla.mha --saveTransform TallElla.tfm
All of the above should be on one line.  Processing time will vary from 30 minutes to 1 hour, depending on the PC.  The result should be two new files: TallElla.mha and TallElla.tfm
Regretfully, this output image, while a .mha image, uses compression that isn't well supported by Maverick applications at this time.  So, the TallElla.mha file must be run-thru imageMath
imageMath TallElla.mha -W 3 TallElla.mha
The new version of the TallElla.mha file can be imported into Merlin.
<b> BEFORE Registration: Ella-to-Duke </b>
[[Image: Maverick-VirtualFamily-ManWomanRegistration-before.jpg|400px]]
<b> AFTER Registration: Ella-to-Duke </b>
[[Image: Maverick-VirtualFamily-ManWomanRegistration-after.jpg|400px]]
== Notes ==
You can control how closely the woman is deformed into the man by controlling how many BSpline control points are used.  More points means more flexibility and ultimately a closer match.  The two relevant command-line arguments are --controlPointSpacing and --bsplineSamplingRatio.  A smaller controlPointSpacing value means that more bspline control points will be used to span the image.  When more control points are used, more samples should be taken to evaluate the metric, i.e., the bsplineSamplingRatio should be increased.  Note that computation time can quickly become multiple hours.
= View the short and tall Ella next to one another in the same volume =
First move TellElla 600 mm to the right by editing the file TallElla.mha using vi or another text editor.
vi TallElla.mha
Change line containing the keyword <em>Offset</em> to induce the shift
Offset = 600 0 -100
Note: the -100 was added to the z-axis after some trial and error.  It is needed to align the bottom of their feet.
Now we will use the MultipleVolumesToVolume function to merge these women into a single volume. 
First create a text file (call it ellaTwins.txt) that lists these files
Ella.mha
TallElla.mha
Then run the MultipleVolumesToVolume program
MultipleVolumesToVolume ellaTwins.txt 0,0,0 300,128,465 4,4,4 1,0,0,0,1,0,0,0,1 EllaTwins.mha
This file can be directly imported into Merlin and other Maverick applications.
[[Image:Maverick-EllaTwins.jpg|400px]] [[Image:Maverick-Merlin-EllaTwins.jpg|400px]]

Revision as of 20:53, 20 March 2012