How to disable logging in python, jupyter notebook

I am executing parallel processes in VS Code on Ubuntu, with each process invoking SimpleITK. However, the console output from these processes is causing VS Code to crash. How can I disable the logging?

Hello @hucang0,

When you say “console output from these processes” I assume you are referring to warnings printed from ITK/SimpleITK components and not your own? If yes, then you can turn those off sitk.ProcessObject.SetGlobalWarningDisplay(False).

For more details see the read-the-docs SimpleITK logging example.

@zivy. Thanks a lot. I tried. However, it still shows up as

Installing all components. InstallingComponents was successful. ELASTIX version: 5.000 Command line options from ElastixBase: -fMask unspecified, so no fixed mask used -mMask unspecified, so no moving mask used -out ./ -threads unspecified, so all available threads are used WARNING: The parameter “UseDirectionCosines”, requested at entry number 0, does not exist at all. The default value “true” is used instead. WARNING: The option “UseDirectionCosines” was not found in your parameter file. From elastix 4.8 it defaults to true! This may change the behavior of your registrations considerably. Command line options from TransformBase: -t0 unspecified, so no initial transform used Reading images… Reading images took 0 ms. WARNING: the fixed pyramid schedule is not fully specified! A default pyramid schedule is used. WARNING: the moving pyramid schedule is not fully specified! A default pyramid schedule is used. WARNING: The parameter “AutomaticTransformInitialization”, requested at entry number 0, does not exist at all. The default value “false” is used instead. WARNING: The parameter “AutomaticTransformInitializationMethod”, requested at entry number 0, does not exist at all. The default value “GeometricalCenter” is used instead. Transform parameters are initialized as: [1, 0, 0, 1, Installing all components.0, 0 ] InitializeTransform took 0.00s Scales are estimated automatically. InstallingComponents was successful. Installing all components. InstallingComponents was successful. ELASTIX version: 5.000 Command line options from ElastixBase: -fMask unspecified, so no fixed mask used -mMask unspecified, so no moving mask used -out ./ -threads unspecified, so all available threads are used

…

167 -1.272916 94.177550 0.236955 0.032454 3.5 86 -1.406025 50.804823 0.353821 0.049655 1.8 41 -1.304456 29.815753 0.578755 0.030514 8.2 120 127 -1.492951 73.615283 0.253649 0.046916 2.7 …"

Hello @hucang0,

This appears to be an Elastix message, so try calling LogToConsoleOff for the elastix filter.

1 Like

Zivy, thank you so much. It works now!