Resampling the curves

To resample the curves we are going to use a simple windows command line program resample.exe (windows only) from
here. There are probably other ways to do this but this is the least headachey way right now.

First we have to prepare the files:
The landmark files are saved from avizo in the avizo .landmarkAscii.ascii file format. These can be opened in TextEdit on a mac.

create a blank .txt file, we will be placing all the curve landmark coordinates here
- open the left sphenoid curve file from avizo in TextEdit
- it will look like this:
# Avizo 3D ASCII 2.0


define Markers 29

Parameters {
    Units {
        Coordinates "mm"
    }
    NumSets 1,
    ContentType "LandmarkSet"
}

Markers { float[3] Coordinates } @1

# Data section follows
@1
3.994494247436523e+001 -1.678364562988281e+001 8.382704925537109e+001
3.876627349853516e+001 -1.612295913696289e+001 8.283426666259766e+001
....

-you can ignore the text and just copy the coordinates (everything below @1)
- paste that into the blank .txt file
- at the end of the first like type sphenoidL like so:

3.994494247436523e+001 -1.678364562988281e+001 8.382704925537109e+001 sphenoidL
3.876627349853516e+001 -1.612295913696289e+001 8.283426666259766e+001
....

- scroll to the end of the coordinates and hit enter
- open the next curve file (right sphenoid)
- copy the coordinates and place below the left sphenoid curve coordinates
- type sphenoidR at the end of the first line for the right sphenoid curve coordinates
- erase any empty line between the left and right coordinates
- should look like this:
...
7.409994602203369e+000 6.115043640136719e+000 8.650126647949219e+001
6.381602764129639e+000 6.801040649414063e+000 8.691799926757813e+001
-5.285277557373047e+001 -1.355352020263672e+001 9.340502166748047e+001 sphenoidR
-5.152090072631836e+001 -1.331455230712891e+001 9.212683105468750e+001
...

- Repeat these steps until all the curve coordinates have been copied and pasted into the .txt file and labeled (matching the control file discussed below)

- save the file as ####curvelandmarks.txt


To resample the curves:-The program resample.exe is first placed in a folder on its own
- a control file is created as a txt file to indicate how many landmarks each curve should be resampled to, it indicates the name of each curve and number of landmarks
- it is a simple control.txt file that looks like this:

sphenoidL 8
sphenoidR 8
petrL 8
petrR 8
transvL 8
transvR 8
sagittal 40

- input files should be plain txt files as well and should look like this (example):

x2 y2 z2 lambda
x3 y3 z3 nasion
x y z midsag
x y z
x y z
x y z
x y z
x y z coronr
x y z
x y z
x y z
x y z
x y z
x y z
x y z


Instructions from the program creators is as follows:

Run the program from a command prompt. (For DOS-haters, open a command prompt window and access the directory containing the program and the control file. For example if the program is on the C drive in a folder named ‘curve data’ you would do the following:

> cd C:/curve data )

Program commands can be accessed by typing:

> resample.exe –h

The single letter abbreviations on the left can be used with a single dash in front of them, or the full command can be used (e.g., match) with two dashes in front of it.

The various commands are as follows:

COMMAND ACTION:

-c , --control-file CONTROL_FILE identifies CONTROL_FILE as your control file

-d, --directory DIRECTORY process files in DIRECTORY (default is

current directory)

-m, --match FILE_MATCH FILE_MATCH provides the name(s) of the

file(s) to be processed. This can be a space-delimited list (a.prn b.txt c.spo) or you can use wildcards (e.g., *.prn would process all files with a .prn file extension in DIRECTORY) *.* (i.e., all files) is the default.

-o, --output-directory DIRECTORY writes processed files to given DIRECTORY

(default creates a folder named RESAMPLE in the current directory)

-f, --output-format FORMAT writes processed files into DVLR or morpheus compatible files. Options are ‘dvlr’ or ‘morph.’ Default is DVLR. (see below for explanation)

-?, --missing-data ID if there are missing data in your files, then this must be indicated by ID (e.g., if 9999 represents a missing semilandmark, then ID=9999). Default is 9999.

-h, --help

Examples of how these commands work are given in the help screen.



once in the resample folder in the command line type:
resample.exe -c control.txt -m *.txt

-it should create a new file in the resampled folder with the same name but resampled coordinates
- rename the file ###curvelandmarksresampled.txt and  copy that back into the folder you have saved the rest of the relevant files

After Resampling: 

-now you will need to copy the fixed and resampled curve landmarks into excel, the fixed landmarks must be first and the curve landmarks should always be in the same order

-The first sheet of the excel file will be the original landmark coordinates, rename the sheet as such
- the second sheet will be the mirrored coordinates, rename it as such

- copy everything and paste into the second sheet
-insert a new column in front of the x coordinates
- set it equal to -B1 (flip the sign of the x coordinates) and copy down the column
- copy the column and paste special just the values
- delete the second column (original x values)
- flip the rows of the paired landmarks and curves (highlight the coordinates and Shift+drag to the correct row)

-save the excel file as ####_fixed_curve_landmarks.xlsx

-copy and paste the original and mirrored coordinates into separate txt files
-the first line of the txt files should be
LM3= 109 (or whatever # landmarks)

Morton####_fixed_curve_landmarks.txt
Morton####_fixed_curve_landmarks_flipped.txt

No comments:

Post a Comment