[elastix] Elastix verbosity

Stefan Klein s.klein at erasmusmc.nl
Wed Mar 24 17:01:33 CET 2010

Hi Mark,

Sounds like a good idea, these three levels of verbosity. See below for 
some suggestions.

M.Staring at lumc.nl wrote:
> Hi Mark, 
>> Hi Marius,
>> I can certainly take a look at the source and see what I can 
>> do-- may take me a bit, since I'm inundated with projects at 
>> the moment.
> That's great!
>> What I'd like are three levels of verbosity redirected to cout:
>> 0) errors, warnings, and progress (what it is now)
>> 1) errors and warnings (so the 100 iterations of matching 
>> don't show up)
>> 2) errors only (so the warnings about what parameters are 
>> missing don't show up)
>> 3) pass/fail (the 0/1 output you described) So, when I run 
>> the script (on windows atm, so I'll have to look into the 
>> redirects there), I'd like to set --verbosity (or --v) to 
>> some number between 0 and 3, with 0 as the default.
>> The problem as I see it is that I don't know where these 
>> things are being piped at the moment-- is it all to cout and 
>> cerr?  Or are you doing something where all outputs are sent 
>> to a logging class, at which point I could determine which go 
>> to cout and which do not?
>> Because if you have the class already set up, I think it'd be 
>> a trivial thing to change.  If not, it will take me a bit.  
>> Also, I don't know how ITK does its error reporting, and it 
>> appears to be itk problems I need reported, but I'm not sure.
> We use some special classes for that. They can be found at:
> 	elastix\src\Common\xout
> In elastix\src\Core\Kernel\elxElastixMain.cxx in the function xoutSetup() we set up the outputs. For example like:
> 	xout.AddOutput("cout", &std::cout);
> 	xout.AddTargetCell( "warning", &g_WarningXout );
>   	xout.AddTargetCell( "error", &g_ErrorXout );
> We already make a distinction in warnings, errors, etc. Currently, we sent everything to the elastix.log file. I don't think that should change, because it gives the user a place to find all details. We sent the iterations info to elastix.log and to iterationinfo.txt files and to std::cout. I think you can either alter the xout classes, or maybe better at the place(s) where xout is being setup. The new code should then take into account the verbosity options that are set by the user, so that based on these options for example xout["warning"] is connected to std::cout. I guess something like:
> 	if ( verbosity == 0 or 1 )
> 	{
> 	  xout.AddTargetCell( "warning", &g_WarningXout );
> 	}
> Stefan can give you more information about the implementation details, since he created the xout stuff.

In src/Core/Kernel/elxElastixBase.cxx, line 96 (::BeforeAllBase()), you 
could read the "VerbosityLevel" parameter from the parameter file, and 
based on its value modify the xout properties.

if ( verbosity >1 )

And after line 325 also read the verbosity level from the parameter file 
and add:

if ( verbosity >0 )

Instead of removing the xout["warning"] "cout" output at line 96, you 
could also change:
src/Core/Configuration/elxConfiguration.cxx, line 167 and further.
That code implements the PrintErrorMessages parameter. So it could be 
easily changed to read the VerbosityLevel (instead of the 
PrintErrorMessages parameter). This solution would have the advantage 
that other warnings, not related to missing parameters, are still shown. 
Line 170 explicitly turns off only warnings related to missing parameters.

Let me know if you have questions.

>> On Thu, Mar 18, 2010 at 1:32 AM,  <M.Staring at lumc.nl> wrote:
>>> Hi Mark,
>>> There exists an option
>>>        (PrintErrorMessages "false")
>>> which will print less/no error messages.
>>> This is not a commandline switch, but a parameter file entry.
>>> Note that in a bash script you can remove (redirect) all elastix 
>>> output with
>>>        elastix -f .... >> /dev/null
>>> Unfortunately, you cannot control the elastix output with the 
>>> granularity you want. I understand you like to have that feature to 
>>> automatically detect what exactly went wrong in case of an error?
>>> Also note that elastix does exit with a return code: 0 if 
>> everything 
>>> went ok, 1 if something went wrong.
>>> Would you like to have different return codes for the 
>> several errors 
>>> you mention?
>>> Or would you like to have something easily grep-able in the 
>>> elastix.log file, which enables automatic checking of the error?
>>> And: would you like to be the one that modifies the elastix 
>> sources to 
>>> implement this feature :-)
>>> Let me know if I understood your question correctly. Cheers,
>>> Marius
>>>> -----Original Message-----
>>>> From: Mark Roden [mailto:mmroden at gmail.com]
>>>> Sent: woensdag 17 maart 2010 22:07
>>>> To: Staring, M. (LKEB)
>>>> Cc: jonmorra at gmail.com; s.klein at eramusmc.nl; 
>>>> daniel.valentino at gmail.com; elastix at bigr.nl
>>>> Subject: Elastix verbosity
>>>> Hi Marius,
>>>> I'm having some problems with running elastix as part of a script.
>>>> Unfortunately, the verbosity of elastix is very high, and there 
>>>> doesn't appear to be a command-line switch to turn it 
>> down.  Is there 
>>>> one, and I'm just missing it?  I don't need to see the 100 
>> iterations 
>>>> to do registration, nor the missing parameters that aren't in the 
>>>> text file.  I do, however, need to see the itk load errors 
>> that are 
>>>> happening, and figure out if that's a problem with inputs, 
>> outputs, 
>>>> and so forth.
>>>> Thanks,
>>>> Mark
> _______________________________________________
> elastix mailing list
> elastix at bigr.nl
> http://lists.bigr.nl/mailman/listinfo/elastix

More information about the Elastix mailing list