Skip to content

population_template initialisation and drift correction fixes#2471

Merged
jdtournier merged 2 commits intodevfrom
population_template_space_init_drift_fix
Nov 15, 2022
Merged

population_template initialisation and drift correction fixes#2471
jdtournier merged 2 commits intodevfrom
population_template_space_init_drift_fix

Conversation

@maxpietsch
Copy link
Member

  1. proposed fix to population_template: bogus average space #2467
  2. also fixes that the intialisation was not used in the first registration level
  3. while at it, also added the option to delete intermediate templates which could be handy if many levels are requested and storage space in scratch is limited

For context regarding 1.:

The initial template space is computed after the initial trafos R_i (default: translations to centre of mass) are applied to the input images.
The drift correction is supposed to prevent changes in appearance to the template over template levels and used the average transformation A = E [T_i ] across the image trafos T_i which include the initialisation. Hence for large "outliers" in the initialisation (i.e. one subject is far form the others in scanner space), the initial drift correction moves the template content out of the template FOV (as reported in #2467). The proposed fix computes E [R_i ] and corrects drift via T_i <- T_i E [R_i ] (E [T_i ])^{-1}. This approximately preserves the size and shape of the image relative to the (average) original input images. Suggestions on how to improve drift correction are very welcome.

BTW, on my test data (neonatal FA maps), deactivating drift correction via -linear_no_drift_correction leads to visible distortion in the affine levels that increase with the number of levels iterations. It's also worth thinking about implementing some form of (approximate) average shape preservation for the nonlinear registration.

This PR alters the behaviour and output of population_template for all types or registration except for nonlinear so we'd need to tag it. Test data needs to be updated as well. Should this go to master?

- use it in first registration level
- fix stabilisation #2467
- also added option to delete intermediate templates if storage space in
  scratch is an issue
@maxpietsch maxpietsch added the bug label Apr 28, 2022
@maxpietsch maxpietsch linked an issue Apr 28, 2022 that may be closed by this pull request
@Lestropie
Copy link
Member

Should this go to master?

Given #2467 states that use of an existing command-line option resolves the issue for problematic data, I would tend to think no? But I don't have a sense of the prevalence or magnitude of the problem to make a confident call.

@maxpietsch
Copy link
Member Author

Given #2467 states that use of an existing command-line option resolves the issue for problematic data

Don't think there is a way to fix it via command-line options, setting average_inv = None is done by patching the code. Currently, for certain data, population_template produces cropped templates. So it's a bugfix but it also affects outputs for other data, hence a new tag is required.

@jdtournier
Copy link
Member

Given the discussion above, I reckon this needs to merge to dev with a view to releasing as part of 3.1.0. I've amended the PR to merge to dev, and tagged for the 3.1.0 milestone. Hope everyone is OK with that...

@jdtournier jdtournier changed the base branch from master to dev November 10, 2022 16:07
@jdtournier jdtournier changed the base branch from dev to master November 10, 2022 16:07
@jdtournier jdtournier requested a review from a team November 10, 2022 16:08
@jdtournier jdtournier added this to the 3.1.0 updates milestone Nov 10, 2022
@Lestropie
Copy link
Member

I've amended the PR to merge to dev ...

... and then changed it back to master?

@jdtournier
Copy link
Member

jdtournier commented Nov 14, 2022

oops, sorry - turns out changing the base to dev isn't as simple as anticipated, and introduces a lot of merge conflicts. I was in the middle of doing that offline when I got sidetracked. I'll try to fix that up now...

@jdtournier jdtournier changed the base branch from master to dev November 14, 2022 17:34
@jdtournier jdtournier merged commit 84e11a4 into dev Nov 15, 2022
@jdtournier jdtournier deleted the population_template_space_init_drift_fix branch November 15, 2022 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

population_template: bogus average space

3 participants