Skip to content
Discussion options

You must be logged in to vote

Hi @Minxiangliu , RandShiftIntensity cannot support your requirement directly. You may need to define a customized transform. Here is an example:

from monai.utils.enums import TransformBackends
from monai.transforms.transform import Transform
from monai.transforms import RandShiftIntensity
import torch

class FgShift(Transform):

    backend = [TransformBackends.TORCH]

    def __init__(self, offsets, prob = 0.1, bg_value = 0.0):
        self.shifter = RandShiftIntensity(offsets=offsets, prob=prob)
        self.bg_value = bg_value

    def __call__(self, img, offset = None):
        """
        Apply the transform to `img`.
        """
        out = torch.where(img != self.bg_value, self.…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Minxiangliu
Comment options

@yiheng-wang-nv
Comment options

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