How To's: Difference between revisions

From bone.wiki
Jump to navigation Jump to search
Redirecting to Main Page
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
__TOC__
#REDIRECT [[Main Page]]
 
 
 
 
=HowTo Library=
 
:In addition to this HowTo library, much information is also available at the [http://www.scanco.ch/cgi-bin/scanco.pl?menu=support&site=faq Scanco Medical FAQ].
:*users@scanco.ch
:*basser5dorf
 
 
 
 
 
 
 
 
 
==Print outs and visualization==
 
===HowTo: Print out report sheets===
 
The postscript report sheets can be generated and printed on the command line.  For the XtremeCT system, use <code>UPAT_PRINT_LIST.EXE</code> which can be run (using the symbol):
<pre>
$ UPAT_LIST
</pre>
 
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:
<pre>
$ UPAT_LIST -h
</pre>
 
One particular option that may be useful, is to turn off slice matching:
<pre>
$ UPAT_LIST -nomatch
</pre>
 
 
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:
<pre>
$ RUN UM:UCT_RAY_BATCH.EXE
</pre>
 
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 <code>SYS$SCRATCH</code> 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:
<pre>
$ @COM:PRINT_2D.COM
$ @COM:PRINT_3D.COM
</pre>
 
===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.
 
<pre>
$ ipl
/read all xx_all.aim
/read trab xx_seg.aim
/transparent
  -input_solid              trab
  -input_transp              all
  -output                    out
</pre>
 
Note: the solid volume is OVERWRITING the transparent input volume, so usually, it
is the smaller (inner) of the two.
 
<pre>
/write out xxx_transp.aim
/quit
</pre>
 
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.
 
<b>Step by Step Example:</b> 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
 
<b>Step by Step Example:</b> 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'
 
<b>Note:</b> 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.)
 
<b>Notes/Hints:</b>
:* 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.
 
<pre>
$ 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.
$
</pre>
 
==Writing Scripts==
 
===HowTo: Get information about a sample or measurement from database===
 
The following will create a <code>sys$scratch:info.txt</code> file.
<pre>$ write_info</pre>
 
===HowTo: Create an MSQ image and view it===
 
This is based on marching cubes.  See <code>IPL_UPAT_EVAL.COM</code> for an example as per below:
 
<pre>
/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
</pre>
 
Then, use <code>UCT_3D</code> 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:
<pre>
$ @um:ipl_eval_only.com 'aim_file' 'gobj_file' 'p1' 0
</pre>
 
you need to create your own IPL file would be translated to the following command:
<pre>
$ submit /noprint /que=sys$slow ue:IPL_VOI_JOSH_M.COM
  - /log=sys$scratch:test.log /para=('aim_file','gobj_file','seg_file')
</pre>
The IPL file would look something like this…
<pre>
$  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
</pre>
 
Some more handy IPL sequences are:
<pre>
$    INPUT = F$SEARCH("UCT_MEASUREMENT_DATA:[*.*''P1']*.RSQ",1)
</pre>
 
and then you just need to give meas. number as P1 (and maybe slice range as p2),
<pre>
$ if p2 .eqs. "" then p2 := A
</pre>
OR, some nice starts are:
<pre>
$    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
</pre>
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:
<pre>
$    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
</pre>
Note that <code>uct_reconstruction_file</code> is a logical that points to <code>um:uct_reconstruction.com</code>.
 
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.
<pre>
SSID (network name): bhlab
WPA2 encryption key: hallgrimssonboyd
</pre>
 
 
==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 [[Media:wholebody.pdf | 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):
<pre>
$ 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.:
</pre>
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):
 
<pre>
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
</pre>
 
So it seems the 3D upat eval never wrote anything to the database for that scan. In this case, you can run:
 
<pre>
$ @ue:ipl_upat_eval_again_quick.com
</pre>
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:
 
<pre>
$ 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.
 
</pre>
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===
 
<pre>
$ 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>
</pre>
 
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:
<code>
\\hal\FTP Home
</code>
 
Other options for file transfer:
<pre>
$ sftp  ! haven't tried it much
$ scp    ! doesn't work well with openvms
</pre>
 
===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:
<pre>
$ 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>
</pre>
 
==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 <code>DISK1:[MICROCT.EVAL]IPL_FE_VM.COM</code> on percy to include the desired analysis, e.g.:
<pre>
FE_PROBLEM :== 9 !combination of 1 - 6
FE_PAR_NO :== 42 ! von Mises equivalent stress
</pre>
 
Start the evaluation as a batch job in queue SC3309_FE
<pre>$ fem DISK3:[MICROCT.PROJECTS.DEFROM.MODELS]SHAM_A12_W12_SEG.AIM</pre>
 
Look at the log file <code>SYS$SCRATCH:SHAM_A12_W12_SEG_FE.LOG</code> during execution to  verify the process.
 
The job is submitted using:
<pre>
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
</pre>
You can copy the <code>IPL_FE_VM.COM</code> to your project directory and use the above command to submit it.
 
Alternatively, FE analysis can be run interactively
<pre>$ iplfe</pre>
 
===Extracting results===
 
Creates a total result file called <code>.post</code> file. 
Then, by default, it extracts one parameter (e.g. von mises stress), and produces stats file
<code>.postlist</code> and a colorful <code>.aim</code> file (<code>_fe_par_42.aim</code>)
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:
<pre>
$ iplfe
/fe_post
</pre>
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 <code>DISK1:[MICROCT.EVAL]IPL_REGISTER*.COM</code> scripts.
You can also use it interactively by starting
<pre>
$ iplreg
ipl> register
ipl> transform
</pre>
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 <code>initial_transform_axis_x, initial_transform_axis_y, initial_transform_axis_z</code>. These correspond to the versor components and are calculated as follows:
<pre>
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)
</pre>
where <code>n=[n_x,n_y,n_z]^T</code> is the unit vecotr representing the axis of rotation and <code>alpha</code> is the angle of rotation. Example 45 degree rotation around x-axis:
<pre>
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
</pre>
The rotations after registration <code>final_transform_axis_x, final_transform_axis_y, final_transform_axis_z</code> can be interpreted the same way.
ITK provides the functions GetAxis() and GetAngle to obtain <code>[n_x, n_y, n_z]</code> and <code>alpha</code> respectively, which are calculated as follows:
<pre>
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)
</pre>
 
==Statistics and Analysis==
 
===JAGS (analysis of Bayesian models using Markov Chain Monte Carlo)===
 
See [[JAGS Usage]].

Latest revision as of 15:48, 16 September 2010

Redirect to: