question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

transform torchio subject - mask with multiple masks and different shapes than image

See original GitHub issue

I have an RGB Image and a 7-class ground truth mask and I’m trying to figure out how to integrate torchio into my pipeline. I get this error

ValueError: Images in sample have inconsistent shapes:
{'Image': (1, 3, 4041, 2817), 'Mask': (1, 7, 4041, 2817)}

Also, when transforming the ground truth mask, what is the appropriate shape? onehot (eg. 1, 7, 4041, 2817) or categorical (eg. 1, 1 ,4041, 2817)?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
fepegarcommented, Jul 12, 2020

You can use image_interpolation='linear'.

Interpolation with B-splines of order 1 is equivalent to using linear interpolation, AFAIK. In 2 and 3D, linear interpolation is also called bilinear and trilinear interpolation, respectively.

0reactions
xen0f0ncommented, Jul 12, 2020

Yes. I though that Resample does resize… Although I resize 2d images, I think it works. I use the bspline interpolation method (since there is no bilinear or bicubic). Am I missing something?

Read more comments on GitHub >

github_iconTop Results From Across the Web

torchio.transforms.preprocessing.intensity.mask - Read the Docs
If ``None``, all values larger than zero will be used for the mask. ... image to mask >>> transformed = mask(subject) # Set...
Read more >
TorchIO: A Python library for efficient loading ... - arXiv
We present TorchIO, an open-source Python library to enable effi- cient loading, preprocessing, augmentation and patch-based sampling of medical.
Read more >
API Reference - ivadomed documentation
Compute a soft Dice coefficient between im1 and im2, ie equals twice the sum of the two masks product, divided by the sum...
Read more >
TorchIO: a Python library for efficient loading ... - arXiv Vanity
In comparison, many medical images are reconstructed such that voxel location ... TorchIO provides several MRI-specific augmentation transforms related to ...
Read more >
How to perform identical transform on both image and target ...
If you want to treat each mask separately as a sample, you could call view(-1, height, width) on it to put all masks...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found