preprocessing and crop or pad #1129
Replies: 3 comments 2 replies
-
|
Hi, @EvelyneCalista. Neither of those are expected. Can you please share some code so we can reproduce the issue? |
Beta Was this translation helpful? Give feedback.
-
|
Hi @fepegar , class ResampleXY:
def __init__(self, spacing_x, spacing_y):
self.spacing_x = spacing_x
self.spacing_y = spacing_y
def __call__(self, subject):
sx,sy,sz=subject.spacing
resampling = tio.Resample((self.spacing_x, self.spacing_y, sz))
resmpled_img = resampling(subject)
return resmpled_img
if __name__ == "__main__":
for id in subjid:
save_dir = os.path.join(savepath, str(id))
if not os.path.exists(save_dir):
os.makedirs(save_dir)
scan = os.path.join(rootpath,str(id)+'/scan.nii')
mask_label = os.path.join(rootpath,str(id)+'/label.nii')
mask_lb = glob.glob(os.path.join(root_mask,str(id),'*.nii'))[0]
crop_shape=(512,512,44)
resize_ds_rate = (2,2,1)
subject = tio.Subject(
image=tio.ScalarImage(scan),
mask_img = tio.ScalarImage(mask_lb),
label = tio.LabelMap(mask_label))
transforms = [
tio.ToCanonical(),
ResampleXY(spacing_x=0.45, spacing_y=0.45),
tio.CropOrPad(crop_shape,mask_name='label'),
tio.RescaleIntensity()
]
transform = tio.Compose(transforms)
preprocessed = transform(subject)
preprocessed.image.save(os.path.join(save_dir,'croppad.nii.gz'))
preprocessed.mask_img.save(os.path.join(save_dir,'mask.nii.gz')) |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for your advice, I have updated the version now. I use ITK-SNAP, would this visualization tool good enough? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi ,
I would like to ask several questions about the pre-processing transform.
I tried with other image to check, but it looks normal (the header not get changed).
I use torchio version0.18.63. is this a bug or did i make a mistake?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions