-
-
Notifications
You must be signed in to change notification settings - Fork 381
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Control low-spatial-frequency and high-amplitude deformations for nonlinear transformateions #734
Comments
Suggestions
I have never had any issues with the default SyN parameters with Rats or Mice. |
also - if you want to increase regularization, set the
totalFieldVarianceInVoxelSpace > 0
the 1e-8 step sizes you are using are ... unusual. more like 0.1 - this
is in voxel space.
you may need to do brain extraction in new subjects. but maybe i am
misinterpreting the pictures.
sharing problematic data always helps.
…On Wed, Mar 13, 2019 at 9:40 AM Gabriel A. Devenyi ***@***.***> wrote:
Suggestions
- Fix your bias field with N4 first
- Do a fully dense Rigid/Similarity/Affine before SyN with more blur
levels
- Really, use CC.
- Don't winsorize your histogram
I have never had any issues with the default SyN parameters with Rats or
Mice.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#734 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AATyfuPhJowq0qetyL-5gJEPgZaYKrCwks5vWP-9gaJpZM4bs5dE>
.
|
thank you for your speedy replies :)
@stnava sorry for omitting that, please find a self-contained reproducible example here, there is an iteration step since the bad file doesn't always fail, but the good file always doesn't. Thanks for clarifying the unit for the SyN step sizes, that had been unclear to me. Sadly, increasing the |
I think you meant to have a different link or an attachment that's missing. I don't see a runnable example with data. |
@gdevenyi oops, yes, that was an empty link, please check again now. |
Okay, I see what's going on. antsRegistration has some quirks with non-isotropic voxels. Whenever I'm solving a registration problem, I always upsample my fixed image to the highest res voxel in isotropic spacing. If you do this:
And use resample.nii.gz as your fixed image, all the regular antsRegistration suggestions work as expected. |
@gdevenyi interesting... but if you look at the headers, the images have the exact same level of anisotropy, so it really can't be just that, right? Also, while completely removing the winsorization breaks the process, reducing the extent to which it is done has significantly improved the results, though I would again be very interested in further suggestions. |
Another comment regarding choice of atlas, your atlas is "extracted" while your moving image isn't. This in general causes pain because you have edges in one image while there's no edge in the other. |
Masking could fix this, but your mask is too generous so the edge is included in the registration. |
@gdevenyi yes, I have noticed that the main difference between the atlas that always works and the one which occasionally doesn't it the black rim. But I had thought the moving image would just be contracted into the non-black space (and this also happens e.g. with the “good” moving image I sent you). Any idea what causes this intance and how it might be combated without addding a resampling node to the preprocessing or recreating the template? |
@gdevenyi ok, so going back to your suggestion, I assume instead of
you meant
since the atlas is already isotropic. So I tried that and if anything it worsened the results, so I don't think it's the source of the problem or a good workaround. |
Hrm, I didn't realize the atlas was isotropic. So, I rephrase the problem. The atlas resolution is lower than some/all of the moving image dimensions. So the first thing ants does is throw away useful data since the fixed image determines the space the work is done. Upsampling the atlas fixes this. |
Yes. This is correct.
On Wed, Mar 13, 2019 at 7:52 PM Gabriel A. Devenyi ***@***.***> wrote:
Hrm, I didn't realize the atlas was isotropic.
So, I rephrase the problem. The atlas resolution is lower than some/all of
the moving image dimensions. So the first thing ants does is throw away
useful data since the fixed image determines the space the work is done.
Upsampling the atlas fixes this.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#734 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AATyfvf07BnOyA1Eu6tD401Dx0NRk2Sxks5vWY8_gaJpZM4bs5dE>
.
--
brian
|
@gdevenyi -- I would just rephrase a couple things:
We would prefer that people reading this forum not come away thinking that ANTs is somehow uniquely deficient with respect to these issues. |
Absolutely agree @ntustison , much better phrasing. |
yes - it is more of an understanding issue on the part of the user. ants
gives users a lot of freedom - and therefore increases the burden of
understanding the underlying concepts.
brian
…On Wed, Mar 13, 2019 at 8:07 PM Gabriel A. Devenyi ***@***.***> wrote:
Absolutely agree @ntustison <https://github.com/ntustison> , much better
phasing.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#734 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AATyfoqJ0-kH2XQ093sl5glI5WMR92FBks5vWZLWgaJpZM4bs5dE>
.
|
some, yes, the template is 0.2x0.2x0.2 whereas the structural scan is 0.167x0.075x0.65, the issue however, is that I am using the structural scan as an intermediary to register functional data (which is 0.312x0.281x0.65). Ideally I would not want to oversample the structural data too much due to both multiple comparison and memory concerns. Still, I don't see how this would be the specific issue here, since over 50 other scans at the same resolution reliably register correctly, and it is only 2-3 where SyN introduces this strange roll/scale effect (which looks much more like some affine transformation). Barring a change in the resolution of the target space, what else could I try? I basically just want to tell it to not make this kind of low spatial frequency high amplitude roll/scale. Mouse brains are much simpler than human brains, and I can reliably say that if the algorithm is moving 30% of the image more than 20 voxels away, its definitely wrong. |
you have all the answers you need from prior discussion. these are
non-trivial insights, so perhaps think through what they mean.
you are the only one who knows your data, its problems, etc. we are more
or less giving general insights based on knowledge
gained from data that is different from yours.
the resolution of a statistical study is not dependent on the resolution of
the transformation.
you can resample fmri derived data to whatever template resolution you
prefer for final analysis.
…On Wed, Mar 13, 2019 at 8:25 PM Horea Christian ***@***.***> wrote:
The atlas resolution is lower than some/all of the moving image dimensions.
some, yes, the template is 0.2x0.2x0.2 whereas the structural scan is
0.167x0.075x0.65, the issue however, is that I am using the structural scan
as an intermediary to register functional data (which is 0.312x0.281x0.65).
Ideally I would not want to oversample the structural data too much due to
both multiple comparison and memory concerns.
Still, I don't see how this would be the specific issue here, since over
50 other scans at the same resolution reliably register correctly, and it
is only 2-3 where SyN introduces this strange roll/scale effect (which
looks much more like some affine transformation).
Barring a change in the resolution of the target space, what else could I
try? I basically just want to tell it to not make this kind of low spatial
frequency high amplitude roll/scale. Mouse brains are much simpler than
human brains, and I can reliably say that if the algorithm is moving half
the image more than 20 voxels away, its definitely wrong.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#734 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AATyfqr3cRgmBBKvmf06R06dpcZw89rRks5vWZcUgaJpZM4bs5dE>
.
|
sorry, I didn't intend to overwhelm you with specific details about the data, I just wanted to clarify the details surrounding the topic of resolution which came up. At any rate, the process at hand is very simple, I want to make slight (which I can also define in precise voxel/length units) transformations to an ellipsoid to make it fit into another. I assume this functionality is available in ANTs. The answers I have gotten were:
Is there no ANTs parameter which reliably controls the amplitude of nonlinear transformations? |
totalFieldVarianceInVoxelSpace will do it. your statement that it "will
not work" is wrong.
brian
…On Thu, Mar 14, 2019 at 9:07 AM Horea Christian ***@***.***> wrote:
sorry, I didn't intend to overwhelm you with specific details about the
data, I just wanted to clarify the details surrounding the topic of
resolution which came up.
At any rate, the process at hand is very simple, I want to make *slight*
(which I can also define in precise voxel/length units) transformations to
an ellipsoid to make it fit into another. I assume this functionality is
available in ANTs. The answers I have gotten were:
- Reduce the extent to which the image is winsorized, which helped
(thanks @gdevenyi <https://github.com/gdevenyi>) but did not fully fix
the issue.
- Enlarge totalFieldVarianceInVoxelSpace, which will not work with the
example I have compiled for you
<http://chymera.eu/debug/ANTs/regularization.tar.xz>.
- Change the template/mask, which is infeasible.
Is there no ANTs parameter which reliably controls the amplitude of
nonlinear transformations?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#734 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AATyfkHT2WT5-RrO9Z5htO6xKv7ntnyzks5vWkmggaJpZM4bs5dE>
.
|
Yes, as Brian mentioned, the total field variance constrains the deformation. It might not be the magic parameter which fixes your single example but that is the ANTs parameter in question. Another alternative to try is the BSplineSyN transform which, I find, tends to produce a more elastic- type solution. |
While you're focusing on the SyN part of the registration it is my contention that this is a sign of a failure of the affine stage before it. Here's my generic registration script for a affine+SyN registration, with its solutions to your good and bad images, using the upsampling. Without upsampling, the affine fails badly for this script, pointing to that being the source of your problems. I suggest you QC your affine registrations as I do, by saving out an affine transformed image so you can see if your affine worked. |
yes - it is generally the case that when you see "odd deformations", it is
due to a failed rigid or affine mapping.
brian
…On Thu, Mar 14, 2019 at 10:19 AM Gabriel A. Devenyi < ***@***.***> wrote:
[image: image]
<https://user-images.githubusercontent.com/3001850/54364121-a3b75e00-4642-11e9-9681-6750bcc2f9d3.png>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#734 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AATyfq9qTazpq7veAyABoVrwiq76tjuuks5vWlpugaJpZM4bs5dE>
.
|
@gdevenyi thanks for giving this a shot! Could you explain what I should be noticing in the image which you posted? It seems to me like all cases work out without showcasing my initial issue. I have also downloaded and looked at your archive, and I cannot find anything to suggest the following:
Looking at On a tangential note: I have also mentioned above that the error looks more affine-like than SyN-like to me, but I had done QC, and figured out that up until the SyN phase good/bad images tended to be equally well registered. |
The domain of the fixed image defines the domain of the virtual space the computation is performed. So changing the spacing of the fixed image changes the interpretation of several It makes sense that resampling the atlas would change results, though it might be possible to arrive at the same results by adjusting other parameters. I managed to get reasonable results with
As has been suggested above I did not use histogram matching or winsorization. I would be especially careful doing anything to the intensities if using mean squares metric, as the example script does. The other big variable, particularly if using different atlases, is going to be the initialization. If the geometric centers of the images align poorly, you might get a bad initial alignment. |
I am having this issue (unsure if it is a bug, a missing feature, missing documentation, or inaccessibility of documentation) whereby the nonlinear transformation phase of an
antsRegistration
call ends up severely warping my image.In most cases the transformation looks acceptable:
But in some it does not:
Interestingly this seems to only happen with specific moving images (I have been unable to determine the common denominator) and specific fixed images (e.g. the first but not the second one of our templates):
I assume this has to do with the black border, but I was unable to test, because at this point the templates are pretty much “given”.
In my quest to resolve this I have manually iterated through countless parameter variations based on the instructions here, here and on incremental empirical evidence. It has boiled down to this:
I use MI here to have the operation performed more rapidly. Adding CC+MI improves the results but does not sort out the issue completely. At any rate, this kind-of works, but not really. Please note that the issue is with the SyN phase alone, everything else works great.
More generally I have observed that:
histogram_matching=False
is betterI can't really observe a reliable impact of editing the syn parameters, however. Past work indicates that since I work with mouse brains (having a much smaller scale than human brains, about 1:10 length units), I should reduce the first parameter by a factor of 10, but even reducing it by a factor of 10^8 seems to have done little to address the issue.
The text was updated successfully, but these errors were encountered: