Comments (10)
I think the code logic is correct, but maybe the docs and the error message are not clear. The idea is that a single scale value for all dimensions is sampled if isotropic
is True
. The number of scales must be one or two because if it's one (let's call it
Does that make sense?
from torchio.
I have the same issue.
from torchio.
Hello
I aggree it seems a bug to fix, but the work-around seems quite easy
either set the scale with 3 number, but put isotropic to False
or just set cale with 1 number (since you want it to be isotropic). In this case you do not even need to set the "isotropic" argument (default False will also be fine). (should work exactly the same with issotropic set to True)
May be I miss something, (@fepegar ?) but my understanding is that "isotropic" argument is not usefull
from torchio.
Hi and thanks for your response. I agree that there are workarounds for this bug, but I believe it's better to fix it. I fixed it in this pull request using a single line of code #1159
from torchio.
hmm, the logic I do not understand is when is the isotropic
argument necessary ? My understanding is that isotropic
is implicit when you specify parameter of length 1 or 2
taff1 = tio.RandomAffine(scales=0.2)
taff2 = tio.RandomAffine(scales=(0.8, 1.5))
print(f'Scale is {taff1.scales} isotropic is {taff1.isotropic} ')
print(f'Scale is {taff2.scales} isotropic is {taff2.isotropic} ')
Scale is (0.8, 1.2, 0.8, 1.2, 0.8, 1.2) isotropic is False
Scale is (0.8, 1.5, 0.8, 1.5, 0.8, 1.5) isotropic is False
from torchio.
Thanks @fepegar, it makes sense to me now. I have modified the error message and the documentation to make it more clear. Please find them in this #1163.
@romainVala Based on this code in spatial.radom_affine.RandomAffien.get_params
:
scaling_params = self.sample_uniform_sextet(scales)
if isotropic:
scaling_params.fill_(scaling_params[0])
If "isotropic" is True, then the scaling factor of all other dimensions is filled with the first scaling factor, so when "scales" only has 1 or 2 values and "isotropic" is set as True, we make sure that all dimensions will be scaled with the same factor. In your example, the values of scales are lower and upper bounds of random sampling, not the actual values of scaling in the transformation.
from torchio.
not sure to understand properly ...
scale input parameter for RandomAffine
is to specify the lower and upper bound ... in order to do a random selection.
If you want to force RandomAffine
to get a specific value (for instance 0.8), then you need to restrict the bound to (0.8, 0.8) ... or may be, since you do not want randomness, then directly go with the Affine
transform
I agree with the code snipet you show, but my example demonstrate that this line of code is not needed.
from torchio.
@romainVala Imagine that we have set the bounds as (1,3), then the scales will be randomly selected as (1.3, 1.5, 2.8). If "isotropic" is True, then we force the scales to be (1.3, 1.3, 1.3). The scaling factor is chosen randomly but as isotropic is True, it will be same for all dimensions.
from torchio.
@AminAlam, that's the intended behavior indeed.
from torchio.
Ok, my bad
I was too focus on the extension of input parameter, But you are right
isotropic is for enforcing the chosen random values to be isotropic
sorry for my confusions
from torchio.
Related Issues (20)
- 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)
- 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 17
- Cannot copy subclass of Subject with keyword arguments HOT 2
- Image intensity augmentations 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.