Skip to content

Conversation

@mattcieslak
Copy link
Contributor

Hi Frank,

I've been trying to match the Chen AutoTrack behavior in the current DSI Studio codebase. It's probably not going to be possible to share the testing data, so I tried to add back in some Chen methods. I did this in two stages. First I edited the options to match Chen: PennLINC#1 when --chen_mode=1. Then I changed how spatial normalization is run: PennLINC#2.

I can confirm that these changes compile without any issue and that the tractography looks better most of the time.

That being said, I'm not sure if all these changes actually make sense technically and would be happy to refactor to better fit your vision for DSI Studio. Could you please take a look and see if there's anything you would advise against including? I've got a nice test setup to try out any suggestions.

Thanks as ever!

@frankyeh
Copy link
Owner

frankyeh commented Jan 21, 2026 via email

@frankyeh
Copy link
Owner

I reviewed the code, and a large portion of it is the registration, but the Hou registration usually works better and handle large FOV which is very common in many DTI.

Could you try using Hou reg + Chen mode and see if this gives similar results as previous Chen?

@mattcieslak
Copy link
Contributor Author

On it! just to be sure - the Hou registration will work ok with the low anisotropy of the infant brains? Is the same amount of deformation possible in Hou and Chen? I got the impression that Chen was aiming for simpler deformations.

Also, I don't think there is a benefit to keeping the map.gz format if it's deprecated in favor of .mz. I can remove map.gz support

@frankyeh
Copy link
Owner

frankyeh commented Jan 22, 2026 via email

@mattcieslak
Copy link
Contributor Author

You're right - the Hou registration is excellent, even in the tiny, low anisotropy brains. I've been checking this by saving the template bundles in native subject space and checking their overlap in the dsi studio gui. I removed the Chen code/options for registration from this PR and will follow up over email to debug the tractography parameters

@frankyeh
Copy link
Owner

Follow-up on the auto-tracking part:

  1. thread.param.min_length and thread.param.max_length are identical between Hou and Chen. In Hou, the routine is implemented as a class method, so we don’t need to expand it for Chen mode.

  2. The Chen code that selects tract ID and tract name did not support the hierarchical atlas. The selection also does not affect fiber tracking. Therefore, we should use the Hou implementation here.

  3. The default track_voxel_ratio is the same in Hou and Chen, so there’s no need to modify it.

  4. The “check ending” logic differs only for "Cingulum." I would consider use the Chen setting even in Hou.

At this point, the remaining differences that matter are:
a) tip_iteration, and
b) use_roi.

use_roi=1 adds a ROA and an ROI to help terminate tracking earlier when streamlines deviate far from the intended target. It should produce consistent results and likely won’t change outcomes much, so we can probably keep the Hou version.

That leaves tip_iteration as the main remaining difference. A value of 32 may be too aggressive for infant brains and may be more appropriate for adults.

@mattcieslak
Copy link
Contributor Author

quick question - if I wanted to warp the template QA and ISO images so they could be visualized in the same space as the fib's QA and ISO is there an easy way to get that done? I've tried

dsi_studio --action=reg --source=${SUBJECT_QA} --to=${TEMPLATE_QA} --t2s=${TEMPLATE_ISO} --mapping=${MAPPING_FIELD}

and

dsi_studio --action=reg --to=${TEMPLATE_QA} --mapping=${MAPPING_FIELD}

and both produce an output in the dsi studio templates directory that is A-P flipped

@frankyeh
Copy link
Owner

frankyeh commented Jan 23, 2026 via email

}
reg.linear_restarts = 6;
// Use a wider affine search (especially scaling) for lifespan differences.
static const float lifespan_affine_bound[3][8] = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably isn't what made the difference, I think it's the restarts

const std::vector<unsigned int>& color)
{
tipl::progress prog0("saving " + file_name);
tipl::out() << "saving tt: file=" << file_name
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was having trouble writing out tt files so I added a bunch of extra checks and fallbacks here. My suspicion is that the real issue was that the bad warps were causing template streamlines to be outside the field of view in native space, triggering a crash

@mattcieslak mattcieslak changed the title Add a "Chen Mode" for AutoTrack Add debugging options for AutoTrack and add random starts to linear reg Feb 4, 2026
@mattcieslak
Copy link
Contributor Author

I was able to get registration working consistently! The key change was to add random restarts to the linear registration.

Trackingwise the TIP iterations had to be set lower, and the otsu threshold set a bit lower too.

To figure this out, I added a couple other debugging features to autotrack. To access these, you can add items to a --debug flag in autotrack, where

  • --debug=template_images writes nifti files of the template images warped into subject space after registration.
    This is ultimately how I figured out that linear registration was getting stuck.
  • --debug=streamlines produces streamline outputs at each of the specified distance thresholds, with and without TIP.
    This was useful to confirm that the TIP iterations was too high for infants at 32.
  • --debug=shape writes out shape statistics for each of the distance thresholds and TIP iterations.
    I think in practice I will always enable this because it makes small files and can be very informative.
  • --debug=template_streamlines writes out the template streamlines warped to subject space. This is really useful for QC visualization, and I also calculate shape statistics on the template bundles in subject native space.

If you just specify --debug with no arguments then all of them are turned on, or if you want to select just a few like --debug=streamlines,template_images.

side note: There are some edits to tract_model.cpp where I was trying to figure out why autotrack was crashing when writing the template streamlines warped to subject space. It was only happening when there was a bad registration, but I think it might be helpful to keep some of the print-outs and exception handling. Happy to remove it too, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants