Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

change default pading for RandomAffine to minimum #344

Closed
romainVala opened this issue Nov 3, 2020 · 10 comments
Closed

change default pading for RandomAffine to minimum #344

romainVala opened this issue Nov 3, 2020 · 10 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@romainVala
Copy link
Contributor

馃殌 Feature
I notice that by default you choose the minimum as default_pad_value for elastic deformation
whereas the default method is otsu for randomAffine

Motivation
it seems to me more natural to take the min, as noise is expected in the image border (at least for brain, in 5 of the 6 border slices )
no ?
and it makes more sense to have the same default for both transform

Pitch
by the way we should may be add a default_pad_value as argument in the randomElastic too (but minimum is fine, so may be latter ...)

Alternatives

Additional context

@romainVala romainVala added the enhancement New feature or request label Nov 3, 2020
@fepegar
Copy link
Owner

fepegar commented Nov 4, 2020

it seems to me more natural to take the min, as noise is expected in the image border (at least for brain, in 5 of the 6 border slices )

Sometimes the minimum is very different from the border, so it creates a gradient. I feel like using the Otsu threshold of the values at the border is the most robust option. But I can't think of an obvious counterexample at the moment...

and it makes more sense to have the same default for both transform

Yes! I added the padding stuff to RandomAffine as an experiment, but it should also be added to Resample and RandomElasticInformation. Actually, it would be nice to merge these 3 one day.

@romainVala
Copy link
Contributor Author

adding the mean value (of the otsu mask) will also add gradient in the image borders
may be padding stuff is a proper solution (I did not know it was possible, does it allow to choose 'reflect' ? )

When talking of the same default I was thinking of changing RandomAffine default default_pad_value, which is now 'otsu' whereas it is 'minimum' in RadomElasticInformation (without the possibility to change it)

Not sure what you have in mind for merging those 3 transforms, but a first step would be to homogenize them, by adding the default_pad_value and the padding stuff if possible (with the same default)

@fepegar
Copy link
Owner

fepegar commented Nov 5, 2020

adding the mean value (of the otsu mask) will also add gradient in the image borders

I guess.

may be padding stuff is a proper solution (I did not know it was possible, does it allow to choose 'reflect' ? )

Hmm you can always use Pad with any mode you want, then apply the affine and then Crop.

When talking of the same default I was thinking of changing RandomAffine default default_pad_value, which is now 'otsu' whereas it is 'minimum' in RadomElasticInformation (without the possibility to change it)
Not sure what you have in mind for merging those 3 transforms, but a first step would be to homogenize them, by adding the default_pad_value and the padding stuff if possible (with the same default)

I agree, this needs to be changed. The idea of merging is avoiding loss of information due to multiple interpolations.

@romainVala
Copy link
Contributor Author

Yes! I added the padding stuff to RandomAffine as an experiment

then I do not understand what you add ?

@fepegar
Copy link
Owner

fepegar commented Nov 5, 2020

Maybe "padding" (used by e.g. NiftyReg) is not the right nomenclature. I meant that I added logic to compute the "default pixel value" (used by ITK) when no information is available for that voxel during resampling. Does that make sense?

@romainVala
Copy link
Contributor Author

sorry, but not sure to follow

when no information is available for that voxel during resampling.

this is already handel (in RandomAfinne)

        default_pad_value: As the image is rotated, some values near the
            borders will be undefined.
            If ``'minimum'``, the fill value will be the image minimum.
            If ``'mean'``, the fill value is the mean of the border values.
            If ``'otsu'``, the fill value is the mean of the values at the

do you mean you add other logic than minimum, mean otsu, or constant value ?, which logic then ?

@fepegar
Copy link
Owner

fepegar commented Nov 5, 2020

I don't know what the question is anymore haha.

When you apply e.g. a rotation to an image, you need to pad the result with some values. For example, in this image, the value is 0:

The minimum could have been chosen instead, or some other value.

That's all. I'm not proposing any new technique to compute the padding value. I agree the method should be the same for RandomAffine, RandomElasticDeformation and Resample.

@fepegar fepegar added good first issue Good for newcomers help wanted Extra attention is needed labels Nov 5, 2020
@romainVala
Copy link
Contributor Author

romainVala commented Nov 5, 2020

Yes! I added the padding stuff to RandomAffine as an experiment,

it is just this sentence I did not understand (since it is already there, in random Affine), but ok, no matter, I think we do agree (and it is not a very important point)

@fepegar
Copy link
Owner

fepegar commented Nov 5, 2020

I meant that back then I added that to RandomAffine and forgot to add it to the other transforms as well.

@fepegar
Copy link
Owner

fepegar commented Dec 4, 2020

Closing as this was fixed in #353. Next step should be adding padding options to Resample and RandomElasticDeformation.

@fepegar fepegar closed this as completed Dec 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants