Open auneri opened 1 month ago
You may find this SimpleITK Example relevant. A similar approach should be possible with ITK Python: https://simpleitk.readthedocs.io/en/master/link_Logging_docs.html
Thanks, that is indeed very relevant. If I understand it correctly, this solution would require a LoggerBase
class implemented on the ITK (C++) side.
I also noticed ITK has TextOutput
, LoggerOutput
, and FileOutputWindow
, all derived from OutputWindow
. Only OutputWindow
is exposed in Python. I wonder if TextOutput
would do the job in this case. Something like:
text = itk.TextOutput.New() # after TextOutput gets wrapped
itk.OutputWindow.SetInstance(text)
I even tried defining my own TextOutput
class in Python, but was not able to overload methods like DisplayText
.
@N-Dekker are your experiences with logging in elastix relevant here?
Sorry, I don't really know. Looks like itkWarningMacro outputs to standard error (std::cerr
) by default, as that's what OutputWindow::DisplayText
does. Is it not possible to show standard error output directly in a notebook? And why isn't itk::TextOutput available in Python? Again, I don't know 🤷
Description
When using itk inside a jupyter notebook, warnings triggered by itkWarningMacro (and possibly others) are streamed to the server console instead of the notebook.
Steps to Reproduce
Expected behavior
The following warning should appear in the notebook:
Actual behavior
The warning only appears in the jupyter server console.
Reproducibility
Happens every time.
Versions
Tested on v5.3 and v5.4.
Environment
Tested on Windows 10 and 11.
Additional Information