Skip to content
Discussion options

You must be logged in to vote

one possible option would be making a customized transform to assign the pixel size and SpacingD to normalize them:

import os
import numpy as np
import monai
from monai.transforms import Compose, Lambda, LoadImageD, SpacingD


class AssignPixelSize:
    def __init__(self, key, pixel_key):
        self.key = key
        self.pixel_key = pixel_key

    def __call__(self, data_dict):
        print(data_dict[self.pixel_key])
        data_dict[self.key].affine[0, 0] = data_dict[self.pixel_key][0]
        data_dict[self.key].affine[1, 1] = data_dict[self.pixel_key][1]
        return data_dict


filename = os.path.join(".", "MONAI-logo_color.png")
monai.apps.download_url("https://monai.io/assets…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@hermancollin
Comment options

Answer selected by hermancollin
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