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.

LabelMap creation from torchio.Image

See original GitHub issue

🐛Bug Sorry if I miss something here, but we used to declare LabelMap, from the torchio.Image function

To reproduce

# Your code here
import torchio as tio
sujbad = tio.Image(type=tio.LABEL, path='/mypath/mask.nii.gz')
sujok  = tio.LabelMap(path='/mypath/mask.nii.gz')

Expected behavior

I expect those 2 declaration to be equivalent (since the type can be specify in the Image constructor)

Actual behavior

type(sujbad)
torchio.data.image.Image

System info

Output of python <(curl -s https://raw.githubusercontent.com/fepegar/torchio/master/print_system.py):


Platform: Linux-4.15.0-139-generic-x86_64-with-glibc2.10
TorchIO:  0.18.39
PyTorch:  1.7.1
NumPy:    1.20.2
Python:   3.8.5 (default, Sep  4 2020, 07:30:14) 
[GCC 7.3.0]

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
fepegarcommented, May 28, 2021

will it makes a difference somewhere ?

At the moment, I’m not sure. I would need to look into it. But please do move to ScalarImage, as in the examples and tutorials, as this is now considered the standard way and using Image for scalar images will be removed in the future.

0reactions
romainValacommented, May 28, 2021

I understand, that creating a torico.Image with type=‘label’ is not a good idea, (because in other part of the code like for instance https://github.com/fepegar/torchio/blob/af86828360353dbe127d8195567ea4b9e83f238b/torchio/transforms/transform.py#L432, it will not be consider as a LabelMap

but is it also the case for intensity type ? should I also switch
tio.Image(type='intensity', path=path) to
tio.ScalarImage(path=path)

will it makes a difference somewhere ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Image - TorchIO - Read the Docs
An instance of Image can be created using a filepath, a PyTorch tensor, ... The instance of LabelMap contains a brain parcellation of...
Read more >
torchio/image.rst at main - GitHub
Subclasses are used to indicate specific types of images, such as :class:`ScalarImage` and :class:`LabelMap`, which are used to store, e.g., CT scans and ......
Read more >
TorchIO tutorial.ipynb - Colaboratory - Google Colab
LabelMap . The image class will be used by the transforms to decide whether or not to perform the operation. For example, spatial...
Read more >
Using data augmentation to generate new data for deep ...
Contribute to fepegar/SlicerTorchIO development by creating an account on GitHub. ... I exported an image as a volume (.nii) and volume label map...
Read more >
TorchIO: A Python library for efficient loading ... - arXiv
and LabelMap, which are used to store, e.g., CT scans and segmentations, respectively. An instance of Image can be created using a filepath, ......
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