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.

Working with a dataset with different volumes

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Problem summary

I am working with BraTS 2021 dataset and I am not using patch-based training. The issue appears because I am feeding the model with volumes that have different heights and widths.

One solution is to use Resize. However, it causes deformation.

I tried using Resample to resample all the volumes in the dataset to one reference space. However, when plotting the results after resampling, it seems that the resampled volumes are also deformed.

given the code below,

Q1: did I do something wrong? Q2: is there a more robust way for unifying the height and width for all volumes?

PS: in the given code, I used two volumes with the same height and width to study the effect on the resulting shape.

Code for reproduction

import torchio as tio
import matplotlib.pyplot as plt

train_dir = "path" 
train_set = tio.datasets.RSNAMICCAI(train_dir, train=True)

# size of volume0 is (1, 512, 512, 400) and volume1 is (1, 512, 512, 129)

resample_transform = tio.Resample((train_set[1]['FLAIR'].spatial_shape, train_set[1]['FLAIR'].affine))
transformed = resample_transform(train_set[0]['FLAIR'])

# size after resampling is (1, 512, 512, 129) for both volumes as expected 

plt.figure("Before resampling")
plt.imshow(train_set[0]['FLAIR'].data[0, :, :, 200], aspect="auto")
plt.show()

plt.figure("After resampling")
plt.imshow(transformed.data[0, :, :, 65], aspect="auto")
plt.show()


# the slices are completely deformed

Actual outcome

the resampled slices are deformed

Error messages

No response

Expected outcome

I was expecting the the resampled volumes to have the same spatial structure but with lower resolution.

System info

No response

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
romainValacommented, Sep 7, 2022

I can not be sure, because I do not have the data, (strange, I just get the BraTS2021_Training_Data.tar with 1251 subject, but they are all at the same size, so I guess we do not have the same data …)

But from the dimension your first volume has 400 slices, you reslice it to 129 slices, so it makes sense that the z projection is changed … (but there is no deformation of the volume)

I advise you save the volume after resample (transformed.FLAIR.save(‘xx.nii’) ) and visualize it in a 3D viewer (itksnap, 3D slicer, fslview, mrview …) you will better understand what the resample do

0reactions
Ahmed93Sabercommented, Sep 8, 2022

I will try that. Thanks a lot for the support.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple Volume Considerations for Sequential Data Sets - IBM
Consider the following when working with multiple volumes: Your program is extending a sequential data set if it uses the EXTEND or OUTINX...
Read more >
MainframeSupport tip about Multi volume datasets
Using UNIT your dataset is allocated as a multi volume dataset. The neat thing is that a dataset can extent 16 times on...
Read more >
Volume Dataset - an overview | ScienceDirect Topics
This section discusses value-based encoding techniques for time-varying volume data. Topics in feature extraction are covered by other chapters of this book.
Read more >
Workspace: Visualising volume datasets - CSIRO Research
This way we are able to visualise the boundaries between different 'sections' in the dataset without having the clip the volume. Clipping is...
Read more >
How to Handle Large Volumes of Data in Power BI - BizAcuity
Decrease granularity/ Group by and summarize – Detailed datasets have several rows of data, with information that is at a granular level.
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