Hello, I am using simpleitk to write mhd files using
sitk.WriteImage(img, ‘file.mhd’)
The output file is of mhd + zraw type.
How can I generate mhd + raw files using simpleitk?
Thank you in advance!
Hello, I am using simpleitk to write mhd files using
sitk.WriteImage(img, ‘file.mhd’)
The output file is of mhd + zraw type.
How can I generate mhd + raw files using simpleitk?
Thank you in advance!
.zraw
is used when the file compression is enabled, .raw
is used then file is uncompressed.
If it is a one-off thing, you could edit .mhd
file and change the file name along with renaming the actual file.
Hello @totoro3y,
The default setting for WriteImage
's useCompression
variable is False
so surprising that your code creates a file with zraw extension. The following short snippet illustrates how the extension varies if compression is on or off:
import SimpleITK as sitk
img = sitk.ReadImage('training_001_ct.mha')
sitk.WriteImage(img,'with_compression.mhd', useCompression = True)
sitk.WriteImage(img,'no_compression.mhd')
Hello, Thank you for sharing your reply. I tried as you said however, an error has raised.
Traceback (most recent call last)
----> 2 sitk.WriteImage(out_img, ‘out.mhd’,useCompression = True)
TypeError: WriteImage() got an unexpected keyword argument ‘useCompression’
Do you have any idea about that?
Thank you!
Hello @totoro3y,
Possibly a toolkit version issue. Code looks good and works with the latest SimpleITK release, version 2.0.2.