Loading...
 


Programming batch jobs for image analysis with Huygens Scripting

This article explains how to program batch jobs for image analysis with Huygens Scripting.





  # FILE: batchCtl.tcl
 #
 # PURPOSE:
 # Control file for batch processing script doBatch.tcl
 #
 # Set the compute environment. The ConcurrentJobs parameter controls
 # the number of jobs which are running at the same time. If 'auto' is
 # selected this parameter is derived from the cpu count.

 # The ThreadsPerJob parameter controls the number of processors which
 # work together on one job. If 'auto' is selected the number is
 # derived from the number of !ConcurrentJobs and the cpu count. Also
 # 'auto' allows the number of threads per job to increase when there
 # are less jobs in the queue left than the ConcurrentJobs number.
 #

 set computeEnvironment(ConcurrentJobs) 2
 set computeEnvironment(ThreadsPerJob) auto

[...]

 #   Define a microscopic parameter set
 #   You can define as many as you like yourself
 #
 set myMPSet(NumericalAperture)  1.33
 set myMPSet(LateralSampling)    0.1
 set myMPSet(AxialSampling)      0.3
 set myMPSet(PinholeRadius)      {374.18 224.03 252.6}
 set myMPSet(ExcitationWavelength) {364 488 543}
 set myMPSet(EmissionWavelength) {470 525 570}
 set myMPSet(MicroscopeType)     confocal
 set myMPSet(RefractiveIndexLensMedium) 1.515
 set myMPSet(RefractiveIndexSpecimenMedium) 1.44


 # Register it for future reference:
 registerMPSet myMPSet


 # Define a few restoration parameter sets:
 set myRPSet(Method)             cmle
 set myRPSet(SignalToNoise)      {30 50 3}
 set myRPSet(MaxIterations)      30
 set myRPSet(Timeout)            6000
 set myRPSet(QualityCriterion)   0.01
 set myRPSet(BackgroundMode)     manual
 set myRPSet(BackgroundPerc)     {0 0 0}

 # Register it for future reference:
 registerRPSet  myRPSet

 #
 # Set the project 'root' directory to which all image file pathnames are
 # relative:
 #
 setRootDirectory "."

 #In this path a directory "Results" will be created which will contain
 #the deconvolved images.
 #
 setResultsPath "~/Huygens_Batch"


 #
 #                       THE TASK QUEUE
 #
 # Each task consists of one or two filenames, a word indicating the method
 # to be used, two parameter sets and an optional double-quoted string
 # containing option-value pairs to be added to the image restoration command.
 #
 # The items in a task are as follows:
 #
 # 1- The first word of the task is the filename of a measured image,
 # 2- the name of the PSF (or 'auto' if it is unavailable),
 # 3- a microscopic parameterset or '-' if you are sure the parameters in the
 #    image file are fully correct,
 # 4- a restoration parameterset,
 #
 # Example:
 #
 # addTask faba64.ics  auto myMPSet  myRPSet
 #
 # You can use 'glob' style wildcards to select files.
 # Example:
 # foo*.ics will match fooBar.ics fooCell.ics, and so on.
 #
 # Do NOT use wildcards in combination with numbered TIFF series in such a way
 # that the wildcards can be confused with the index numbers.

 addTask faba64.ics  fabaPsf.ics  myMPSet  myRPSet
----

Image restoration


In most of the cases you don't need to edit anything else than batchCtl.tcl. But you may want to modify the commands that are actually executed on every image. These are in the script restOneImage.tcl, defined in the procedure cmdRestore, that looks like this:


  #   FILE restOneImage.tcl --
 #
 #   Restore a single image
 #   Intended to be used by supervisor script like doBatch.tcl.

[...]

proc cmdRestore {original method psf dest optStr bgMode bgStr} {

  #deconvolution
  set executing "$original $method $psf -> $dest $optStr -bgMode $bgMode $bgStr"
  myprint "Executing $executing"

  if [catch {eval $executing} result] {
    error "Failed to save execute command: $executing"
  }

  # calculate maximum
  set paramlist [$dest stat -tclReturn]
  array set param $paramlist
  set maxval $param(maxValue)
  if {$maxval <= 255} {
     myprint "Executing $dest convert -type byte"
     $dest convert -type byte
  } elseif {$maxval <= 32767} {
     # convert to integer type
     myprint "Executing $dest convert -type int"
     $dest convert -type int
  }

}
----



Contact Information

Scientific Volume Imaging B.V.

Laapersveld 63
1213 VB Hilversum
The Netherlands


Phone: +31 (0)35 64216 26
Fax: +31 (0)35 683 7971
E-mail: info at svi.nl

Image Image Image Image Image Image