Code Monkey home page Code Monkey logo

Comments (5)

Zhack47 avatar Zhack47 commented on June 21, 2024 1

Thanks!
I completely agree with this solution
I am going to make a PR to fix this !

from torchio.

fepegar avatar fepegar commented on June 21, 2024

Hi, @Zhack47. Can you please share a minimal example I can reproduce?

from torchio.

Zhack47 avatar Zhack47 commented on June 21, 2024

This is more minimal and should trigger the bug (tested on the same machine as above)

import numpy as np
import torch
from torch.utils.data import DataLoader
from torchio.data.sampler.label import LabelSampler
from torchio import DATA, TYPE, LABEL, INTENSITY, IntensityTransform

class SimulateLowResolutionTransform(IntensityTransform):
    def __init__(self):
        super().__init__(1)

    def apply_transform(self, subject):
        keys = sorted(subject.keys())
        for key in keys:
                subject[key][DATA] = subject[key][DATA].unsqueeze(0)
        return subject

if __name__ == "__main__":
    import torchio as tio
    st = SimulateLowResolutionTransform()
    colin_dataset = tio.datasets.mni.Colin27()
    ds_train = tio.SubjectsDataset([colin_dataset], transform=st)
    sampler = LabelSampler((120, 120, 80))
    patches_queue_train = tio.Queue(ds_train, max_length=32, samples_per_volume=4, sampler=sampler,
                                    shuffle_patches=True, shuffle_subjects=True, num_workers=8)

    training_loader = DataLoader(patches_queue_train, batch_size=2, shuffle=True)
    for batch in training_loader:
        print(batch["t1"][DATA].shape)

from torchio.

fepegar avatar fepegar commented on June 21, 2024

Thanks, @Zhack47. Good catch!
I think adding raise exception after line 330 would do. Do you agree?
Would you like to contribute with a PR?

from torchio.

fepegar avatar fepegar commented on June 21, 2024

Fixed in v0.19.1.

from torchio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.