Batchmake slicer: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
No edit summary
Line 1: Line 1:
*BatchMake in Slicer
===BatchMake in Slicer===
BatchMake has been integrated in Slicer since version 3. A "BatchProcessing" subsection can be found in the list of Slicer modules. There are BatchMake into that section: "Gaussian Blur BatchMake", "Registration BatchMake" and "EMSegment BatchMake". All three modules are internally calling the Slicer modules, respectively "Gaussian Blur", "Register Images" and "EMSegment Simple".
BatchMake has been integrated in Slicer since version 3 and highly improved in [http://wiki.slicer.org/slicerWiki/index.php/Documentation-3.4 version 3.4]. A "Batch Processing" category can be found in the list of Slicer modules.<br>
There are 4 modules into the Batch Processing subsection: [http://wiki.slicer.org/slicerWiki/index.php/Modules:GaussianBlurBatch-Documentation-3.4 Gaussian Blur BatchMake], [http://wiki.slicer.org/slicerWiki/index.php/Modules:RegisterImagesBatch-Documentation-3.4 Register Images BatchMake], [http://wiki.slicer.org/slicerWiki/index.php/Modules:EMSegmentBatch-Documentation-3.4 EMSegment BatchMake] and [http://wiki.slicer.org/slicerWiki/index.php/Modules:ResampleVolumeBatch-Documentation-3.4 Resample Scalar Volume BatchMake]. All the Batch modules are internally calling Slicer modules, respectively [http://wiki.slicer.org/slicerWiki/index.php/Modules:GaussianBlur-Documentation-3.4 Gaussian Blur], [http://wiki.slicer.org/slicerWiki/index.php/Modules:RegisterImages-Documentation-3.4 Register Images], [http://wiki.slicer.org/slicerWiki/index.php/Modules:EMSegment-Simple EMSegment Simple] and [http://wiki.slicer.org/slicerWiki/index.php/Modules:ResampleVolume-Documentation-3.4 Resample Scalar Volume].<br>
<br>
The ultimate strenght of batch processing is to run automatically multiple modules multiples times with multiple parameters on multiple inputs on multiple machines. <br>
Since [http://wiki.slicer.org/slicerWiki/index.php/Documentation-3.4 Slicer 3.4], you can easily transform any Slicer modules to support batch processing. Only minor changes in the module XML file are needed, no code rewriting.<br>
In this tutorial we will introduce you with BatchMake in Slicer and guide you step by step to batch process your data. We will also explain how you can create your own BatchMake module in Slicer.<br>


The ultimate strength of BatchProcessing is to run multiple modules multiples times with multiple parameters on multiple inputs without any human interaction. This is done by writing a script and executing it locally on your machine or externally using grid computing (Condor).
===How to run a BatchMake module locally?===
In this tutorial we will introduce you with BatchMake in Slicer and guide you step by step to do batch processing. We will also explain how you can create your own BatchMake module in Slicer.
{|
 
|[[Image:GaussianBlurBatchMake.png|thumb|300px|Gaussian Blur BatchMake GUI]]
** How to run a BatchMake module locally?
|}
[[Image:GaussianBlurBatchMake.png | thumb]]
In this section, we will see how to run locally (on your machine) a Gaussian Blur filter on a single image with different sigma values.
In this section, we will see how to run locally (on your machine) a Gaussian Blur filter on a single image with different sigma values.
***Launch Slicer
*Launch Slicer
***Open the "Gaussian Blur BatchMake" module located in "BatchProcessing"
*Open the "Gaussian Blur BatchMake" module located in "Batch Processing"
***Choose the different values you want sigma to vary. Generated files will have in their name a sigma suffix.
*By setting Sigma minimum, Sigman maximum and Sigma step, you change the number of times the Gaussian Blur module will be called with a different sigma. If Sigma minimum, maximum and step are respectively set to 1, 10 and 1; Gaussian Blur will be run 10 times, with a sigma varying from 1 to 10.
***Select a directory with images to process for "Data directory"
*Then fill "Data directory", a directory containing images to blur
***Create a mask that matches the filenames of the images to process in the previous directory for "Data file mask"
*Change the mask (wildcards) to select the images to blur based on their filenames.
***Choose an output directory where all the result images will be saved in for "Output directory
*Check "Recursive" if you want to recursively apply the "Data file" mask in the "Data directory".
***Make sure the "Run using Grid/Condor" checkbox is unchecked
*Choose an output directory where all the result images will be saved in for "Output directory"
***Press apply to launch the processing
*Make sure the "Run using Grid/Condor" checkbox is unchecked to run the module locally
Note: The GaussianBlur BatchMake module does not deal with Slicer objects but it deals with files directly. The inputs of the Gaussian Blur filter are the files found in the input directory. If Sigma minimum, Sigma maximum and Sigma step are respectively set to 1, 10 and 1, then 10 files will be created for each input file. For example, if you had 3 files in your input directory that match the "Data file mask", ie imageX.mha, imageY.mha and imageZ.mha all three matching *.mha; after the module is executed the output directory will contain: imageX-1.mha, imageX-2.mha ... imageX-10.mha, imageY-1.mha, imageY-2.mha ... imageY-10.mha, imageZ-1.mha, imageZ-2.mha ... imageZ-10.mha.
*Press apply to launch the processing
 
Note: The inputs of the Gaussian Blur filter are the files found in the input directory. If Sigma minimum, Sigma maximum and Sigma step are respectively set to 1, 10 and 1, then 10 files will be created for each input file. For example, if 3 files in the input directory  
** How to run Register Images on a Condor grid
imageX.mha, imageY.mha and imageZ.mha  
In this section, we will see how to register multiple moving images to a single fixed image.  
match the "Data file mask", (i.e. all three matching *.mha); after the module is executed the output directory will contain:  
We will assume that Condor has been already installed on your machine(s) and works properly.
imageX-1.mha, imageX-2.mha ... imageX-10.mha,
The first thing you have to do is to run Slicer with Condor privileges aka run Slicer as a Condor user. If you already are a Condor user, you can launch Slicer normally.
imageY-1.mha, imageY-2.mha ... imageY-10.mha,
$ ./Slicer3-build/Slicer3
imageZ-1.mha, imageZ-2.mha ... imageZ-10.mha
If you are a regular user with no condor privileges but you created a Condor user (called condor) on your machine, you should launch Slicer using your environment variables but as a Condor user:
{|
$ su condor -m -c ./Slicer3-build/Slicer3
|[[Image:GaussianBlurBatchMakeModuleInput.png|78px|thumb|Input images]]
Note: you should probably change the read/write access permissions of the Slicer temporary directories.
|[[Image:GaussianBlurBatchMakeModuleOutput.png|800px|thumb|Output images]]
Once Slicer is open, go in the BatchProcessing subsection and select "Registration BatchMake".<br>
|}
[[Image:RegistrationBatchMake-Selection.png|center|200px]]<br>
===How to run Register Images on a Condor grid===
In this section, we will see how to register - on different machines - multiple moving images to a single fixed image .  
We will assume that Condor has been already installed on your machine(s) and works properly. You must have created and configured a condor user account on your machine, the condor scripts generated by BatchMake will be executed by the condor user ( +Owner = condor ).
*Start Slicer as a regular user, there is no need to be a condor user.
*Open the "Register Images BatchMake" module located in "Batch Processing"
{|
|[[Image:RegistrationBatchMake-Selection.png|thumb|center|400px|Selection of the Register Images Batch module]]
|[[Image:RegisterImagesBatchMakeModule-RigidRegistration.png|thumb|center|400px|Register Images Batch GUI]]
|}
*


** How to vary the module parameters ?
===How to vary the module parameters ?===


** How to write your own Batch Processing module ?
===How to write your own Batch Processing module ?===
The BatchMake modules running on Condor don't support the <image> tags in the module XML files. Slicer pass <image> arguments to the modules the memory address where the image is loaded and not the filename of the image.  as <im they must be changed into <file> or <directory>+<string>. Share

Revision as of 19:19, 7 April 2009

BatchMake in Slicer

BatchMake has been integrated in Slicer since version 3 and highly improved in version 3.4. A "Batch Processing" category can be found in the list of Slicer modules.
There are 4 modules into the Batch Processing subsection: Gaussian Blur BatchMake, Register Images BatchMake, EMSegment BatchMake and Resample Scalar Volume BatchMake. All the Batch modules are internally calling Slicer modules, respectively Gaussian Blur, Register Images, EMSegment Simple and Resample Scalar Volume.

The ultimate strenght of batch processing is to run automatically multiple modules multiples times with multiple parameters on multiple inputs on multiple machines.
Since Slicer 3.4, you can easily transform any Slicer modules to support batch processing. Only minor changes in the module XML file are needed, no code rewriting.
In this tutorial we will introduce you with BatchMake in Slicer and guide you step by step to batch process your data. We will also explain how you can create your own BatchMake module in Slicer.

How to run a BatchMake module locally?

Gaussian Blur BatchMake GUI

In this section, we will see how to run locally (on your machine) a Gaussian Blur filter on a single image with different sigma values.

  • Launch Slicer
  • Open the "Gaussian Blur BatchMake" module located in "Batch Processing"
  • By setting Sigma minimum, Sigman maximum and Sigma step, you change the number of times the Gaussian Blur module will be called with a different sigma. If Sigma minimum, maximum and step are respectively set to 1, 10 and 1; Gaussian Blur will be run 10 times, with a sigma varying from 1 to 10.
  • Then fill "Data directory", a directory containing images to blur
  • Change the mask (wildcards) to select the images to blur based on their filenames.
  • Check "Recursive" if you want to recursively apply the "Data file" mask in the "Data directory".
  • Choose an output directory where all the result images will be saved in for "Output directory"
  • Make sure the "Run using Grid/Condor" checkbox is unchecked to run the module locally
  • Press apply to launch the processing

Note: The inputs of the Gaussian Blur filter are the files found in the input directory. If Sigma minimum, Sigma maximum and Sigma step are respectively set to 1, 10 and 1, then 10 files will be created for each input file. For example, if 3 files in the input directory

imageX.mha, imageY.mha and imageZ.mha 

match the "Data file mask", (i.e. all three matching *.mha); after the module is executed the output directory will contain:

imageX-1.mha, imageX-2.mha ... imageX-10.mha,
imageY-1.mha, imageY-2.mha ... imageY-10.mha,
imageZ-1.mha, imageZ-2.mha ... imageZ-10.mha
Input images
Output images

How to run Register Images on a Condor grid

In this section, we will see how to register - on different machines - multiple moving images to a single fixed image . We will assume that Condor has been already installed on your machine(s) and works properly. You must have created and configured a condor user account on your machine, the condor scripts generated by BatchMake will be executed by the condor user ( +Owner = condor ).

  • Start Slicer as a regular user, there is no need to be a condor user.
  • Open the "Register Images BatchMake" module located in "Batch Processing"
Selection of the Register Images Batch module
Register Images Batch GUI

How to vary the module parameters ?

How to write your own Batch Processing module ?

The BatchMake modules running on Condor don't support the <image> tags in the module XML files. Slicer pass <image> arguments to the modules the memory address where the image is loaded and not the filename of the image. as <im they must be changed into <file> or <directory>+<string>. Share