Comments (10)
I see the warning from the doc, but did not look at the code yet,
Actually I was looking for a sampler, that contains the center of the patch within the label. (it is a more conservative alternative to the current setting "at least one non background voxel")
The implementation just need to randomly sample (for the patch center) the coordinate of the label mask ... it should be fast ?
from torchio.
Yes I think that's the way to go. That's how NiftyNet works as well. I'll add a more generic weighted sampler. Then a label map can be used as sampler.
I need to think how to handle sampler images, though. That's why I also added a torchio.SAMPLER
attribute. I guess the easiest is to treat them as torchio.LABEL
and apply all spatial transforms using nearest neighbor interpolation. I'll try to work on this after the MICCAI deadline.
from torchio.
ok
it makes sens to indeed treat them as LABEL
from torchio.
Hi @fepegar, we will probably use the LabelSampler
soon so I was wondering if there were any news regarding this issue.
I thought we could use the same signature with an extra argument that would be a list of probabilities for the different values in the label with default as [1/n] * n
with n
the number of different values. Checks would be added to make sure the length of the given list is equal to n
and that probabilities sum to 1.
For the implementation itself, we could just draw a random number that decide which label value to focus on, then choose randomly a corresponding voxel from the label and return the patch centered on this voxel (with padding if needed).
Would that be enough or am I missing a deeper design choice that would lead to a different solution? In any case I would be happy to provide a PR if needed.
from torchio.
I'll take a look at this next week. Before I forget, this is related to #50.
I think we can follow NiftyNet's approach, i.e. using weighted samplers. Then a label sampler would be a specific case, where the label map can be used as a weight map. They can be tricky, this needs to be done carefully (NifTK/NiftyNet#432).
from torchio.
Hi @fepegar! Any update on this issue?
from torchio.
Sorry, I've been busy. I'll hopefully look into it on Friday.
from torchio.
No problem!
from torchio.
I just spent some hours on this. See #175.
from torchio.
Let me know if that implementation would work for you and I'll merge the changes ASAP.
from torchio.
Related Issues (20)
- Suggestions the modifying default value of prefetch_factor and the argument to set it for minimize the blocking-bottleneck between fetch subject and generate patch in Queue HOT 1
- Different transforms applied to CT and label HOT 11
- The Affine matrix does not change after applying the augmentations HOT 3
- Custom loader not used when loading data lazily HOT 2
- Seed is not working HOT 2
- Silenced exception makes it harder to debug custom Transforms HOT 5
- Resample
- tio.Resample does not work with custom image class HOT 2
- Setting NUM_SAMPLES when using sampler with Queue HOT 3
- RescaleIntensity - multiple calls HOT 9
- Return sampled parameters upon request HOT 3
- Halve queue length when using DDP HOT 2
- bug in rotation part of tio.transforms.RandomAffine HOT 4
- get_subjects_from_batch has a hick-up with int metadata HOT 5
- masking_method in Mask class is not saved as argument (preventing applying the inverse transform)
- RandomAffine raises an error when isotropic=True and 3 elements are given for scales HOT 10
- Queue is not respecting the batch size HOT 1
- Resample an image by providing only the target affine HOT 1
- Supporting PyTorch 2.3 HOT 11
- Cannot copy subclass of Subject with keyword arguments HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from torchio.