Replies: 1 comment 1 reply
-
Hi, @c-winder. This is not a TorchIO issue but a SimpleITK issue, but I think you can solve it like this: import SimpleITK as sitk
sitk.ProcessObject_SetGlobalWarningDisplay(False)
tio.ScalarImage(DICOM_DIRECTORY)
sitk.ProcessObject_SetGlobalWarningDisplay(True) I guess you could create a context manager: @contextmanager
def suppress_sitk_warnings():
display_sitk_warnings = sitk.ProcessObject_GetGlobalWarningDisplay()
sitk.ProcessObject_SetGlobalWarningDisplay(False)
yield
sitk.ProcessObject_SetGlobalWarningDisplay(display_sitk_warnings) Does that help? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm trying to catch warnings thrown by SITK while using
tio.ScalarImage(DICOM_DIRECTORY)
to read a DICOM series.The warnings are as follows:
WARNING: In D:\a\1\sitk-build\ITK-prefix\include\ITK-5.3\itkImageSeriesReader.hxx, line 478 ImageSeriesReader (0000016B8C6D7180): Non uniform sampling or missing slices detected, maximum nonuniformity:1112.44
I believe these are thrown by corrupt scans in my dataset, and I would like to catch these warnings so that I can filter such scans from my dataset. Unfortunately this is not as simple as using
warnings.filterwarnings("error")
, as the error is thrown by C code in SITK and not recognised by Python. Is there a way around this?Beta Was this translation helpful? Give feedback.
All reactions