I was trying to convert a DICOM stack to a NifTI in Python when I realized
itk.Image is not wrapped for pixel type
int. I installed itk through Anaconda.
It is my understanding that if I defined a variable of type
int in C, the size would be platform dependant. However, it wouldn’t make sense for the image data pixel type to be platform dependant.
Can I assume that if an image has pixel type
int I can read it in as type
short? When I read the DICOM in as type
short, the data looks correct when rendered. I just want to know if this is a fluke.
Here is how I determine the pixel type:
# Try to get the ImageIO given the file name imageIO = itk.ImageIOFactory.CreateImageIO(file_name, itk.ImageIOFactory.ReadMode) if imageIO is None: return None imageIO.SetFileName(file_name) imageIO.ReadImageInformation() # Get pixel type pixel_type_as_string = imageIO.GetComponentTypeAsString(imageIO.GetComponentType())