I am getting this python TypeError TypeError: sequence item 0: Unable to cast Python instance to C++ type (compile in debug mode for details) everytime I try to run an algorithm on a basic ultrasound image. I followed the steps on the Python SDK documentations Basic usage part. Here is the code:
Just passing the image as an argument fixed the issue. Now the problem I am having is that the “Generate confidence maps” algorithm does not accept my images.
At first I thought the issue was that the images were not ultrasound images, which the confidence map needs. So I added the img2 line where I set the modality of the image to an ultrasound but I still get the following error:
imfusion._bindings.IncompatibleError: No algorithm called 'Ultrasound;Compute Confidence Maps' is compatible with the given data.
Do you know how I can run the confidence maps algorithm correctly?
I had a closer look at the SetModalityAlgorithm and it seems that you need to pass the modality not as a string but rather as the Data::Modality enum value (if you have the SDK, have a look at Data.h)
enum Modality
{
NA = 0, ///< Not applicable
XRAY = 1, ///< 2D X-Ray based data
CT = 2, ///< X-Ray Computed Tomography
MRI = 3, ///< Magnetic Resonance Imaging (MRI)
ULTRASOUND = 4, ///< Ultrasound image data
VIDEO = 5, ///< Video / optical image data
NM = 6, ///< Nuclear Medicine (SPECT or PET)
OCT = 7, ///< Optical Coherence Tomography
LABEL = 8 ///< Labeling data/label map
};
I believe the error might be caused because there is only a single image in the sharedImageSet. In the ImFusionSuite application I also was not able to generate confidence maps of single ultrasound images. I would need to add multiple images to the SharedImageSet for that.
I will be getting images either as openCV images or numpy arrays. I want to add them to the ImageSet and set their modality to ultrasound and finally convert them to confidence maps. For a quick test I have the code below but setting the modality gives an error.
imfusion.init()
# Generate empty image set
imageset = imfusion.SharedImageSet(np.zeros([2, 714, 816, 1], dtype='uint8'))
# Open US image
img = imfusion.open("images/testImages/test_snap1.png")
# Add the same image to the set twice
np.append(imageset, img)
np.append(imageset, img)
# This line causes an error, I also tried running it with imageset[0] but I got the same error
imfusion.executeAlgorithm('Set Modality', imageset, { 'modality': 4 })
imfusion.executeAlgorithm('Ultrasound;Compute Confidence Maps', imageset)