- Inspecting analyze image headers and surface files.
- Image processing such as smoothing, thresholding, flipping etc.
- Segmentation (voxel classification), slice inhomogeneity correction & bias field correction tools.
- Image Reslicing and other utilities to manipulate transformations.
- Batch mode registration tools.
- Batch mode segmentation tools.
Typing any of the bioimagesuite command names with no arguments prints a short description of its usage. Arguments in square brackets are optional.
Note: Most of this functionality (with the exception of the
batch-mode tools) is available via the graphical user interface see: the Image Processing, (ii) Segmentation and Registration pages respectively.
Inspecting Analyze Header Files and Surface Files (.vtk)
The pxmat_headerinfo.tcl command can be used to print basic information about analyze header files (.hdr). The syntax is:pxmat_headerinfo.tcl image1 image2 ... imagen
Image Processing Tasks
Flipping Images
Sometimes images need to be flipped about one of the coordinate axes. This can be accomplished using the pxmat_flip.tcl sciprt. The syntax is
pxmat_flip.tcl direction file1 file2 file3 ...
Direction 0=x, 1=y, 2=z
Reorienting
Reorienting is defined here as switching the orientation of an image from, for example, axial to coronal. This is accomplished by the pxmat_reorientimage.tcl command. The syntax is
pxmat_reorientimage.tcl input_image output_image output_orientation
output_orientation = 0 axial 1 coronal 2 sagittal
Smoothing
This is accomplished by the pxmat_smoothimage.tcl command. The syntax ispxmat_smoothimage.tcl kernel_size input_image1 input_image2 .....
Thresholding
Similarly this is performed by the pxmat_thresholdimage.tcl command. The syntax is:pxmat_thresholdimage.tcl threshold input_image1 input_image2 .....
Resampling Images
This is accomplished using the pxmat_resampleimage.tcl command. The syntax is:pxmat_resampleimage.tcl input_image output_image blur_mode voxelsize1 [ voxelsize2 ] [ voxelsize3 ]
Combining Multiple 3D Images into a single 4D Image
This is accomplished using the pxmat_create4dimage.tcl command. The syntax is:pxmat_create4dimage.tcl image1 image2 ... imagen
output = image1_4D.hdr
Extracting 3D Image volumes from a single 4D Image
This is accomplished using the pxmat_split4dimage.tcl command. The syntax is:pxmat_split4dimage.tcl image [ begin =1 ] [ end = maximum number of frames ]
Segmentation and Bias Field Correction Tools
Segmentation Tools
A single script pxmat_segment.tcl captures some of the functionality from the < a tools (Histogram & Region Segmentation.) The reader refered to that page for more details. The syntax for pxmat_segment.tcl is:pxmat_segment.tcl input numclasses [ smoothness = 1.0 ] [ maxsigmaratio = 0.05 ] [ mrfiterations = 20 ] [ outputname = "" ]
Number of classes = number of tissue labels (background is a tissue label so add this) Smoothness = spatial smoothness, is set to zero -- a faster algorithm is used MaxSigmaRatio = this constrains the ratio of the max standard deviation to the min standard deviation If Output Name is blank defaults are either input_quicksegm (smoothness=0.0) or input_segm
Slice Inhomogeneity correction & Bias Field Correction tools.
pxmat_biasfield.tcl is a multifunctional script for performing both these tasks. The syntax is:pxmat_biasfield.tcl input [ mode = 5 ] [ threshold =0.05 ] [ numclasses = 4 ] [ res=3 ] [ maxsigmaratio = 0.5 ] [ minb1 =0.8 ] [ maxb1=1.25 ]
mode = 0 (slice homogeneity) 1 (triple slice homogeneity) 2 (quadratic polynomial) 3 (cubic polynomial) 4 = triple slice + quadratic, 5=triple slice + cubic. Threshold = 0.05, normalized threshold (0..1) to exclude voxels from bias field estimation -- to eliminate background Number of classes = number of tissue labels (background is a tissue label so add this) for polynomial Resolution = 3, resolution sampling for polynomial estimation MaxSigmaRatio = this constrains the ratio of the max standard deviation to the min standard deviation Min B1 and Max B1 specify the range of B1 field allowe
Slice Inhomogeneity correction
This is performed simply using mode = 0 in pxmat_biasfield.tcl.Bias Field correction
There are 2 methods here, which can be used in combination:- Multiple (triple slice) orientation slice inhomogeneity correction – set mode = 1 in pxmat_biasfield.tcl.
- Polynomial bias field correction using the method of Styner et al (TMI 2000) – set mode = 2 (quadratic ) or 3 (cubic) in pxmat_biasfield.tcl. This second method requires a crude histogram segmentation hence the other parameters – this invokes the histogram segmentation (i.e. smoothness=0) method from the previous section.
The two bias field correction methods may be combined by setting the mode to 4 or 5 respectively. In general, the triple-slice method can be used to get a good initial starting point for the polynomial method in cases where the bias field change is large.
In addition to the segmentation parameters, the parameters threshold, res, minb1 and maxb1 or only used by the polynomial method.
Reslicing Images and other command line tool using transformations
The BioImage Suite registration tools (both command line and using the graphical user interface), produce transformation files as outputs, typically with a ".matr" or a ".grd" extensions. (See the File Formats page for more details.) The command line tools described here can be used to apply these transformations to images (reslicing) or to manipulate the transformations in different ways.Image Reslicing
Given a reference image, a target image and an appropriate transformation (or set of transformations) the target image can be resliced in the space of the reference image using the command
pxmat_resliceimage.tcl reference_image target_image output_image interpolation_mode xform [xform2] [ xform3]
interpolation_mode = 0,1,3 none,linear,cubic (Avoid
linear if the images are in the range 0..1)
xform = the .matr or .grd file
Note: The direction of the transformations is a common source of confusion. When computing registrations, the estimated transformations is FROM the reference TO the target. This transformation can be used in pmat_reslice.tcl to move the target image to the reference image. A good rule of thumb is to remember that images move in the opposite direction as transformations.
If multiple transformations are specified (upto 3) then the the concatenation of these transformations will be used. For example, consider the case where we have:
- A transformation from a 3D reference brain to a 3D individual anatomical. xf1.grd
- A transformation from a 3D individual anatomical to a scout image. xf2.matr
- A transformation from the scout image to a functional acquisition. xf3.matr
pxmat_resliceimage.tcl ref_image func_image resliced 3 xf1.grd xf2.matr xf3.matr
Inverting Transformations
Often the inverse transformation is required. This can be accomplished using the pxmat_inverttransform.tcl script. The syntax is:pxmat_inverttransform.tcl reference_image output_transformation xform1 [ xform2 ] [ xform3 ]
Computing Displacement Fields
Sometimes it is desired to get the displacement field for each voxel. This can be accomplished using the pxmat_displacementfield.tcl command. The syntax is:pxmat_displacementfield.tcl reference_image output_field xform1 [ xform2 ] [ xform3 ]
Batch Mode Registration
A quick overview of GNU Make.
All Batch Job Generators in BioImage Suite result in a makefile which needs to be processed with the Unix Make Utility (most commonly GNU Make). While "makefiles" are primarily used to compile large programs they are a great mechanism for general batch mode processing because they enable:- the definition of job dependencies -- i.e. job A must be completed before job B
- the use of multiple processors at the same time -- i.e. run two or more jobs at once.
- the ability to automatically recover from a system crash and to restart at the point that the job failed -- i.e. no repeat computations.
make -f makefile.controls
- "-n" - do a dry run i.e. simply print a list of commands
to be executed without doing anything
make -n -f makefile.controls
- "-j" - specify how many jobs to run at once -- typically
equal to the number of processors available e.g. to use 2 processors
type
In addition makefiles contain a number of "jobs" which may be explicitly specified. Typically the first job defined in BioImage Suite batch jobs is the equivalent of "do everything" so you need not worry about this - in some cases other specifications will need to be given given. Note: If after starting a batch job -- it is for some reason terminated (either by a system crash or a reboot or ....) it may be restarted by typing exactly the same command as the one used to originally start the batch job. The job dependency mechanism in make will ensure that no processing that was previously completed is re-run.
make -j2 -f makefile.controls
Microsft Windows Info
Whereas make is a standard feature on most unix system, to run batch jobs in MS-Windows you will to download and install GNU Make. A binary (from the UnixUtils distribution ) is available for download at this location (source code here. Place make.exe in a directory in your path such as C:\yale\vtk44_yale\bin.Single Reference Image Registrations
To compute batch-mode registrations to a single reference (typically inter-subject nonlinear brain mappings for the purpose of computing fMRI composite maps etc.) BioImage Suite provides the pxmultiregister_int.tcl tool. This is a batch-mode generator which will generate a makefile - the batch job itself is executed using the standard make program - see detailed description above. pxmultiregister_int.tcl has a large number of options -- with more to be added in the next release. Simply typing pxmultiregister_int.tcl sample lists all options, which might be intimidating for the average user. A basic setup file has the form: (Lines beginning with # are treated as comments and may be added liberally to document the processing.#Example Setup File
# all lines beginning with # are ignored
#
#
# Mode of Operation
set intensities_only 1
#
#
#
#
# List all images here
#
set imglist {
Az2_2_sm0.8.hdr
Az2_3_sm0.8.hdr
Az2_4_sm0.8.hdr
}
#
# Put reference brain here
#
set refimg Az2_5_sm0.8.hdr
# Linear mode -- choices are "rigid", "similarity", "affine" -- this is used to generate an initial transformation to be refined later.
set linearmode "affine"
# Tweak parameters for intensity based part (the ones below are typical for fMRI composite maps)
# Resolution is a scale factor x native (i.e. if reference image is 1.1x1.1x1.2 setting this to 1.5 will resample the images to
# 1.65x1.65x1.7 mm). Integer values are not recommended due to artifacts in joint histogram computation, 1.5 or 1.2 are good values
set resolution 1.5
# Spacing defines the flexibility of the transformation -- the gap between control points in the tensor b-spline model used for the non-linear transformation
# 15.0 mm is a good choice for composite functional maps
# For structural morphometric studies this should be reduced to 10 or 8 mm (with a corresponding increase in computational time)
# If the data is a fairly low resolution this can be increase to 20mm or so.
set spacing 15.0
# This is the maximum number of iterations for the Conjugate Gradient Minimizer (15 is usually a safe number)
set iterations 15
# Leave this to zero unless other instructed
# Regarding filetype: filetype = 1 includes directory name in output filename 0 does not
set filenametype 0
# Set this higher if data quality is low
set smoothness 0.001
# If linearonly=1 then the resulting transformation will be linear i.e. no warping will be attempted
set linearonly 0
pxmultiregister_int.tcl controls_setup control_results
pxmultiregister_int.tcl controls_setup control_results go > makefile.controls
Pairwise Image Registrations
The case of interest here is where one set of images (e.g. thick-slice "2D" conventional images) are to be mapped to another set of images (e.g. high resolution 3D anatomical images). To accomplish this use the pxpairwiseregister.tcl script. This is a batch-mode generator which will generate a makefile -- the batch job itself is executed using the standard make program -- see above for instructions as to how to use GNU make. pxpairwiseregister.tcl has a large number of options. Simply typing pxpairwiseregiste.tcl sample lists all options, which might be intimidating for the average user. A basic setup file has the form: (Lines beginning with # are treated as comments and may be added liberally to document the processing.#Example Setup File
# all lines beginning with # are ignored
#
#
#
# Put reference list here
#
set reflist {
/data1/brains/1001/refA.hdr
/data1/brains/1002/refB.hdr
}
#
# Put the target list here
#
set trglist {
/data1/brains/1001/targA.hdr
/data1/brains/1002/targB.hdr
}
#
#
# Type of registration
# mode = rigid,affine,nonlinear
set mode "nonlinear"
#
# Tweak parameters
# filetype = 1 includes directory name in output filename 0 does not
# defaults are for rigid/affine/nonlinear
set resolution 1.5
set spacing 15.0
set iterations 15
set stepsize 1
set smoothness auto
pxpairwiseregister.tcl setup.txt results
pxpairwiseregister.tcl setup.txt results go > makefile.results
Batch Mode Registration Utilities
The following helper scripts are used to assist/compute the batch mode registrations. They are not meant to be invoked directly, so only a cursory description is given. Invoking each script with no arguments gives a brief description of its syntax.- pxmat_register.tcl – computes intensity based registrations.
- pxmat_distortioncorrection.tcl – computes intensity based distortion correction for Echoplanar images.
- pxmat_pointregister.tcl – computes point based registrations.
- pxmat_integratedregistration.tcl – computes integrated intensity + point based registrations.
- pxmat_computeoverlap.tcl – computes the overlap of pre-segmented structures after registration &ndash this is a measure of registration quality.
- pxmat_computesimilarity.tcl – computes the similarity of two images after registration.
- pxmat_computedistance.tcl – computes the distance of two surfaces after registration.
Batch Mode Segmentation
To compute batch-mode segmentation, BioImage Suite provides the pxmultisegment.tcl tool. This is a batch-mode generator which will generate a makefile - the batch job itself is executed using the standard make program - see detailed description above. Simply typing pxmultisegment.tcl sample lists all options. A basic setup file has the form: (Lines beginning with # are treated as comments and may be added liberally to document the processing.#Example Setup File
#Example Setup File
# all lines beginning with # are ignored
#
#
# Mode of Operation
#
#
# List all images here
#
set imglist {
4T.hdr
1147acpc.hdr
}
#
#
# Mode
# Set this to 0 to use native BioImage Suite tools
set usefsl 0
set numclasses 3
set identifier segm
#
#
# FSL parameters
set imgtype 1
#
#
# BioImage Suite parameters
set smoothness 0
set maxsigmaratio 0.05
set mrfiterations 20
pxmultisegment.tcl controls_setup control_results
pxmultisegment.tcl controls_setup control_results go > makefile.controls
