This page was created by the IDL library routine
mk_html_help. For more information on
this routine, refer to the IDL Online Help Navigator
or type:
? mk_html_help
at the IDL command line prompt.
Last modified: Fri Dec 4 10:39:05 2009.
NAME:
BACKPROJECT
PURPOSE:
Reconstructs a sinogram into an image using backprojection.
CATEGORY:
Tomography data processing
CALLING SEQUENCE:
Result = BACKPROJECT(Sinogram, Angles)
INPUTS:
Sinogram:
The input sinogram, dimensions NX x NANGLES. This should have been
filtered before calling this function.
Angles:
An array of dimensions NANGLES which contains the angle in degrees of
each projection.
KEYWORD PARAMETERS:
This function accepts the BILINEAR and CUBIC keywords accepted by the
IDL RIEMANN procedure.
OUTPUTS:
This function returns the reconstructed image.
RESTRICTIONS:
This function does not yet properly scale the result. This will be fixed
in the near future.
PROCEDURE:
This function simply calls the IDL RIEMANN procedure for each row in the
sinogram, using the ROW and BACKPROJECT keywords. The BILINEAR and CUBIC
keywords are passed from BACKPROJECT to RIEMANN if they are present.
EXAMPLE:
r = backproject(sinogram, angles)
MODIFICATION HISTORY:
Written by: Mark Rivers, May 13, 1998
21-APR-1999 MLR Changed function to use keyword inheritance (_EXTRA) rather
than hardcoding the BINLINEAR and CUBIC keywords
18-MAY-1999 MLR Changed function back to hardcoding the BINLINEAR and
CUBIC keywords, because the CENTER keyword was causing
problems with keyword inheritance when called from
RECONSTRUCT_SLICE, since CENTER is also used by SINOGRAM.
20-FEB-2000 MLR Set all pixels outside reconstructed area to 0.
19-APR-2001 MLR Change units of ANGLES from radians to degrees
(See backproject.pro)
NAME:
GRIDREC
PURPOSE:
Performs tomographic reconstruction using the "gridrec" algorithm written
by Bob Marr and Graham Campbell (not sure about authors) at BNL in 1997.
The basic algorithm is based on FFTs. It reconstructs 2 data sets at once,
one in the real part of the FFT and one in the imaginary part.
This routine is 20-40 times faster than BACKPROJECT, and yields virtually
identical reconstructions.
This file uses CALL_EXTERNAL to call GridrecIDL.c which is a thin
wrapper to grid.c,
CATEGORY:
Tomography data processing
CALLING SEQUENCE:
GRIDREC, Sinogram1, Sinogram2, Angles, Image1, Image2
INPUTS:
Sinogram1:
The first input sinogram, dimensions NX x NANGLES.
Sinogram2:
The second input sinogram, dimensions NX x NANGLES.
Angles:
An array of dimensions NANGLES which contains the angle in degrees of
each projection.
KEYWORD PARAMETERS:
CENTER: The column containing the rotation axis. The default is the center
of the sinogram.
SAMPL: The "sampl" parameter used by grid.c. Meaning not certain. Default=1.2
C: The "C" parameter used by grid.c. Meaning not certain. Default=6.0
R: The "R" parameter used by grid.c. Meaning not certain. Default=1.0
MAXPIXSIZE: The "MaxPixSize" parameter used by grid.c. Meaning not certain.
Default=1.0
X0: The "X0" parameter used by grid.c. Meaning not certain. Default=0.0
Y0: The "Y0" parameter used by grid.c. Meaning not certain. Default=0.0
LTBL: The "ltbl" parameter used by grid.c. Meaning not certain. Default=512.
FILTER_NAME: The "filter" parameter used by grid.c. Character string. Default="shepp".
GEOM: The "geom" parameter used by grid.c.
0 = The actual angles in degrees are passed to grid.c. This is the
default.
1 = Assume angles go from 0 to 180-delta, evenly spaced
1 = Assume angles go from 0 to 360-delta, evenly spaced
DEBUG: Set this flag to enable debugging printing from the C code.
OUTPUTS:
Image1:
The reconstructed image from Sinogram1.
Image2:
The reconstructed image from Sinogram2.
Note that the sizes of Image1 and Image2 are controlled by "grid" and will not
be equal NX*NX. RECONSTRUCT_SLICE uses the IDL routine CONGRID to resize the
images to be NX*NX.
PROCEDURE:
This function uses CALL_EXTERNAL to call the shareable library GridrecIDL,
which is written in C.
RESTRICTIONS:
GRIDREC locates the GridrecIDL shareable library via the environment variable
GRIDREC_SHARE. This environment variable must be defined and must contain the
name (typically including the path) to a valid shareable library or DLL.
EXAMPLE:
GRIDREC, s1, s2, angles, image1, image2, center=419
MODIFICATION HISTORY:
Written by: Mark Rivers, March 4, 2000
19-APR-2001 MLR Change units of ANGLES from radians to degrees. Write
documentation header.
(See gridrec.pro)
NAME:
READ_TOMO_DATA
PURPOSE:
This procedure reads a tomography data set from individual Princeton
Instruments .SPE files. It writes a 3-D volume file to disk.
This function is a simple wrapper around TOMO::PREPROCESS.
See the documentation for TOMO::PREPROCESS
for information on the input parameters and other details.
PROCEDURE:
This function simply creates a TOMO object and calls TOMO::PREPROCESS.
EXAMPLE:
The following example will read files Mydata1.SPE through Mydata370.SPE,
using a constant dark current of 50 counts at each pixel. This data set
is assumed to have white field frames in it. The output file will be
Mydata.volume
IDL> READ_TOMO_DATA, 'Mydata', 1, 370, dark=50
; Now read the volume file back into IDL
IDL> vol = READ_TOMO_VOLUME('Mydata.volume')
; Play the volume data as a movie, rotating the sample
IDL> window, 0
IDL> make_movie, vol, min=3000, max=12000
MODIFICATION HISTORY:
Written by: Mark Rivers, March 27, 1999.
3-APR-1999 MLR Changed white field normalization to use weighted average
of white fields before and after, rather than simple
average
4-APR-1999 MLR Changed the default value of threshold from 1.20 to 1.05
Switched to double correlation method of zinger removal
for white field images when possible.
18-MAY-1999 MLR Added missing keyword DOUBLE_THRESHOLD to procedure line
07-JUL-1999 MLR Changed zinger removal for data frames so it is done after
whitefield correction. This makes the identification of
zingers (versus high-frequency structure in the whitefield)
much more robust.
13-SEP-1999 MLR Changed the dark current correction to use a loop, so that
two large arrays are not required at the same time.
08-DEC-1999 MLR Added FIRST_ROW and LAST_ROW keywords for handling very
large data sets.
Added OUTPUT keyword
02-MAR-2000 MLR Added DEBUG keyword to calls to REMOVE_TOMO_ARTIFACTS
large data sets.
02-MAR-2000 MLR Changed the default value of THRESHOLD from 1.05 to 1.25
because the lower threshold was causing significant
blurring of sharp edges. Changed the default value of
DOUBLE_THRESHOLD from 1.02 to 1.05, since it was finding
many more zingers than physically plausible.
02-MAR-2000 MLR Added SWAP_IF_BIG_ENDIAN keyword when opening output file.
22-JAN-2001 MLR Added some default debugging when writing output file
11-APR-2001 MLR Put the original version in the TOMO class library and renamed
the procedure there PREPROCESS rather than READ_TOMO_DATA.
Made this procedure simply create a TOMO object and call
TOMO::PREPROCESS.
(See read_tomo_data.pro)
NAME:
READ_TOMO_VOLUME
PURPOSE:
Reads in 3-D volume files written by WRITE_TOMO_VOLUME or TOMO::WRITE_VOLUME.
This function is a simple wrapper around TOMO::READ_VOLUME.
See the documentation for TOMO::READ_VOLUME
for information on the input parameters and other details.
PROCEDURE:
This function simply creates a TOMO object and calls TOMO::READ_VOLUME.
EXAMPLE:
volume = READ_TOMO_VOLUME('diamond2.volume')
MODIFICATION HISTORY:
Written by: Mark Rivers, May 13, 1998
06-APR-1999 MLR Made file input optional, puts up dialog if it is not
specified
25-JAN-2000 MLR Added /swap_if_big_endian keyword to openr to allow
files to be read on big-endian machines.
23-FEB-2000 MLR Added xrange, yrange, zrange keywords
11-APR-2001 MLR Put the original version in the TOMO class library, made this
function simply create a TOMO object and call TOMO::READ_VOLUME.
(See read_tomo_volume.pro)
NAME:
RECONSTRUCT_SLICE
PURPOSE:
Reconstructs a single slice in a tomography volume array.
CATEGORY:
Tomography data processing
CALLING SEQUENCE:
Result = RECONSTRUCT_SLICE(Slice, Volume)
INPUTS:
Slice: The number of the slice to be reconstructed.
Volume: The 3-D volume array from which the slice is extracted
KEYWORD PARAMETERS:
NORING:
Setting this keyword prevents the function from removing ring
artifacts.
PIXEL_SIZE:
Specifies the size of each pixel. This is used only when the NORMALIZE
keyword is also set. The normalized output will be in units of
"mu" in inverse length, where the units are controlled by the value
specified for pixel size. For example, if the pixels are 10 microns
and the user specifies PIXEL_SIZE=.01 then the normalized values will
be inverse mm. If the user specifies PIXEL_SIZE=.001 then the
output will be inverse cm, etc. The default value is 1, which means
that the normalized output will be mu per pixel.
NORMALIZE:
Specifies that the output is to be normalized to absolute absorption
units. If the SCALE keyword is not specified then this is done by
normalizing the reconstructed slice to have the same integrated area
as the average sum of each row of the sinogram.
SCALE:
Specifies the scale factor to be used in normalizing the output. This
is only meaningful when the NORMALIZE keyword is used. The default
value of SCALE is obtained normalizing the reconstructed slice to
have the same integrated area as the average sum of each row of the
sinogram, and this value is printed out. The SCALE value can also be
explicitly set. This is typically done under the following conditions:
1) Reconstruct a few slices using /NORMALIZE but without specifying
SCALE. Note the average value of SCALE printed out by this
routine for these slices.
2) Reconstruct the entire volume with RECONSTRUCT_VOLUME, specifying
both /NORMALIZE and SCALE=scale, using the scale factor found in
step 1 above.
Doing these steps ensures that exactly the same scale factor is used
for normalizing each slice of the reconstructed volume. This is
probably more accurate than using slightly different normalizing
factors for each slice.
ANGLES:
An array of angles (in degrees) at which each projection was collected.
If this keyword is not specified then the routine assumes that the data was
collected in evenly spaced increments of 180/n_angles.
All keywords accepted by SINOGRAM, GRIDREC and BACKPROJECT are passed to
those routines via keyword inheritance
OUTPUTS:
This function returns the reconstructed slice. It is a floating point
array of dimensions NX x NX.
PROCEDURE:
Does the following: extracts the slice, computes the sinogram with
centering and optional center tweaking, removes ring artifacts, filters
with a Shepp-Logan filter and backprojects. It also prints the time
required for each step at the end.
EXAMPLE:
r = reconstruct_slice(264, volume, tweak=-2)
MODIFICATION HISTORY:
Written by: Mark Rivers, May 13, 1998
05-APR-1999 MLR Fixed serious error. Angles were being computed wrong.
Previously it was calculating 0 to 180, rather than 0 to
180-angle_step
05-APR-1999 MLR Added FILTER_SIZE keyword, made the default be 1/4 of
the image width
18-MAY-1999 MLR Changed formal parameter _extra to _ref_extra to allow
CENTER keyword value to be returned from sinogram
20-FEB-2000 MLR Added NORMALIZE and PIXEL_SIZE keywords for normalization.
21-FEB-2000 MLR Added SCALE keyword for normalization.
06-MAR-2000 MLR Added support for GRIDREC reconstruction
22-JAN-2001 MLR Fixed bug in passing center to sinogram with Gridrec
11-APR-2001 MLR Added ANGLES keyword to allow specifying angle array
Added CENTER keyword, because 22-JAN-2001 change still did not
cause sinogram to ignore center keyword, which was passed both
explicitly and via EXTRA. Once that was fixed, however, it
was found to not yield the desired results with GRIDREC, because
part of the reconstructed object is not visible. Change to pass
center to sinogram even for gridrec.
17-APR-2001 MLR Changed call to GRIDREC to pass angle array.
Removed "center" keyword in call to GRIDREC, since sinogram
has padded the array to put the rotation axis in the center.
19-APR-2001 MLR Changed units of ANGLES from radians to degrees
25-NOV-2001 MLR Removed FILTER_SIZE keyword. This can now be passed to TOMO_FILTER
by keyword inheritance, and the default in TOMO_FILTER now is the
same as this routine previously used.
Removed /SHEPP_LOGAN keyword in call to TOMO_FILTER, this is the default.
Removed STOP keyword, the same result can be achieved with breakpoints.
16-AUG-2003 MLR Made /NORMALIZE work with Gridrec, not just with /BACKPROJECT
(See reconstruct_slice.pro)
NAME:
RECONSTRUCT_VOLUME
PURPOSE:
This procedure reconstructs a complete 3-D data set (X, Y, Theta) into a
3-D (X, Y, Z) volume. It reads its input from disk and writes its output
back to disk.
This procedure is a simple wrapper around TOMO::RECONSTRUCT_VOLUME().
See the documentation for TOMO::RECONSTRUCT_VOLUME
for information on the input parameters and other details.
EXAMPLE:
reconstruct_volume, 'FOSSIL1', CENTER=329
MODIFICATION HISTORY:
Written by: Mark Rivers, April 23, 1999
30-APR-1999 MLR Fixed bug introduced by new version of sinogram, need
to get size of reconstructed slices after centering
18-MAY-1999 MLR Changed formal parameter _extra to _ref_extra to allow
CENTER keyword value to be returned from sinogram (via
reconstruct_slice).
23-FEB-2000 MLR Pass extra keywords to read_tomo_volume
7-MAR-2000 MLR Added support for GRIDREC reconstruction, which reconstructs
2 slices at once.
2-JAN-2001 MLR Added CENTER keyword. If it is a 2-element array then the
center is interpolated.
11-APR-2001 MLR Put the original version in the TOMO class library, made this
procedure simply create a TOMO object and call
TOMO::RECONSTRUCT_VOLUME.
(See reconstruct_volume.pro)
NAME:
REMOVE_TOMO_ARTIFACTS
PURPOSE:
Removes artifacts from tomography images and sinograms.
CATEGORY:
Tomography data processing
CALLING SEQUENCE:
Result = REMOVE_TOMO_ARTIFACTS(Image)
INPUTS:
Image: The input array from which artifacts are to be removed.
KEYWORD PARAMETERS:
IMAGE2:
A second input and output image when doing DOUBLE_CORRELATION
ZINGERS:
Set this keyword to remove zingers from the input image
DOUBLE_CORRELATION:
Set this keyword to remove zingers from the input using double
correlation rather than a spatial detection
RINGS:
Set this keyword to remove ring artifacts from a sinogram
DIFFRACTION:
Set this keyword to removed diffraction artifacts from a sinogram
WIDTH:
Set this keyword to adjust the size of the filter kernal used in the
artifact removal. The default is 9 pixels.
THRESHOLD:
Set this keyword to adjust the threshold used in detecting zingers and
diffraction artifacts. The defaults are 1.2 for /ZINGER and
/DOUBLE_CORRELATION and 0.8 for/DIFFRACTION
DEBUG:
Set this keyword to print debugging information
OUTPUTS:
This function returns an image with the specified artifacts removed.
PROCEDURE:
THIS STILL NEEDS TO BE DOCUMENTED. For now, see the source code.
EXAMPLE:
r = remove_tomo_artifacts(sinogram, /Rings)
MODIFICATION HISTORY:
Written by: Mark Rivers, May 13, 1998
MLR 4/4/99 MLR Added DOUBLE_CORRELATION keyword
MLR 4/5/99 MLR Added /EDGE_TRUNCATE to all calls to SMOOTH so that
smoothing works to the edges of the image
(See remove_tomo_artifacts.pro)
NAME:
SINOGRAM
PURPOSE:
To convert raw tomography data into a sinogram.
CATEGORY:
Tomography
CALLING SEQUENCE:
result = SINOGRAM(Input, Angles)
INPUTS:
Input
An array of raw tomography data. INPUT(I, J) is the intensity at
position I for view angle J. Each row is assumed to contain at least
one air value at each end for normalization.
Angles
An array of the angles of each row of the input. Units are degrees.
KEYWORD PARAMETERS:
ACC_VALUES=acc_values
The number of values to be discarded at the beginning and end of each
row. These values are typically discarded because the stage was in its
acceleration/deceleration phase or because there are simply an
unecessarily large number of air values at the ends of each row.
The default value is 0.
AIR_VALUES=air_values
The number of air values to be averaged together at the beginning and
and of each row, after discarding the ACC_VALUES. This averaging is
done to decrease the statistical uncertainty in the air values.
The default value is 10.
COG=cog
This keyword is used to return the measured and fitted
center-of-gravity data for the sinogram. The center-of-gravity data are
very useful for diagnosing problems such as backlash, beam hardening,
detector saturation, etc. COG is dimensioned (n_angles, 2), where
n_angles is the number of angles in the input array. COG(*,0) is the
measured center-of-gravity data. COG(*,1) is the fitted data. The
following command can then be given after the SINOGRAM command
IDL> PLOT, COG(*,0)
IDL> OPLOT, COG(*,1)
to see is the sinogram data are reasonable.
/AUTO_CENTER
Used to specify that the rotation axis is to be automatically
determined by fitting the center of gravity data for the sinogram.
This operation is used to correct for the fact that the rotation axis
may not have been perfectly centered when the data were collected.
The default is not to auto center the rotation axis.
CENTER=center
If /AUTO_CENTER is specified then CENTER is an output value containing
the calculated column number of the rotation axis. If /AUTO_CENTER is
not specified then CENTER is an input value containing the column
number of the rotation axis. The units of CENTER are columns in the
input image, i.e. before additional air values are added to shift the
rotation axis position. If /AUTOCENTER is not specified and CENTER < 0
then centering is not done, i.e. it is treated as if the CENTER keyword was
absent.
/BACKLASH
Used to specify that even rows of the image are to be shifted left or
right so that the fitted rotation axis of the even rows is the same
as that for the odd rows. This is used to correct for backlash on
images done with first generation CT scans, when the scanning is
done bidirectionally.
The default is not to correct backlash.
/DEBUG
Used to turn on debugging output. The default is not to print
debugging output.
/FLUORESCENCE
Used to indicate that the data are fluoresence data rather than
absorption data. For fluoresence data the data are not normalized to
air on each side of the image, and the logarithm is not taken.
RETURN:
The output array containing the corrected sinogram. It is always of
type FLOAT.
PROCEDURE:
This routine creates a sinogram from raw tomography data. It does the
following:
- Converts to an odd number of columns (if necessary) by discarding
the last column
- Discards unwanted or uneeded pixels from the left and right edges
of the image. These could be values collected during motor
acceleration or extra air values which will simply slow down the
reconstruction.
"ACC_VALUES" pixels are discarded from both the left and right
edges of the array.
- Averages the air values for "air_values" pixels on the left and
right hand sides of the input.
- Logarithmation. output = -log(input/air). The air values are
interpolated between the averaged values for the left and right
hand edges of the image for each row. This step is not performed
if the /FLUORESCENCE keyword is set.
- Backlash correction (optional) If /BACKLASH is specified then
motor backlash is corrected for. This is done by fitting the
center-of-gravity separately for the even and odd rows of the
image and then shifting the even rows so the the rotation axes are
the same.
The measured center-of-gravity is fitted to a sinusoidal curve
of the form Y = A(0) + A(1)*SIN(X + A(2)).
A(0) is the rotation axis
A(1) is the amplitude
A(2) is the phase
The fitting is done using routine CURVE_FIT in the User Library.
The shifting is done using routine POLY_2D which can shift by
fractional pixels.
- Centering of the rotation axis (optional). If /AUTO_CENTER
is specified then the image is shifted so that the rotation axis
obtained by fitting the center-of-gravity data for all rows in the
image coincides exactly with the center column. If CENTER is
specified without /AUTO_CENTER then the image is shifted by this
value. If CENTER is specified with /AUTO_CENTER then the CENTER
value is an output containing the actual position of the rotation
axis.
The shifting is actually done by adding extra air pixels to the
sinogram so that the rotation axis is in the center of the
enlarged sinogram array.
MODIFICATION HISTORY:
Created 21-OCT-1991 by Mark Rivers.
MLR 25-NOV-1994:
Removed BSIF_COMMON
Made TOMO_HEADER a structure passed to the routine
This structure must contain the fields .ANGLE, .WIDTH, .STEP_SIZE
MLR 13-MAY-1998
Converted from a procedure to a function, added ANGLES parameter,
removed TOMO_HEADER parameter. Added TWEAK_CENTER and DEBUG keywords.
MLR 9-MAR-1999
Added some more DEBUG output.
Changed the CENTER keyword to AUTO_CENTER, made TWEAK_CENTER work even
if /AUTO_CENTER is not used.
MLR 9-APR-1999
Changed the way shifting is done. Previously it was done with POLY2D
but this could shift the object out of the field of view. Changed the
logic so the shifting is now done by adding extra air pixels on one
side of the sinogram. This can't do fractional pixels, but it does
fix the problem of shifting out of the window.
MLR 9-APR-1999
Removed the TWEAK_CENTER keyword, replaced with the CENTER keyword.
MLR 18-MAY-1999
Fixed bug when CENTER was specified, but no shift was required
MLR 23-JUN-1999
Added FLUORESCENCE keyword
MLR 22-JAN-2001
Changed logic so that if CENTER<0 it is ignorred
MLR 19-APR-2001
Changed units of ANGLES from radians to degrees
(See sinogram.pro)
NAME:
TOMO::GET_SETUP
PURPOSE:
This function returns the setup information for a tomography data set
CATEGORY:
Tomography
CALLING SEQUENCE:
setup = TOMO->GET_SETUP()
OUTPUTS:
This function returns a structure of type {TOMO} containing the information
about the tomography dataset. The current definition of the {TOMO}
structure is:
{tomo, $
title: " ", $
operator: " ", $
camera: " ", $
sample: " ", $
comments: ptr_new(), $
image_type: " ", $ ; "RAW", "CORRECTED" or "RECONSTRUCTED"
dark_current: 0., $
center: 0., $
energy: 0., $
x_pixel_size: 0., $
y_pixel_size: 0., $
z_pixel_size: 0., $
scale_factor: 0., $
nx: 0L, $
ny: 0L, $
nz: 0L, $
angles: ptr_new() $
}
This definition is subject to change in the future, but the above fields
will not change, new fields may be added.
EXAMPLE:
IDL> tomo = obj_new('TOMO')
IDL> status = TOMO->READ_SETUP('Sample1.setup')
IDL> setup = TOMO->GET_SETUP()
MODIFICATION HISTORY:
Written by: Mark Rivers, Nov. 18, 2001
(See tomo__define.pro)
NAME:
TOMO::PREPROCESS
PURPOSE:
This procedure reads a tomography data set from individual Princeton
Instruments .SPE files. It writes a 3-D volume file to disk.
CATEGORY:
Tomography
CALLING SEQUENCE:
TOMO->PREPROCESS, Base_file, First, Last
INPUTS:
Base_file:
The base file name for the data set. The actual file name are assumed
to be of the form Base_file + strtrim(file_number,2) + '.SPE'.
First:
The number of the first file, typically 1.
Last:
The number of the last file
KEYWORD PARAMETERS:
THRESHOLD:
The threshold for zinger removal in normal frames. See documentation
for REMOVE_TOMO_ARTIFACTS for details. Default=1.25
DOUBLE_THRESHOLD:
The threshold for zinger removal in white field frames using double
correlation. Default=1.05
DARK:
The dark current, either a scaler or a 2-D array. If this is a scaler
value then a constant dark current is subtracted from each pixel in
every frame. If this is a 2-D array then it must have the same
dimensions as each frame in the data set. In this case the specified
2-D dark current will be substracted from each frame in the data set.
Note that if the data set contains dark current frames (frame type =
DARK_FIELD) then this keyword is normally not used.
FIRST_ROW:
The starting row (slice) to be processed. The default is 0. This
keyword, together with LAST_ROW below are provided for processing
data sets which are too large to be read into memory in their
entirety. It lets one create multiple volume arrays from a single
data set, for example rows 0-300 in file 1, (FIRST_ROW=0, LAST_ROW=300)
rows 301-600 in file 2, etc.
LAST_ROW:
The ending row (slice) to be processed. The defaults is the last row
in each image. See comments under FIRST_ROW above.
BUFF_ANGLES:
The size of the buffer (in # of angles) to be used when writing the normalized
data to the output file. The default is no limit, so an array of size
(ncols, nrows, nangles) is allocated. If BUFF_ANGLES is specified then the
output file is write in chunks of "BUFF_ANGLES" at a time, and an array
of only (ncols, nrows, BUFF_ANGLES) is needed. This keyword is useful
when processing data sets with many angles. The output file is identical
whether or not this keyword is used, it only affects how many times the
output file is opened and appended to.
WHITE_FIELD:
The white field value, either a scaler or a 2-D array. If this is a
scaler value then each pixel in each data frame is normalized by this
constant value. If this is a 2-D array then it must have the same
dimensions as each frame in the data set. In this case then each data
frame in the data set is normalized by the specified 2-D array.
Note that if the data set contains white field frames (frame type =
FLAT_FIELD), which is typically the case, then this keyword is
normally not used.
WHITE_AVERAGE:
Set this flag to 1 to process the flat fields by averaging all of them
together. The default (WHITE_AVERAGE=0) is to interpolate flat fields in time.
NOTE: The default value for this flag is 0 for backward compatibility.
However, in general setting WHITE_AVERAGE=1 greatly reduces ring artifacts
compared with the default interpolation method, so it's use is strongly
recommended.
WHITE_SMOOTH:
The size of the smoothing kernal for smoothing the white fields. Set this
value to 2 or more to smooth the white fields before normalization.
Since white fields generally do not have much high frequency content,
smoothing can be used to reduce noise in the normalization.
Default=0 (no smoothing).
OUTPUT:
The name of the output file. The default is Base_file + '.volume'
STATUS_WIDGET:
The widget ID of a text widget used to display the status of the
preprocessing operation. If this is a valid widget ID then
informational messages will be written to this widget.
ABORT_WIDGET
The widget ID of a widget used to abort the preprocessing operation.
If this is a valid widget ID then the "uvalue" of this widget will be
checked periodically. If it is 1 then this routine will clean up and
return immediately.
DEBUG:
A debugging flag. Allowed values are:
0: No informational output
1: Prints each input filename as it is read, and prints limited
information on processing steps
2: Prints detailed information on processing steps
OUTPUTS:
This function returns a 3-dimensional signed 16-bit integer volume array
of size [NCOLS, NROWS, NANGLES]. The data is the ratio of the input image
to the flat field, multiplied by 10,000. The ratio of the data to the
flat field should be in the range 0 to 1 (with occasional values slightly
greater than 1). Multiplying by 10000 should give sufficient resolution,
since even values with 99% absorption will be stored with a precision of
1%.
RESTRICTIONS:
- There must not be any missing files between the numbers specified by the
First and Last parameters.
- The input files must follow the naming convention Base_file +
strtrim(number,2) + '.SPE', where number varies from First to Last.
- By storing the normalized data as 16-bit integers, there is a
possibility of loss of some information when using a true 16-bit camera.
PROCEDURE:
This function performs the following steps:
- Reads each frame in the data set into a large 3-D data buffer. Stores
a flag for each frame indicating if the frame is a dark current, a
white field or normal data.
Stores the rotation angle at which each frame was collected.
- Subtracts the dark current from each data frame and white field frame,
using dark current images in the data set if present, or the input dark
current if present.
If the data set contains multiple dark current frames, then the
correction is done as follows:
- Use the first dark current for all frames collected before the
first dark current
- Use the last dark current for all frames collected after the last
dark current
- Use the average of the closest preceeding and following dark
currents for all frames collected between two dark currents.
- Removes zingers from white field frames using REMOVE_TOMO_ARTIFACTS with
/DOUBLE_CORRELATION if possible, or /ZINGERS if not.
- Divides each data frame by the white field, using white field images in
the data set, or the input white field if present. If the
data set contains multiple white field frames, and WHITE_AVERAGE=0,
then the correction is done as follows:
- Use the first white field for all frames collected before the
first white field
- Use the last white field for all frames collected after the last
white field
- Use the weighted average of the closest preceeding and following white
fields for all frames collected between two white fields.
If WHITE_AVERAGE=1 then all of the white fields in the data are averaged
before normalizing. This is recommended.
The ratio of each frame to the white field is multiplied by 10,000 to be
able to use 16 bit integers, rather than floats to store the results,
saving a factor of 2 in memory, which is important for these large 3-D
data sets.
- Sorts the rotation angle array, to determine the order in which the
normalized data frames should be written back out to disk in the volume
file.
- Corrects for zingers in the white-field normalized data frames, using
REMOVE_TOMO_ARTIFACTS, /ZINGERS.
- Writes the normalized data frames to a single disk file. The default
file name is Base_file + '.volume'. This file is in little-endian binary
format, with the following data:
- NCOLS (long integer, number of columns in each frame)
- NROWS (long integer, number of rows in each frame)
- NANGLES (long integer, number of frames)
- DATA (short integer array [NCOLS, NROWS, NANGLES]
The volume file can be read back in to IDL with function
READ_TOMO_VOLUME
EXAMPLE:
The following example will read files Mydata1.SPE through Mydata370.SPE,
using a constant dark current of 50 counts at each pixel. This data set
is assumed to have white field frames in it. The output file will be
Mydata.volume
IDL> READ_TOMO_DATA, 'Mydata', 1, 370, dark=50
; Now read the volume file back into IDL
IDL> vol = READ_TOMO_VOLUME('Mydata.volume')
; Play the volume data as a movie, rotating the sample
IDL> window, 0
IDL> make_movie, vol, min=3000, max=12000
MODIFICATION HISTORY:
Written by: Mark Rivers, March 27, 1999.
3-APR-1999 MLR Changed white field normalization to use weighted average
of white fields before and after, rather than simple
average
4-APR-1999 MLR Changed the default value of threshold from 1.20 to 1.05
Switched to double correlation method of zinger removal
for white field images when possible.
18-MAY-1999 MLR Added missing keyword DOUBLE_THRESHOLD to procedure line
07-JUL-1999 MLR Changed zinger removal for data frames so it is done after
whitefield correction. This makes the identification of
zingers (versus high-frequency structure in the whitefield)
much more robust.
13-SEP-1999 MLR Changed the dark current correction to use a loop, so that
two large arrays are not required at the same time.
08-DEC-1999 MLR Added FIRST_ROW and LAST_ROW keywords for handling very
large data sets.
Added OUTPUT keyword
02-MAR-2000 MLR Added DEBUG keyword to calls to REMOVE_TOMO_ARTIFACTS
large data sets.
02-MAR-2000 MLR Changed the default value of THRESHOLD from 1.05 to 1.25
because the lower threshold was causing significant
blurring of sharp edges. Changed the default value of
DOUBLE_THRESHOLD from 1.02 to 1.05, since it was finding
many more zingers than physically plausible.
02-MAR-2000 MLR Added SWAP_IF_BIG_ENDIAN keyword when opening output file.
22-JAN-2001 MLR Added some default debugging when writing output file
11-APR-2001 MLR Changed the name of this routine from READ_TOMO_DATA to
TOMO::PREPROCESS when it was incorporated in the TOMO class
library.
This routine now updates the .SETUP file with the dark current
that was specified when running this procedure.
The output file is now written with TOMO::WRITE_VOLUME rather
than being incrementally written as the data are processed. This
requires more memory, but is necessary to allow use of netCDF
and other file formats.
1-NOV-2001 MLR Added BUFF_ANGLES keyword
20-NOV-2001 MLR Added ABORT_WIDGET and STATUS_WIDGET keywords
25-APR-2002 MLR Added support for reading 3-D .SPE files, created when doing
fast scanning
18-DEC-2005 MLR Added white_average and white_smooth keywords.
Renamed WHITE keyword to WHITE_FIELD
Setting white_average greatly reduces ring artifacts in many cases.
(See tomo__define.pro)
NAME:
TOMO::READ_SETUP
PURPOSE:
This function reads the setup information for a tomography data set from an
ASCII file.
CATEGORY:
Tomography
CALLING SEQUENCE:
result = TOMO->READ_SETUP(File)
INPUTS:
File:
The name of the input file.
OUTPUTS:
This function returns 0 if it was unable to read the file, 1 if it was
successful.
EXAMPLE:
IDL> status = TOMO->READ_SETUP('Sample1.setup')
MODIFICATION HISTORY:
Written by: Mark Rivers, Aug. 2001?
(See tomo__define.pro)
NAME:
TOMO::READ_VOLUME
PURPOSE:
Reads in 3-D volume files written by WRITE_TOMO_VOLUME. These are binary
files written in little endian. This file format is "temporary" until we
decide on a portable self-describing binary format, such as HDF or netCDF.
Both intermediate volume files (after preprocessing) and final
reconstructions are currently stored in this format.
CATEGORY:
Tomography data processing
CALLING SEQUENCE:
Result = READ_TOMO_VOLUME(File)
INPUTS:
File:
The name of the volume file to be read. If this is not specified then
the function will use DIALOG_PICKFILE to allow the user to select a
file.
KEYWORD PARAMETERS:
XRANGE=[xstart, xstop]
The range of X values to read in. The default is to read the entire
X range of the data
YRANGE=[ystart, ystop]
The range of Y values to read in. The default is to read the entire
Y range of the data
ZRANGE=[zstart, zstop]
The range of Z values to read in. The default is to read the entire
Z range of the data
OUTPUTS:
This function returns a 3-D 16-bit integer array. The dimensions are
NX, NY, NZ
RESTRICTIONS:
These files are written using the little-endian byte order and
floating point format. When this routine reads the files it swaps the
byte order if it is running on a big-endian machine. Thus the file format
is most efficient on little-endian machines (Intel, DEC).
EXAMPLE:
volume = READ_TOMO_VOLUME('diamond2.volume')
MODIFICATION HISTORY:
Written by: Mark Rivers, May 13, 1998
06-APR-1999 MLR Made file input optional, puts up dialog if it is not
specified
25-JAN-2000 MLR Added /swap_if_big_endian keyword to openr to allow
files to be read on big-endian machines.
23-FEB-2000 MLR Added xrange, yrange, zrange keywords
11-APR-2001 MLR Added support for netCDF file format.
(See tomo__define.pro)
NAME:
TOMO::RECONSTRUCT_VOLUME
PURPOSE:
This procedure reconstructs a complete 3-D data set (X, Y, Theta) into a
3-D (X, Y, Z) volume. It reads its input from disk and writes its output
back to disk.
CATEGORY:
Tomography.
CALLING SEQUENCE:
TOMO->RECONSTRUCT_VOLUME, Base_file
INPUTS:
Base_file:
The base file name. The input file is assumed to be named
base_file+'.volume', and the output file will be named
base_file+'_recon.volume'. The input file is read with
READ_TOMO_VOLUME and the output file is written with WRITE_TOMO_VOLUME.
KEYWORD PARAMETERS:
This procedure accepts all keywords accepted by READ_TOMO_VOLUME and
RECONSTRUCT_SLICE and simply passes them to those routines via keyword
inheritance.
CENTER
This keyword, which is passed to RECONSTRUCT_SLICE can either be a scaler (the
normal case) or a 2-element array. If it is a 2-element array then the
center value passed to RECONSTRUCT_SLICE is interpolated between CENTER[0]
for the first slice of the volume file to CENTER[1] at the last slice of the
volume file. This can be useful if the optimum center varies with slice
depth.
ANGLES
An optional array of angles (in degrees) at which each projection was taken.
This keyword is passed to RECONSTRUCT_SLICE. If this keyword is missing
then RECONSTRUCT_SLICE assumes even spacing from 0 to 180-delta degrees.
SCALE
The scale factor by which the data should be multiplied before writing as
short integers to the output file. The default is 1.e6. Since the
attenuation values are per-pixel, and are typically 0.001, this leads to
integers in the range of 10,000. If there are highly attenuating pixels the
scale factor may need to be decreased to 1-5e5 to avoid integer overflow.
The inverse of the SCALE is stored as the attribute volume:scale_factor
in the netCDF file.
STATUS_WIDGET:
The widget ID of a text widget used to display the status of the
preprocessing operation. If this is a valid widget ID then
informational messages will be written to this widget.
ABORT_WIDGET
The widget ID of a widget used to abort the preprocessing operation.
If this is a valid widget ID then the "uvalue" of this widget will be
checked periodically. If it is 1 then this routine will clean up and
return immediately.
OUTPUTS:
This procedure writes its results to a file base_file+'_recon.volume'
RESTRICTIONS:
This procedure assumes a naming convention for the input and output files.
The output is stored as 16 bit integers to save memory and disk space.
This can reduce the dynamic range of the reconstructed data.
PROCEDURE:
This procedure simply does the following:
- Reads a corrected input volume (X, Y, Theta) which is typically
created with READ_TOMO_DATA
- Calls RECONSTRUCT_SLICE for each row (slice) in the input volume
- Scales the reconstructed data (floating poing) by 10000 and converts
to 16 bit integers
- Writes the reconstructed 3-D volume (X, Y, Z) back to disk with
WRITE_TOMO_VOLUME
EXAMPLE:
reconstruct_volume, 'FOSSIL1', /AUTO_CENTER
MODIFICATION HISTORY:
Written by: Mark Rivers, April 23, 1999
30-APR-1999 MLR Fixed bug introduced by new version of sinogram, need
to get size of reconstructed slices after centering
18-MAY-1999 MLR Changed formal parameter _extra to _ref_extra to allow
CENTER keyword value to be returned from sinogram (via
reconstruct_slice).
23-FEB-2000 MLR Pass extra keywords to read_tomo_volume
7-MAR-2000 MLR Added support for GRIDREC reconstruction, which reconstructs
2 slices at once.
2-JAN-2001 MLR Added CENTER keyword. If it is a 2-element array then the
center is interpolated.
11-APR-2001 MLR Incorporated the previous routine RECONSTRUCT_VOLUME into the
TOMO class library.
This procedure now updates the .SETUP file with the center
value which was used for the reconstruction.
12-APR-2001 MLR Added SCALE and angles keywords since we need to process them
here.
22-NOV-2001 MLR Added STATUS_WIDGET and ABORT_WIDGET keywords
02-APR-2002 MLR Fixed bugs with STATUS_WIDGET and ABORT_WIDGET
11-APR-2002 MLR Fixed bug introduced on 02-APR with center
(See tomo__define.pro)
NAME:
TOMO::WRITE_SETUP
PURPOSE:
This function writes the setup information for a tomography data set to an
ASCII file.
CATEGORY:
Tomography
CALLING SEQUENCE:
result = TOMO->WRITE_SETUP(File)
INPUTS:
File:
The name of the output file.
OUTPUTS:
This function returns 0 if it was unable to write the file, 1 if it was
successful.
EXAMPLE:
IDL> status = TOMO->WRITE_SETUP('Sample1.setup')
MODIFICATION HISTORY:
Written by: Mark Rivers, Aug. 2001?
(See tomo__define.pro)
NAME:
TOMO::WRITE_VOLUME
PURPOSE:
Writes 3-D volume files to be read later by READ_TOMO_VOLUME.
There are currently 2 file formats supported:
1) The old APS-specific architecture-dependent binary format.
In general this format should no longer be used, since it does not
contain information on the dark current, centering, etc. It is also
not nearly as portable as netCDF, since if the IDL routine
READ_TOMO_VOLUME is not used to read the files then user-code must
handle byte-swapping, etc.
2) netCDF format files. This is the format which should generally be used,
since it supports additional information like the dark current and it is
very portable. Many data-handling packages support netCDF and there are
netCDF libraries available on virtually all platforms.
CATEGORY:
Tomography data processing
CALLING SEQUENCE:
TOMO->WRITE_VOLUME, File, Volume
INPUTS:
File:
The name of the volume file to be written.
Volume:
The 3-D volume data to be written. This must be a 3-D 16-bit integer
array. The dimensions are NX, NY, NANGLES or NX, NY, NZ
KEYWORD PARAMETERS:
XOFFSET:
YOFFSET:
ZOFFSET: The [X,Y,Z] offsets in the disk array to begin writing to. Default
is [0,0,0]
XMAX:
YMAX:
ZMAX: The maximum [X,Y,Z] size of the array on disk. Valid only when the
file is first created, i.e. if APPEND is not specified. Default
is the size of the Volume array in each dimension.
APPEND: Open an existing file for appending or overwriting data. Default is to
APPEND=0 which creates a new file.
NETCDF:
Set this keyword to write files in netCDF file format. This is the
default. If NETCDF=0 then files are written in the old APS format.
RAW: The data are raw projections (X,Y,THETA), not normalized for flat field
CORRECTED: The data are flat-field normalized projections (X,Y,THETA)
RECONSTRUCTED: The data are reconstructed sections (X,Y,Z)
RESTRICTIONS:
The old APS format files are written using little-endian byte order.
When this routine writes such files it swaps the byte order if it is
running on a big-endian machine. Thus that file format
is most efficient on little-endian machines (Intel, DEC).
EXAMPLE:
tomo = obj_new('tomo', 'test.setup')
tomo->WRITE_VOLUME, 'diamond2.volume', volume
MODIFICATION HISTORY:
Written by: Mark Rivers, May 13, 1998
26-JAN-2000 MLR Added /swap_if_big_endian keyword to openw to allow
files to be read on big-endian machines.
11-APR-2001 MLR Added support for netCDF file format. Added NETCDF keyword.
5-NOV-2001 MLR Added XOFFSET, YOFFSET, ZOFFSET, XMAX, YMAX, ZMAX, and
APPEND keywords
24-JUN-2002 MLR Fixed bug if input volume was 2-D rather than 3-D.
(See tomo__define.pro)
NAME:
TOMO_FILTER
PURPOSE:
Filters a sinogram before backprojection. A selection of filters is
available.
CATEGORY:
Tomography data processing
CALLING SEQUENCE:
Result = TOMO_FILTER(Sinogram, Filter_size, D)
INPUTS:
Sinogram: The unfiltered sinogram. This must be a 2-D array.
OPTIONAL INPUTS:
Filter_size: The half-size of the filter in pixels. The default is NX/4 where
NX is the first dimension of the sinogram.
D: An additional filter parameter. The default is 1.0
KEYWORD PARAMETERS:
FILTER_NAME: A case-insensitive string specifying the filter to be used.
Allowed values are:
'GEN_HAMMING'
'LP_COSINE'
'SHEPP_LOGAN'
'RAMLAK'
'NONE'
The default is 'SHEPP_LOGAN'
OUTPUTS:
This function returns the filtered sinogram.
PROCEDURE:
For each row in the sinogram, this function simply does the following:
Pads the input sinogram
Does a convolution with the appropriate filter
The code for the filters was taken from the IDL tomography demo program
which is included in the IDL distribution. It would be easy to add
additional filters in the future.
EXAMPLE:
f = tomo_filter(sinogram, filter_name='SHEPP_LOGAN')
MODIFICATION HISTORY:
Written by: Mark Rivers, May 13, 1998
25-Nov-2001 MLR Changed the keywords from names of individual filters
(e.g. /SHEPP_LOGAN) to FILTER_NAME
Changed the default filter size from 32 to NX/4
(See tomo_filter.pro)
NAME:
WRITE_TOMO_VOLUME
PURPOSE:
Writes 3-D volume files to be read later by READ_TOMO_VOLUME or TOMO::
READ-VOLUME.
This function is a simple wrapper around TOMO::WRITE_VOLUME.
See the documentation for TOMO::WRITE_VOLUME
for more information.
CATEGORY:
Tomography data processing
CALLING SEQUENCE:
WRITE_TOMO_VOLUME, File, Volume
PROCEDURE:
This function simply creates a TOMO object and calls TOMO::WRITE_VOLUME.
EXAMPLE:
WRITE_TOMO_VOLUME, 'diamond2.volume', volume
MODIFICATION HISTORY:
Written by: Mark Rivers, May 13, 1998
26-JAN-2000 MLR Added /swap_if_big_endian keyword to openw to allow
files to be read on big-endian machines.
04-MAR-2001 MLR Added support for netCDF file format. Added NETCDF
and SETUP keywords
11-APR-2001 MLR Put the original version in the TOMO class library, made this
function simply create a TOMO object and call TOMO::WRITE_VOLUME.
(See write_tomo_volume.pro)