Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

493 integrate 3rd party transforms into MONAI #500

Merged
merged 10 commits into from
Jun 8, 2020
Merged

493 integrate 3rd party transforms into MONAI #500

merged 10 commits into from
Jun 8, 2020

Conversation

Nic-Ma
Copy link
Contributor

@Nic-Ma Nic-Ma commented Jun 6, 2020

Fixes #493 .

Description

This PR implemented a tutorial to integrate 3rd party transforms into MONAI.
Including: BatchGenerator, TorchIO and Rising.

Status

Ready

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or new feature that would cause existing functionality to change)
  • New tests added to cover the changes
  • Docstrings/Documentation updated

@hjmjohnson
Copy link
Contributor

@Nic-Ma EXCELLENT. I need the MRI Bias correction capabilities from TorchIO for my work in about 2 weeks from now.

Thank you.

@wyli
Copy link
Contributor

wyli commented Jun 6, 2020

@Nic-Ma EXCELLENT. I need the MRI Bias correction capabilities from TorchIO for my work in about 2 weeks from now.

Thank you.

do you mean randomised simulation of bias fields? I don't think there's a bias field correction algo in TorchIO

@hjmjohnson
Copy link
Contributor

@Nic-Ma EXCELLENT. I need the MRI Bias correction capabilities from TorchIO for my work in about 2 weeks from now.
Thank you.

do you mean randomised simulation of bias fields? I don't think there's a bias field correction algo in TorchIO

Yes. I do mean simulation of bias fields. I misspoke. Much of my input data is overly pre-processed, and I need to simulate what would come off the scanner. I need to simulate the "undoing" of correction. :).

@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented Jun 7, 2020

/black

@Nic-Ma Nic-Ma changed the title [WIP] 493 integrate 3rd party transforms into MONAI 493 integrate 3rd party transforms into MONAI Jun 7, 2020
@wyli
Copy link
Contributor

wyli commented Jun 7, 2020

have you tried the adaptor in MONAI? I put a quick example here:

from monai.transforms import Compose, adaptor


class MyTransform:
    def __call__(self, **args):
        return {"img": args["image"] + 1, "new_field": args["seg"] + 1}


class MyTransformDict:
    def __call__(self, data_dict):
        data_dict["images"] += 1
        return data_dict


xform = Compose([adaptor(MyTransform(), outputs={"img": "image", "new_field": "images"}), MyTransformDict()])


out = xform({"image": 1, "seg": 2})
print(out)

>>> {'image': 2, 'seg': 2, 'images': 4}

@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented Jun 7, 2020

Hi @wyli ,

Thanks for your review and suggestions.
With adaptor, it can compose all the transforms now.
Could you please help review it again?
Thanks.

@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented Jun 7, 2020

/black

monai/data/dataset.py Outdated Show resolved Hide resolved
@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented Jun 8, 2020

Hi @wyli ,

Thanks for your review.
I updated the PR to address the comments.
Could you please help review it again?
Thanks.

Copy link
Contributor

@wyli wyli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for looking into these!

cc @mjorgecardoso @anfeng @atbenmurray

examples/README.md Outdated Show resolved Hide resolved
@wyli wyli merged commit 120f198 into Project-MONAI:master Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to integrate transforms from BatchGenerator, TorchIO and Rising
4 participants