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.

Coding issue with nibabel--- + Torchio

See original GitHub issue

Hi. Thx for this wonderful repository.

I have a question. If I get the image + labels array for all my data, and corresponding ground truths with img=nib.load(os.path…), with gt… Then, I use img=img_getdata()…, then return them. So then, my question=> in order to use Torchio, which I guess whill be provided by the (subjects, channel, h,w,d)----nibabel, right? If that’s correct, do I need to use then as—

For example a class,

if transform is None:

            if mode == 'train':

               transform = ([
               tio.RandomAffine(): 0.75,
               tio.RandomElasticDeformation(): 0.25,
               tio.RandomAffine(scales=(0.9, 1.2), degrees=(10)),
               tio.RandomFlip(axes=('LR'))..... Likewise
               ])

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
fepegarcommented, Oct 21, 2020

Typically, array = img.get_data() will return a NumPy array of shape (w, h, d). You can add a channels dimension doing for example array[np.newaxis]and passing that to the tensor kwarg of tio.ScalarImage. But this is probably not necessary. Just pass the image path to tio.ScalarImage and it will take care of reading it.

I suggest you take a look at the Getting started section in the docs, and go through all the notebooks.

1reaction
fepegarcommented, Oct 21, 2020

I’m not sure what the question is. Can you maybe try to be more specific?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dataloader fails for some images #669 - fepegar/torchio - GitHub
Although I am able to load the image without issue witth Nibabel along with on ITKSnap, 3DSlicer and FSLeyes.
Read more >
torchio.transforms.preprocessing.spatial.to_canonical
Source code for torchio.transforms.preprocessing.spatial.to_canonical. import nibabel as nib import numpy as np import torch from ... import ...
Read more >
TorchIO: a Python library for efficient loading ... - arXiv Vanity
TorchIO is an open-source project with code, comprehensive examples and extensive ... tool for solving problems related to image understanding and analysis.
Read more >
Working with nibabel source code - Nipy
Working with nibabel source code¶ · Introduction · Install git · Overview · In detail · Following the latest source · Get the...
Read more >
TorchIO: A Python library for efficient loading ... - arXiv
Source code, comprehensive tutorials and extensive documentation for ... TorchIO uses the medical imaging libraries NiBabel and SimpleITK to ...
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