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

Spacing MetaTensor #4319

Merged
merged 17 commits into from
May 24, 2022
Merged

Conversation

rijobro
Copy link
Contributor

@rijobro rijobro commented May 23, 2022

Spacing compatible with MetaTensor. Array transform now also has inverse method.

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • New tests added to cover the changes.

Signed-off-by: Richard Brown <[email protected]>
@rijobro rijobro requested review from wyli, ericspod and Nic-Ma May 23, 2022 10:42
rijobro added 2 commits May 23, 2022 11:46
Signed-off-by: Richard Brown <[email protected]>
Signed-off-by: Richard Brown <[email protected]>
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 the transform becomes easier to use with MetaTensor

monai/transforms/spatial/array.py Show resolved Hide resolved
monai/transforms/spatial/array.py Show resolved Hide resolved
rijobro added 5 commits May 23, 2022 14:11
Signed-off-by: Richard Brown <[email protected]>
Signed-off-by: Richard Brown <[email protected]>
Signed-off-by: Richard Brown <[email protected]>
Signed-off-by: Richard Brown <[email protected]>
Signed-off-by: Richard Brown <[email protected]>
@rijobro
Copy link
Contributor Author

rijobro commented May 23, 2022

@wyli Do you think you can help me with this error in the github action? I can't reproduce it locally. I think it's complaining that img_.device doesn't work when img_ is a np.ndarray. But the code before looks like this:

if get_track_meta():
    img_ = img if isinstance(img, MetaTensor) else MetaTensor(img)
    img_, *_ = convert_data_type(img, dtype=_dtype)
else:
    img_, *_ = convert_data_type(img, torch.Tensor, dtype=_dtype)

It seems to me that in all cases, img_ should be of type torch.Tensor and so `device`` should be available.

rijobro added 2 commits May 23, 2022 17:03
Signed-off-by: Richard Brown <[email protected]>
Signed-off-by: Richard Brown <[email protected]>
@wyli
Copy link
Contributor

wyli commented May 23, 2022

img_ should be of type torch.Tensor and so `device`` should be available.

looks like you addressed the issue... I'll merge this PR and #4308 and have the full integration tests soon.

@wyli wyli merged commit 361cac3 into Project-MONAI:feature/MetaTensor May 24, 2022
@rijobro rijobro deleted the Spacing_MetaTensor branch May 24, 2022 08:45
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.

3 participants