How To's

From bone.wiki
Revision as of 14:35, 16 September 2010 by Enodwell (talk | contribs) (→Evaluation)
Jump to navigation Jump to search



HowTo Library

In addition to this HowTo library, much information is also available at the Scanco Medical FAQ.
  • users@scanco.ch
  • basser5dorf





HowTo: Print out report sheets

The postscript report sheets can be generated and printed on the command line. For the XtremeCT system, use UPAT_PRINT_LIST.EXE which can be run (using the symbol):

$ UPAT_LIST

Look in the UU: directory to see options for the template files (UPAT*.TXT) and the postscript output files (*.PS).

  • UU:UPAT_EVAL_FUP05_SCUSA.PS
  • UU:UPAT_EVAL_BASELINE_SCUSA.PS

For other options, see the upat_list help:

$ UPAT_LIST -h

One particular option that may be useful, is to turn off slice matching:

$ UPAT_LIST -nomatch


For reports from non-patient measurements (i.e., the vivaCT system or non-patient scans on the XtremeCT), the template files are different (UCT*.TXT) and the postscript outputs are different (UCT*.PS). To print a result sheet use:

$ RUN UM:UCT_RAY_BATCH.EXE

If you want to create a postscript file, but not send it to the printer, set the number of copies to zero (interactive). Then, find the postscript file from the SYS$SCRATCH directory and transfer it to your PC. You must transfer the postscript file in ASCII mode. The files are typically called TEMP_3D.PS or UPAT_PAT_62_RR.PS. A program such as Adobe Photoshop can convert the postscript file to a different format.

See also our custom scripts:

$ @COM:PRINT_2D.COM
$ @COM:PRINT_3D.COM

Combining two volumes to create transparent image

First create your two start "seg.aim" images Start by running either the normal eval, or $ voi to get one _seg.aim file of one region

Rename it to a better name in the session manager, e.g. c0001234_all.aim

Then either by choosing different contours, or a different threshold, start the $ voi or the normal evaluation again, which will create another _seg.aim file.

Load them in the 3D viewer ('all files') to check that they look like expected.

Now we will go into IPL and concatenate those two volumes.

$ ipl
/read all xx_all.aim
/read trab xx_seg.aim
/transparent
  -input_solid               trab
  -input_transp              all
  -output                    out

Note: the solid volume is OVERWRITING the transparent input volume, so usually, it is the smaller (inner) of the two.

/write out xxx_transp.aim
/quit

Then load the _transp.aim file in 3D, go to 3D program FAQ to see how to change transparency levels in the Display options there.

See IPL FAQ or 3D program FAQ if you need help with these parts.

Step by Step Example: Showing your chosen trab VOI within whole bone

  • $ voi, enter threshold in ipl_voi.com, start 3d eval WITHOUT contours
  • WAIT UNTIL THE JOB IS FINISHED!
  • Rename xxxx_seg.aim to xxxx_all.aim
  • Start up normal eval program, draw trabecular contours, check threshold in ipl_fixed_batch_v4.com, start 3D eval.
  • WAIT UNTIL THE JOB IS FINISHED!
  • go into ipl and combine the two, see code above
  • Voila, finished

Step by Step Example: Showing high-dense volume surronded by lower density volume

  • Start normal 3D eval with HIGH threshold entered in ipl_fixed_batch_v4.com
  • WAIT UNTIL THE JOB IS FINISHED!
  • Rename xxxx_seg.aim to xxxx_high.aim
  • If wished: read out 3d result database with $ uct_list
  • Start normal 3D eval with LOW threshold entered in ipl_fixed_batch_v4.com
  • WAIT UNTIL THE JOB IS FINISHED!
  • go into ipl and combine the two, see code above
  • Voila, finished

Make an animation

To calculate an Animation, two (separate) tools of the 3D program are used: the set-up of start and end point of the Animation, and the 'Auto-Print' tool that automatically creates the TIF files for every rendered image.

This is a 'step by step' guide to create an animation using TIFF files:

  • Open your sample in the 3D program.
  • Now, open 'options','Animation'
  • Render your Image the way you want your animation to start. e.g. observer rotation -179 degrees. You may interrupt if you want. If you are satisfied with all the settings (rotation, elevation, transparency, colors etc.) the Click on 'Get Settings A'
  • Then, adjust all the settings for the endpoint of your animation (with the mouse or the sliders) e.g. observer rotation +179, and start the rendering. If satisfied, click 'Get settings B'

Note: To test, put # of views to 5 or 10... You can also interrupt the build-ups for faster viewing.

  • Click the START button again, wait till the build-up of the 3D image is finished.
  • DO NOT HIT 'START CALCULATION' YET!
  • First, you also need to set-up the 'Auto-Print' mode:
  • Go to the 'Print' menu (file --> print), choose print to TIF and to File and enter THE BEGINNING OF A FILENAME, e.g. sys$scratch:test_ (the program will append 0000.TIF, 0001.TIF etc afterwards) Or enter (possibly with middle-mouse-click): "DK0:[MICROCT.DATA.00001234.00003456]ANIMATION_" to have the result go to the measurement directory.
  • Click on the 'Auto-Print' box. Then 'ok'
  • Adjust the number of views (e.g. 200), then click on 'Start Calculation', and it will render. This may well take a long time.
  • Take those TIFF files to your PC, and combine the sequences in the program that you are using to convert the TIFF files to AVI or MOV files (like Windows Movie Maker 2, or Quick Time Pro, or Adobe Premiere etc.)

Notes/Hints:

  • The order in the above list can also be reversed: You can first set up the 'Auto-Print', and then go into the 'Animation' menu, choose start and end settings, and hit 'Start Calculation'
  • The positions A and B can be any: e.g. with subdim, you can first take everything (A), then slide it back to nothing (B).
  • You can even slowly change the color of an object. Or slowly hiding objects: choose 'transparent' for object, but change from 0.0 (A) to 1.0 (B)
  • If you want to create a movie with different sections, e.g. first rotate around, then slowly make bone transparent, then cut in: Do this in multiple sections with the 3D program, e.g. first create Auto-Print files 'rotation_0000 to rotation_0200', then 'transp_0000 to transp_0050', and then 'cut_0000 to cut_0100'. Make sure ALL the settings from the last view of the previous section match those of the first view of the next section so you get smoot transitions.
  • The 'Auto-Print' box is also usable without the 'Animation' Menu: Activate it, Like above, with sys$scratch:test_ only the beginning of filename. 'ok' Then, whenever a 3D image is completely built-up (so when you are happy with a view and you do not interrupt the build-up), automatically a TIF file is generated, numbered sequentially.

Convert AIM to TIF series

Use the utility SEQ_TO_IMAGE located in the UT directory. A symbol has been set up to run this called TIF.

$ mcr ut:seq_to_image
Program: seq_to_image V1.1b
Input-File []: WISDOM_L_R05.AIM
File Format [TIF]: 
Default TIF Names: WISDOM_L_R05_xxxx.TIF

Output-File [WISDOM_L_R05]: 
!> Reading AimVersion020 
Start Slice [0]: 
End Slice [179]: 5
Number of images thereof (count) [6]: 
Scale Factor (Integer) [1]: 
global_pos (1=true, 0=false) [0]: 
Max value to norm to 255 [32767]: 
Slice: 0
Slice: 1
Slice: 2
Slice: 3
Slice: 4
Slice: 5
$ dir wisdom*

Directory DISK1:[MICROCT.SCRATCH]

WISDOM_L_R05.AIM;1  WISDOM_L_R05_0000.TIF;1                 WISDOM_L_R05_0001.TIF;1
WISDOM_L_R05_0002.TIF;1                 WISDOM_L_R05_0003.TIF;1
WISDOM_L_R05_0004.TIF;1                 WISDOM_L_R05_0005.TIF;1

Total of 7 files.
$ 

Writing Scripts

HowTo: Get information about a sample or measurement from database

The following will create a sys$scratch:info.txt file.

$ write_info

HowTo: Create an MSQ image and view it

This is based on marching cubes. See IPL_UPAT_EVAL.COM for an example as per below:

/read seg C0000214_SEG.AIM

/sup_divide                               ! careful of the order of inputs here
  -input                     seg
  -suppos_pixels_local       -1 -1 -1
  -supdim_numbers            1 2 1
  -subdim_pixels             -1 -1 -1
  -testoff_pixels            0 0 0

/sub_pick
  -input                     seg
  -output                    segsub
  -subpos_numbers            0 1 0

/tri
  -input                     segsub
  -output                    tri
  -gobj_filename             none
  -peel_iter                 0
  -ip_sigma                  0.8
  -ip_support                1
  -ip_threshold              40
  -nr_ave_iter               2
  -size_image                512 512
  -scale_image               0.800000
  -edges                     false
  -nr_views                  1             ! Important

/msq_from_aim
  -aim_name                  tri
  -msq_filename              C0000123_3D.MSQ

Then, use UCT_3D to view it. If you click on "animations" it will give you the option to read the MSQ file.

HowTo: Create your own IPL script with some tips

To make a script that would submit a job to the queue with the command as follows:

$ @um:ipl_eval_only.com 'aim_file' 'gobj_file' 'p1' 0

you need to create your own IPL file would be translated to the following command:

$ submit /noprint /que=sys$slow ue:IPL_VOI_JOSH_M.COM 
  - /log=sys$scratch:test.log /para=('aim_file','gobj_file','seg_file')

The IPL file would look something like this…

$   if p1 .EQS. "" 
$ 	THEN 
$	write sys$output "Give DK0:[xxx]C0001234_SEG.aim on the line."
$	write sys$output "Or: "
$	write sys$output "Type $ scanco_submit_command um:ipl_eval_autostart/para=(dk0:[xxx]c00123_seg.aim) "
$ 	exit
$   endif
$
$ gobj_file = p1-F$PARSE(p1,,,"VERSION")-"_SEG.AIM" + ".GOBJ"
$ aim_file = p1-F$PARSE(p1,,,"VERSION")-"_SEG.AIM" + ".AIM"
$
$!
$ @um:ipl_eval_only.com 'aim_file' 'gobj_file' 'p1' 0
$ exit

Some more handy IPL sequences are:

$    INPUT = F$SEARCH("UCT_MEASUREMENT_DATA:[*.*''P1']*.RSQ",1)

and then you just need to give meas. number as P1 (and maybe slice range as p2),

$ if p2 .eqs. "" then p2 := A

OR, some nice starts are:

$    IF P3 .EQS. ""
$    THEN
$      WRITE SYS$OUTPUT "P1: Measurement Number to duplicate"
$      WRITE SYS$OUTPUT "P2: New Sample Number from Database"
$      WRITE SYS$OUTPUT "P3: New Start Letter of ISQ file"
$      WRITE SYS$OUTPUT "P4: Optional: Operator Number"
$      WRITE SYS$OUTPUT "P5: Optional: Controlfile Number"
$      EXIT
$    ENDIF

where you say which parameters HAVE to be there (up to p3), and which ones are optional.

All together, the script may look like this:

$    IF P1 .EQS. "" 
$    THEN 
$      WRITE SYS$OUTPUT "P1: Measurement Number to reco" 
$      WRITE SYS$OUTPUT "P2: Optional: Slice number N or Range M:N. Auto:All" 
$      WRITE SYS$OUTPUT "P3: Optional: Queue. Auto: sys$slow" 
$      EXIT 
$    ENDIF 
$ if p2 .eqs. "" then p2 := A 
$ if p3 .eqs. "" then p3 := SYS$SLOW 
$ slices  = p2 
$ quename = p3 
$ INPUT = F$SEARCH("UCT_MEASUREMENT_DATA:[*.*''P1']*.RSQ",1) 
$ INPUT = INPUT - F$PARSE(INPUT,,,"VERSION") 
$ logfile = "sys$scratch:RECO_" + f$PARSE(input,,,"NAME") + ".LOG" 
$ submit/noprint/queue='quename' uct_reconstruction_file - 
    /para=('input','slices','logfile') 
$ exit

Note that uct_reconstruction_file is a logical that points to um:uct_reconstruction.com.

Logicals are preferred in scripts to make them more universal.

General

Wireless Network in Morphometrics Lab

The network is hidden so that we don't get any unwelcome guests or trouble from the internet Nazis in HiiTec.

SSID (network name): bhlab
WPA2 encryption key: hallgrimssonboyd


Errors and Fixes

HowTo: Align the whole body device to be in the field of view

It's important to have your whole sample in the field of view for accurate density measurements. Follow the instructions in this PDF to align the device.

HowTo: Fix "last slice" error problem when extracting AIM from ISQ

Sometimes the evaluation script (i.e., voi) converting the ISQ to an AIM fails because it tries to read one slice more than what is available in the ISQ data. The result of this failure is that the 3D analysis appears to fail and no .AIM or _SEG.AIM is created in the data directory. For example, it may have tried to read 261 slices, but there were only 260 slices available. The easiest work around is to make sure that the white bounding box in the uct_evaluation program does not include the last slice (largest Z dimension). Scanco is aware of this problem and will fix it in future software releases (V5.2).

HowTo: Fix sample data when results fail to print/list/show after evaluation

There are a number of reasons the results may not print:

Incorrect first measurement number

When sample information (such as patient name, DOB, remark) is changed DURING scanning, this can over write the 1st Scan measurement number, resulting in the evaluation sheet not being printed, and data not shown when running upat_list. For example, this happens when:

1) open sample program, enter name, hit save, leave program open

2) start scan (which would write correct record with 1st meas. in sample database)

3) in sample program: then only enter DOB, and hit 'save' again in the sample program --> it 'overwrites' the 1st meas. with an empty string again.

If you want to enter DOB after the scan has started, you HAVE to 'Find...' and re-load that patient first (so it correctly loads the 1st meas. entry also). It is best to just not use the sample management program whilst scanning is taking place.

However, if you do encounter this problem, use the following to fix (shown using patient 668 as an example. 1st scan measurement number was 2672):

 $ set host 0
 calibration
 xxxxx

 $ spb
 $ @[microct]microct_setup
 $ run [calibration.util]uct_correct_first
 $ r UCT_CORRECT_FIRST

 Patient Nr.: 668
 SampleNr.:          668
 First:            0

 2672

 Patient Nr.:

and continue with next non-working patient, give patient number 0 to exit.

$ logout

Evaluation completed (aim files produced) but results not written to database

If the first measurement number and DOB are correct... check the .log file of the evaluation... However, if there is no upat*.log file available for that scan, use:

upat_list -v=2 and you will see (for eg sample 594):

Found sample 594, CAMOS_0018
Found measurement 2536 made 19-MAR-2007 12:52:58.48
Measurement site RL found in list at index 0
Measurement 2536 within measurement period
ERROR finding evaluation for measurement 2536

No valid evaluation found for measurement 2536

So it seems the 3D upat eval never wrote anything to the database for that scan. In this case, you can run:

$ @ue:ipl_upat_eval_again_quick.com

and let it run for the missing data. NOTE it will only need the aim files and gobj files that you still have in your 'models' directory.

Incorrect sequence of measurement numbers

Finally, if none of these options work... check the order of measurement numbers: especially if an import has occured, first check the first measurement number is correct (as above). Then run sys$Scratch:uct_correct_prev_next.exe and correct the order of the measurements: The database keeps a 'daisy' chain of meas. numbers, each meas. knows which one was the previous meas and the next meas.

0 means: no prev. meas (or no next meas) So corrected the order for you like this:

$ r UCT_CORRECT_prev_next

Measurement No. (0 to stop) [0]: 2821
MeasNo.:         2821 PatientNo:          723

Previous [0]:   <-- leave 0
Next     [0]: 2828  <-- give next meas number
Measurement No. (0 to stop) [2828]:
MeasNo.:         2828 PatientNo:          723

Previous [0]: 2821  <-- give prev. meas number
Next     [0]:  <-- leave 0 for very last meas.

Please note: the series of meas. numbers per patient is NOT separate per meas. site, thus radius and tibia meas. are linking to each other. Do not mess up!

File Transfer

HowTo: SC5019 (vivaCT) files to Sodor

$ ftp hal.kin.ucalgary.ca
220 Microsoft FTP Service
Connected to hal.kin.ucalgary.ca. 
Name (hal.kin.ucalgary.ca:microct): hpl-nt\skboyd
331 Password required for hpl-nt\skboyd.
Password: 
230 User hpl-nt\skboyd logged in.
FTP> 

Note that you can log in as either:

  • hpl-nt\skboyd
  • skboyd@kin.ucalgary.ca

On the HPL network, open the window file program and type: \\hal\FTP Home

Other options for file transfer:

$ sftp   ! haven't tried it much
$ scp    ! doesn't work well with openvms

HowTo: FTP to douglas and donald (only in KIN network)

There are FTP servers running on douglas and donald for file transfer WITHIN the KIN network only, e.g. percy or your PC. If you are connecting from home, establish a PPTP VPN connection to nt-hpl first to be virtually in the KIN network. Access from scanners at the hospital (VivaCT) is not possible at the moment. Use user guest and correpsonding password for login to either douglas.kin.ucalgary.ca or donald.kin.ucalgary.ca:

$ douglas.kin.ucalgary.ca
220 Welcome to Dougla's FTP Service
Name (douglas.kin.ucalgary.ca:ypauchard): guest
331 Password required for guest.
Password: 
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
FTP> 

Scanco Finite Element Analysis

Running the FE code on the VMS system

Read the PDF file that is located in the "documents" directory for documentation and pick a problem number and output type. Make sure that your image is suitable for the slected analysis (see page 7 in the Scanco FE guide). You can use your segmented AIM from morphological analysis for FE analysis.

Edit the IPl file used in batch job mode DISK1:[MICROCT.EVAL]IPL_FE_VM.COM on percy to include the desired analysis, e.g.:

FE_PROBLEM :== 9 !combination of 1 - 6
FE_PAR_NO :== 42 ! von Mises equivalent stress

Start the evaluation as a batch job in queue SC3309_FE

$ fem DISK3:[MICROCT.PROJECTS.DEFROM.MODELS]SHAM_A12_W12_SEG.AIM

Look at the log file SYS$SCRATCH:SHAM_A12_W12_SEG_FE.LOG during execution to verify the process.

The job is submitted using:

SUBMIT/NOPRINT/NOTIF/LOG=SYS$SCRATCH:SHAM_A12_W12_SEG_FE.LOG/QUE=UCT_FE_QUEUE UE:IPL_FE_VM.COM/PARA=DISK3:[MICROCT.PROJECTS.DEFROM.MODELS]SHAM_A12_W12_SEG.AIM

You can copy the IPL_FE_VM.COM to your project directory and use the above command to submit it.

Alternatively, FE analysis can be run interactively

$ iplfe

Extracting results

Creates a total result file called .post file. Then, by default, it extracts one parameter (e.g. von mises stress), and produces stats file .postlist and a colorful .aim file (_fe_par_42.aim) which you can view with uct_3d.

If you then want other parameters extracted, or other colorful images, you only need to do a very quick operation in iplfe:

$ iplfe
/fe_post

give .post file and write out the resulting .aim file, and it produces also the .postlist file.

Scanco Image Registration

On percy, check out the DISK1:[MICROCT.EVAL]IPL_REGISTER*.COM scripts. You can also use it interactively by starting

$ iplreg
ipl> register
ipl> transform

Use the ipl help function for more info and read the PDF guide (in Documents).

SimilarityRegistration

Understanding rotation parameters (versors)

In SimilarityRegistration, former AppSimilarityRegistrationV3, used when registering images with Shape, the config file allows for setting inital rotations initial_transform_axis_x, initial_transform_axis_y, initial_transform_axis_z. These correspond to the versor components and are calculated as follows:

initial_transform_axis_x = n_x * sin(alpha/2)
initial_transform_axis_y = n_y * sin(alpha/2)
initial_transform_axis_z = n_z * sin(alpha/2)

where n=[n_x,n_y,n_z]^T is the unit vecotr representing the axis of rotation and alpha is the angle of rotation. Example 45 degree rotation around x-axis:

initial_transform_axis_x = 1 * sin(45/2) = 0.382
initial_transform_axis_y = 0 * sin(45/2) = 0
initial_transform_axis_z = 0 * sin(45/2) = 0

The rotations after registration final_transform_axis_x, final_transform_axis_y, final_transform_axis_z can be interpreted the same way. ITK provides the functions GetAxis() and GetAngle to obtain [n_x, n_y, n_z] and alpha respectively, which are calculated as follows:

v_1 = initial_transform_axis_x
v_2 = initial_transform_axis_y
v_3 = initial_transform_axis_z
magnitude = sqrt(v_1^2 + v_2^2 + v_3^2)
n_x = v_1/magnitude
n_y = v_2/magnitude
n_z = v_3/magnitude
alpha = 2 * atan(magnitude/1)

Statistics and Analysis

JAGS (analysis of Bayesian models using Markov Chain Monte Carlo)

See JAGS Usage.