OPEN3D

Purpose:   Starts the 3D engine and loads the initialization parameters from a text file.

Format:    open3d  filename

Notes:    Use the OPEN3D command to load a list of images and supply the initialization parameters before starting the 3D engine.  filename  must a valid text filename.  The file must conform to the following:
 

Line #
Parameter
Description
1
3DCMD This is the ID, indicates 3D commands to follow
2
number of images The number of image files to load in the 3D Engine
3
pixel size The pixel size in CM
4
slice thickness The slice thickness in MM (z axis of the voxel)
*
CUTOUT
(optional)
This will set the thresholds for the cutouts.  Following the "CUTOUT"  line,  6 lines of numeric values will specify the following:

All Min
All Max
Include Min
Include Max
Exclude Min
Exclude Max

 * 
COORD 
(optional)
This will set the rendering angles.  Following the "CUTOUT"  line,  3 lines of numeric values will specify the following:

Yaw
Pitch
Roll

 * 
RENDER
(optional)
Construct and render using the above parameters.
End of File filenames This is the list of image files to follow the above parameters. The number of lines to read is specified by the  number of images  parameters in line 2.

 

Example:

Description "MRI 3D &Angio"

# Read info from proc.q file

$procq = $temppath "\proc.q"

input_file $procq
finput parent
finput $scriptname
finput $infile
finput op
finput sx
finput sy
finput ex
finput ey
finput orig_width
finput orig_height
finput orig_offset
finput orig_type
finput pix_correct
finput pixsize
finput dontcare
finput dontcare
finput dontcare
finput dontcare
finput dontcare
finput dontcare
finput zoom
finput dontcare

#
# Script start-up initialization
#

if op ! 2
 viewer autoroi on
 viewer clear
 viewer tool rectangle
 viewer notify
 delete $procq
 message "Select ROI..."
 exit
endif

thresh = 2000
input thresh "Initial Minimum Cutoff"

viewer autoroi off
viewer clear
viewer tool arrow
viewer notify

size = (orig_width * orig_height) + 1024
allocate size
 

##############################################################################

$filelist = $temppath "\filelist.q"
input_file $filelist
finput parent
finput numimgs
numfiles = numimgs
$olist = $temppath "\angiolist.q"
delete $olist
print_file $olist
fprint "3DCMD"
fprint numimgs
pixsize = pixsize * 0.1
fprint pixsize
dicomtag $slice 0x00180050
fprint $slice
fprint "CUTOUT"
fprint thresh
fprint 8000
fprint 0
fprint 8000
fprint 0
fprint 8000
fprint "COORD"
fprint 150
fprint 264
fprint 180
fprint "RENDER"
 

$ofile = $temppath "\angio-01.img"
$tfilea = $temppath "\ta.img"
z = 0

*MAIN

 finput $infile
 fprint $ofile

 viewer display $infile
 viewer notify

 gosub GetBox

 convolve $tfilea smooth3.ker
 median $tfilea $ofile 3

 z = z + 1
 message "Pre-Processing Image: " z
 

numimgs = numimgs - 1
if numimgs > 0
 nextfile $ofile
 clear
 goto MAIN
endif
 

open3d $olist

exit
 

*GetBox

#
# Correct for proper corner orientation.
#
 ulx = sx
 uly = sy
 lrx = ex
 lry = ey

 if sx > ex
  ulx = ex
  lrx = sx
 endif
 if sy > ey
  uly = ey
  lry = sy
 endif

#
# Ensure that we're within the image
#
 range = 1
 if ex > orig_width
  range = -1
 endif

 if ey > orig_height
  range = -2
 endif

 if range < 0
  pause "Region outside of image dimensions: " range
 endif

 if lry > (orig_height - 1)
  lry = orig_height - 1
 endif

 if lrx > (orig_width - 1)
  lrx = orig_width - 1
 endif

 orig_total = orig_width * orig_height
 roi_height = lry - uly
 roi_width = lrx - ulx
 roi_total = roi_height * roi_width
 

 if roi_height < 2
 if roi_width < 2
  exit
 endif
 endif
#
# Read the rectangular region into memory
#

 pixpos = (uly * orig_width) + ulx
 a = 0
 v = 0
 loop begin roi_height
  loop begin roi_width
    getpixel pixel pixpos
    memory(a) = pixel
    a = a + 1
    pixpos = pixpos + 1
  loop end
  v = v + 1
  pixpos = ((uly + v) * orig_width) + ulx
 loop end
 

 roi_pixels = roi_width * roi_height
 image_width = roi_width
 image_height = roi_height
 image_type = 2
 a = 0
 outfile $tfilea
 process begin
  out = memory(a)
  a = a + 1
 process end
 

RETURN