Skip to content

PROBLEM ON SAVING A PARTICULAR DATA TYPE #1234

Answered by ericspod
cugwu asked this question in Q&A
Discussion options

You must be logged in to vote

What version of MONAI are you using? Please run monai.config.print_config() to print out the config information. I'm using the current dev version of MONAI which is based off 1.1 and am getting these results:

import torch
import numpy as np
import nibabel as nib
from monai.utils import ImageMetaKey
from monai.data import MetaTensor
from monai.transforms import SaveImage

m=MetaTensor(torch.zeros(16,16,dtype=torch.uint8))
m.meta[ImageMetaKey.FILENAME_OR_OBJ]="test"

s=SaveImage(output_dtype=np.uint8, output_dir="/tmp", output_ext=".nii.gz", output_postfix="", separate_folder=False, resample=False)
s(m)

d=nib.load("/tmp/test.nii.gz")
print(d.dataobj.dtype)  # prints uint8

The nifti file he…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@cugwu
Comment options

@ericspod
Comment options

@cugwu
Comment options

@ericspod
Comment options

Answer selected by cugwu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants