Replicating longitudinal fixel-based analysis approach

I was just wondering if there are any plans for updating fixelcfestats in the near future to enable longitudinal analysis??

I would have preferred to publish the relevant technical work before releasing; but I suspect the public pressure is going to get the better of me… :sweat_smile:


Hi all. Following on from this thread, I’m attempting to use a longitudinal tract of interest approach, so don’t need fixelcfestats.

However I do want to create a longitudinal population template as done in the Genc paper. I have 3 timepoints so 3 scans for each subject in the template. Could someone explain to me how to register to the midpoint of the 3 images?

Thanks very much,



I will share what I did to create an unbiased population template, but someone please correct me if I’m wrong!

First, you will need to create a population template for the 3 timepoints for each of your subjects separately. So each subject ends up with their own intra-subject “population template” for the 3 timepoints. Then, register the FODs of the 3 timepoints to the subject-specific population template for each subject as you would in the generic FBA pipeline. Finally, use the intra-subject registered FODs to create a popualtion template for all your subjects as you would in the FBA pipeline. And that’s it! (I think :sweat_smile:)


Hi Joe

Thanks very much for that. I’m still unsure about exactly how you make the intra-subject template from the 3 timepoints. I’m told this needs to be registered to the midpoint of the 3 images but not sure how you work up the midpoint and how that works in practice. I can see that population_template has a -rigid option for the purpose of creating a longitudinal template but not sure how to implement that to make the intra-subject template.

Could you let me know in more detail how you have done the intra-subject template in terms of commands used ect? Sorry for being a bit simple! :smile:




I see what you mean. What I did is use mrregister for midway rigid registration, using the -transformed_midway option. So something like this:

mrregister -type rigid TP1.mif TP2.mif -transformed_midway TP1_midway.mif TP2_midway.mif

Where TP=timepoint.

Not sure how you would do that for 3 time points, though. Maybe someone with more experience can chime in?

This gives you the average image (intensity or FODs) of the rigidly aligned images. Registration is performed iteratively in a pairwise manner between each subject image and the current best estimate of the template. After each stage, the template is updated with the average of the rigidly transformed images (see diagram here). This is what happens behind the scenes in population_template, nothing you need to worry about.

The template is the unweighted average intensity of all images (time points) mapped to the common space via subject to template transformations. In your case, the template works as mid-point so you’d transform each image to the subject-specific template space. You can use population_tempalte with rigid, affine or nonlinear registration to create this central reference space.

Note that there are other registration approaches to align multiple images to a common central point (based on (pairwise) distances in deformation space for instance) but not within MRtrix. For more information on the topic see for instance The optimal template effect in hippocampus studies of diseased populations, Avants et al.. If you wanted to adjust the “centre” point of the subject-specific template, you’d need to get your hands dirty as the MRtrix tools were not designed for this. I guess the easiest would be to adjust population_template to perform a weighted intensity average based on temporal distance from the target time point. This would bias the template’s representation towards the target time point’s representation and therefore nudge registration towards that time point’s shape as well. It is probably not the best™ approach from a theoretical point of view but I’d guess it would work reasonably well in the absence of large deformations between time-steps.

Thanks Joe and Max for your really helpful comments. I just wanted to clarify a couple of things.

  1. Max - would you suggest then, that that I perform population_template with the rigid option to create an intrasubject template? Presumably I shouldn’t need an affine or non-linear registration options for this step? Or would you use those options if the rigid registration doesn’t look quite right? And then after you have done this for each subject to be included in your template, you then put the intrasubject image through population_template to create your final group template?

  2. Is there another way that would be felt by genera consensus to be better? As per Joe’s previous comment, can someone commment on whether it’s possible to use mrregister -transformed_midway option when you have 3 timepoints? And if so, would this be any different than the previous option, or would they both be, in effect, midpoint/common central point registrations?



Yes, I’d at least check if affine or nonlinear registration produces sharper intra-subject templates. Nonlinear misalignment between repeat scans might or might not be an issue, depending on your scanner parameters and hardware, processing pipeline, subject position, and physiological factors.

mrregister aligns two images, there is no option to simultaneously coregister a third image. Therefore -transformed_midway is always relative to a specific image pair. You could register all three images in a pairwise fashion and transform both images in each pair to their midway space and average all 6 resulting images. For large deformations (depending on deformation distance metric and space), this approach might not be optimal but given that you consider rigid registration, should yield similar results as alignment to the average image via population_template.

1 Like

Thanks Max.

I thought about using mrregister to use midway space registration, only because that seems to be the common approach used in previous fixel longitudinal analysis / TBSS / VBM ect, and so I figured reviewers might take less issue with it as it is more commonplace.

So as you suggested I have used mrregister -type rigid -mask1 -mask2 image1 image2 -transformed_midaway image1_midway image_2midway for each pair to create 6 midway images. However after this, I notice that the midway file dimensions slightly change - e.g. all 3 images inputted are 169 x 169 x115 x45 with voxel size of 1.3 x 1.3 x 1.3 x 1. Where as resulting midway images are e.g. 170 x 173 x 120 x45 with voxel size of 1.36026 x 1.33205 x 1.33474 x 1 in one case and 171 x 172 x 121 x 45 and voxel sizes of 1.35452 ect ect for another resultant image.

So I’m unsure why this is, an how to average the 6 images with slightly differing voxel sizes/dimensions? Also wasn’t sure which command to use to perform this average - was that mraverageheader or another command?

Also when you mention about large deformations, as a ballpark, what parameters would you consider large?

Thanks very much for your ongoing help with this,


Hi Max,

What would be an appropriate method for creating the FOD templates, when there is a large deformation between time points e.g. in my case that I’m looking at infants images at different time points? (the range is about from birth to 6 months).

Thank you,

As far as I know, the midway transformation has only been used for the alignment of paired images, population_template has been used in a number of group-wise peer-reviewed publications. Pairwise registration can introduce problems and might be inferior to groupwise approaches. See for instance here. Assuming pairwise registration works equally well as image-to-template registration, best case you’d get equivalent behaviour between population_template and the pairwise approach. As I hinted at in the last message, if your deformation manifold was nonlinear, you get a suboptimal template using the pairwise approach. The mental picture of 3 people on a hill might help: Assuming one can only walk on the surface of the hill, the average of the pairwise midpoints between people lies inside the hill. The flatter the surface (linear manifold) or the closer the people, the better the approximation of the centre. This problem arises because we average transformed images instead of computing the average transformation on the diffeomorphic manifold which is not possible within MRtrix3.

If you still want to go for pairwise registration (which I would advise against if you could not tell…):

  1. Compute the average space of all non-transformed (translated is fine if their centres are too far off) images. Here is where you decide on the desired target resolution.
  2. Register each image pair, save the full warps.
  3. For each warp:
    1. Convert the full warp to two midway warps using warpconvert -midway -from <image>.
    2. Regrid the midway warps to average space using mrtransform -template average_space.mif
  4. For each image: Warp towards the two other images using the regridded midway warps
  5. Average warped images using mrmath

Hi Max,

Do you know whether that method in here is applicable to FOD images? My understanding is that dealing with FOD images is different from intensity images as FOD involves direction information too.
Please advise.


Yes, FOD registration requires reorientation and the method is not implemented in MRtrix3. population_template works differently, see for instance above. As already written in a previous personal message 7 days ago, you’d need to use population_template.

Again, population_template, see my PM.

1 Like

Hi Max

Thanks again for those useful comments.

Just to check I have understood this correctly - Use population_template to create an intra-subject template first and then feed that intra-subject template with it’s template mask and 39 other intra-subject templates to form my group template.

Then, in order to register each individual scan to the final group template - how would that work? Is it the same as the generic FBA pipeline using mrregister for the individual scan to the group template? For those subjects used in building the group template, would you need to register each scan to their own intra-subject template before registering to the group template?

Thanks again,


I don’t have more information over what’s stated in the paper:

Both statements are correct, as far as I understand the above paragraph.

If you mean to transform the subject to its intra-subject template before registration with the population template, no, that would cause two interpolations. I doubt it is necessary to initialise the registration so simply register the original images to the population template. (mrregister has an option to initialise the nonlinear registration with a 5D warp but since you have two registration steps - subject to intra-subject template and intra-subject template to population template - you’d need to compose those, which is not trivial due to the warps being defined in their midway spaces.)

1 Like


I have a very small (and probably relatively basic) follow-up question. I managed to create an unbiased population template for my cohort as described in Genc et al., 2018, but of course there’s still the issue of lack of CFE support for longitudinal analysis. So, I have a simple idea to analyze my longitudinal data, and just wanted to check if it’s statistically sound.

My study has 2 groups (patients and controls) and 2 timepoints, and I’m trying to see if the patient group exhibited a higher degree of degenerative progression between the 2 timepoints compared to the healthy controls. Would it make sense (statistically), to calculate the difference in FBA values between the 2 timepoints for each group, and then use CFE to perform an independent sample t-test to compare the change of FBA measures over time between the 2 groups? I hope that made sense :sweat_smile:

Any input would be appreciated.Thanks!


… there’s still the issue of lack of CFE support for longitudinal analysis …

If you’re willing to do some Git branch jumping, the relevant code is now in the public domain.

Would it make sense (statistically), to calculate the difference in FBA values between the 2 timepoints for each group, and then use CFE to perform an independent sample t-test to compare the change of FBA measures over time between the 2 groups?

This is a GLM / error modelling question rather than a CFE question. I think that in your case the model errors would be both independent and symmetric (enabling random negation of model residuals) and exchangeable (enabling permutation of model residuals), following which the contrast matrix would be responsible for testing the hypothesis that the difference between the two regression coefficients corresponding to the group longitudinal changes is non-zero. If you were to run these data using the current MRtrix3 code, where errors are assumed to be exchangeable only, you would certainly get something, in that the code would run and you’d get output images; what I’m unsure about is whether or not the incomplete modelling of the model errors would bias the null distribution.

That’s good to know, thanks :grinning:

I already analyzed my data using the approach I explained in my previous post, and I actually ended up getting the results I expected to get, but of course that doesn’t mean that the GLM modelling was unbiased. Is there anyway to check whether the GLM model worked properly or not? I’m really in over my head with all the GLM stuff, so any help would be highly appreciated :sweat_smile:


If you’re willing to do some Git branch jumping, the relevant code is now in the public domain .

I think I managed to merge the updated branch with my local MRtrix3 repository. Thank you for that.

Just a small follow-up question, how can I choose to use sign-flipping instead of permutation testing in fixelcfestats? Is there an option for that? I couldn’t find anything about it in the documentation.

Thanks again for the help!


Is there anyway to check whether the GLM model worked properly or not?

It’s not a matter of whether or not it “worked properly”; that’s the danger with the GLM, it’ll usually do something, but whether or not that something is “proper” is up to the researcher, not the software.

My intuition says:

  • You’d simply not be exploiting all possible mechanisms for shuffling, and therefore wouldn’t be able to generate as many unique shuffles as you would otherwise, but in most scenarios we don’t process anywhere near the maximum possible number of unique shuffles anyway.

  • If there were to be any bias in the null distribution arising from the incomplete error modelling, it’s probably smaller in magnitude than the biases that result from using the Shuffle-X method in the presence of nuisance regressors (assuming you have any).

Depends on the extent to which you’re willing to bet the integrity of your research on a stranger from the internet :sweat_smile: I won’t be offended if you seek clarification from someone with more GLM experience than myself.

I think I managed to merge the updated branch with my local MRtrix3 repository. Thank you for that.

Just beware that the difference between that branch, and what you were using previously, may not be restricted to only the statistical inference commands: stats_enhancements is based on dev, which includes myriad changes not yet merged to master.

Just a small follow-up question, how can I choose to use sign-flipping instead of permutation testing in fixelcfestats ? Is there an option for that? I couldn’t find anything about it in the documentation.

You won’t find it in the online documentation, because that’s generated automatically from the code, and the code used to generate the documentation doesn’t have this capability. If you check the command’s help page by running the command without any arguments, or use the -help option, that’s the documentation that’s relevant for the particular version of the software you have compiled and are running. Here you’re specifically looking for the -errors option.


1 Like