Skip to content
Discussion options

You must be logged in to vote

good question, one way to do it is to use the adaptor API in monai.transforms

How to use the adaptor function

import numpy as np
from scipy import ndimage

from monai.transforms import Compose, LoadImageD, adaptor


def PixelSpacing(pxlsp, target_space=[0.4, 0.4, 0.4]):
    def pixelspacing(img, pxlsp=pxlsp, target_space=target_space):
        orig_shape = img.shape
        target_shape = [
            int(np.round(orig_shape[0] * (target_space[0] / pxlsp[0]))),
            int(np.round(orig_shape[1] * (target_space[1] / pxlsp[1]))),
            int(np.round(orig_shape[2] * (target_space[2] / pxlsp[2]))),
        ]

 …

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@Maryam-Mostafa
Comment options

@wyli
Comment options

wyli Aug 1, 2022
Collaborator

@Maryam-Mostafa
Comment options

@wyli
Comment options

wyli Aug 1, 2022
Collaborator

@Maryam-Mostafa
Comment options

Answer selected by Maryam-Mostafa
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