-
Notifications
You must be signed in to change notification settings - Fork 54
Description
Describe the bug
Tested the App SDK using the Jupyter Notebook example after the latest version of one of the key dependencies, HSDK v3.5, has been released. The test due to an error encountered in the dicom_series_to_volume_operator.py when values to see if it can_cast
to certain NumPy type,
"can_cast() does not support Python ints, floats, and complex because the result used to depend on the value.\nThis change was part of adopting NEP 50, we may explicitly allow them again in the future."
Steps/Code to reproduce bug
Execute the Prostate Seg example app in the Jupyter notebook.
Expected behavior
The latest changes in the dependencies have bumped the NumPy version to greater than v2.0, and the MD App SDK code should be updated use the NumPy can_cast
function as required to avoid runtime error.
Environment details (please complete the following information)
- OS/Platform: Ubuntu 22.04.5 LTS
- Python Version: 3.10.12
- Method of MONAI Deploy App SDK install: [pip and from source]
- SDK Version: 3.0
Additional context
The error has been analyzed for the root cause, and a fix is known.
In the last round of the updates of the dicom_series_to_volume_opertator, the NumPy can_cast
function was used to detect if the pixel data array, intercept, and slope can be casted to the smallest size of NumPy types.
Pixel data read using pydicom is in NumPy types, however, both intercept [0x0028, 0x1052] and slope [0x0028, 0x1053] values are of type pydicom.valuerep.DSfloat which are stored as Python float.
The change in numpy.can_cast() to no longer support Python int, float, and complex directly, which was part of adopting NEP 50, occurred in NumPy version 2.0. So these Python types should converted to NumPy scalar types (e.g., np.int32, np.float64, np.complex128) before using them with can_cast().