next up previous [pdf]

Next: Creating reproducible documentation Up: Example experiments Previous: Example 1

Example 2

The plan for this experiment is to add random noise to the test ``Lena'' image and then to attempt removing it by low-pass filtering and by hard thresholding of coefficients in the Fourier domain. The result images are shown in Figure 3 and 4.

panel1
panel1
Figure 3.
Top left: original image. Top right: random noise added. Bottom left: original image spectrum in the Fourier ($F$-$X$) domain. Bottom right: noisy image spectrum in the Fourier ($F$-$X$) domain.
[pdf] [png] [scons]

panel2
panel2
Figure 4.
Left: denoising by low-pass filtering. Right: denoising by hard thresholding in the Fourier domain.
[pdf] [png] [scons]

Since the SConstruct| file is a Python script, we can also use all the flexibility and power of the Python language in our Madagascar reproducible scripts. A demo script is available in the rsf/scons/rsfpy subdirectory of the Madagascar book directory. Rather than commenting it line-by-line, we select some parts of interest.

In the SConstruct script, we can declare Python variables

and use them later, for example, to define our customized plot command as a Python function

This Python function, named grey(), can then be called in Plot or Result commands, e.g.

We can define a Python dictionary, e.g.

and loop over its entries, e.g.

Note that the title of the plots is obtained by concatenating Python strings.

Python strings can also be used to define sequences of commands used in several Flows, e.g.

Finally, in our Madagascar reproducible script, we may want the option to pass command line arguments when running SCons or use default values otherwise, e.g.

Running scons only, the default value set for fthr (i.e. 70) is used whereas running scons fthr=68 set fthr to a command line specified value.

This is by no mean an exhaustive list of options but, hopefully, it gives you a flavor of the powerful tool you have in hands. Enjoy!


next up previous [pdf]

Next: Creating reproducible documentation Up: Example experiments Previous: Example 1

2012-07-19