# Missing peaks with sh2peaks

**URL:** https://community.mrtrix.org/t/missing-peaks-with-sh2peaks/8732
**Category:** Uncategorized
**Tags:** tractography
**Created:** [April 8, 2026, 1:07pm UTC](https://community.mrtrix.org/t/missing-peaks-with-sh2peaks/8732 "2026-04-08T13:07:40Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![daducci](https://community.mrtrix.org/user_avatar/community.mrtrix.org/daducci/32/415_2.png) [@daducci](https://community.mrtrix.org/u/daducci)
#### Post date: [April 8, 2026, 1:07pm UTC](https://community.mrtrix.org/t/missing-peaks-with-sh2peaks/8732/1 "2026-04-08T13:07:41Z")

</div>

Hi guys,

I’m trying to compute peaks from an SH function with two very clear/distinct lobes (see screenshot #1), but sometimes major peaks are missed in place of much smaller ones (see screenshot #2). The SH functions were estimated with TODI (i.e. `tckmap … -tod …`) from the ground-truth streamlines of a numerical phantom, and I tried changing several settings, e.g., lmax, `-stat_vox`, `-precise`, `-num`etc in both `tckmap` and `sh2peaks`, but many major peaks are always missed. Is there something I can fine-tune to improve results?

I fear the same problem happens in the line-propagation of `SD_STREAM` and, sometimes, streamlines are interrupted or deflected (even though a lobe aligned with the current streamline tangent seems present, see screenshots #3 and #4) without no apparent reason (I checked masks, cutoffs etc). NB: screenshots #1 and #2 refer to different locations inside the phantom than screenshots #3 and #4.

Any clues or tricks?

 ![Screenshot 1](https://community.mrtrix.org/uploads/default/original/2X/2/2223fc212cbf1337c6f3d4908be7d64931cc7cd8.jpeg)

 ![Screenshot 2](https://community.mrtrix.org/uploads/default/original/2X/1/1fa147eda62293772822f8c25979367ef58007db.png)

 ![Screenshot 4](https://community.mrtrix.org/uploads/default/original/2X/4/495063ef7886d85559b60e7f10b9bcde7a22acf5.png)

 ![Screenshot 3](https://community.mrtrix.org/uploads/default/original/2X/b/b28c64645034b49935e2500e9096e16d8ba2bc6c.jpeg)

---

<div class="post-metadata">

### Author: ![bjeurissen](https://community.mrtrix.org/user_avatar/community.mrtrix.org/bjeurissen/32/28_2.png) [@bjeurissen](https://community.mrtrix.org/u/bjeurissen)
#### Post date: [April 8, 2026, 1:35pm UTC](https://community.mrtrix.org/t/missing-peaks-with-sh2peaks/8732/2 "2026-04-08T13:35:01Z")

</div>

Wow, that looks pretty serious. Are you able to provide a (partial) fODF field that we can use to reproduce this?

Also, can you confirm that you are using a recent version?

---

<div class="post-metadata">

### Author: ![daducci](https://community.mrtrix.org/user_avatar/community.mrtrix.org/daducci/32/415_2.png) [@daducci](https://community.mrtrix.org/u/daducci)
#### Post date: [April 8, 2026, 1:38pm UTC](https://community.mrtrix.org/t/missing-peaks-with-sh2peaks/8732/3 "2026-04-08T13:38:55Z")

</div>

Hi Ben,

Yes, I’m using version `3.0.8`. If I enable debug messages I get `[DEBUG] failed to find SH peak!` many times. I tried to go through the code to understand why this happens, but it’s way too complex for me, sorry… 😛

Sure, I can prepare a minimal working example. How can I share it then? Here or via email?

---

<div class="post-metadata">

### Author: ![bjeurissen](https://community.mrtrix.org/user_avatar/community.mrtrix.org/bjeurissen/32/28_2.png) [@bjeurissen](https://community.mrtrix.org/u/bjeurissen)
#### Post date: [April 8, 2026, 1:43pm UTC](https://community.mrtrix.org/t/missing-peaks-with-sh2peaks/8732/4 "2026-04-08T13:43:47Z")

</div>

> [@daducci](#):
>
> Sure, I can prepare a minimal working example. How can I share it then? Here or via email?

Any way you are comfortable with!

---

<div class="post-metadata">

### Author: ![daducci](https://community.mrtrix.org/user_avatar/community.mrtrix.org/daducci/32/415_2.png) [@daducci](https://community.mrtrix.org/u/daducci)
#### Post date: [April 8, 2026, 2:42pm UTC](https://community.mrtrix.org/t/missing-peaks-with-sh2peaks/8732/5 "2026-04-08T14:42:29Z")

</div>

I cropped my dataset to 3x3x5 voxels, and included the fODF field computed with TODI and a (silly) WM mask. I run tracking as follows:

```auto
tckgen -algorithm SD_STREAM fODF.nii.gz SDSTREAM.tck -select 100 -seed_image wm.nii.gz -mask wm.nii.gz -minlen 0.5

```

I cannot upload the files as the system does not allow me, so I uploaded them to my public Dropbox.

Can you spot anything wrong on my side?

Thanks!  
Ale

> **[Dropbox](https://www.dropbox.com/scl/fo/9mz8voqfcu1x7ncy39mde/AF8yL3kGN0yDZuicxpXVSNk?rlkey=f5d5k7yn8k17x6mvxhdu4ix88&dl=0)**

---

<div class="post-metadata">

### Author: ![daducci](https://community.mrtrix.org/user_avatar/community.mrtrix.org/daducci/32/415_2.png) [@daducci](https://community.mrtrix.org/u/daducci)
#### Post date: [April 9, 2026, 8:24am UTC](https://community.mrtrix.org/t/missing-peaks-with-sh2peaks/8732/6 "2026-04-09T08:24:09Z")

</div>

Not sure if this helps, but I debugged the `SH::get_peak()` function and found that some peaks are missed because the `ANGLE_TOLERANCE` is not met (see screenshot #5). Here, the `amplitude=1.11897` corresponds to the single-lobe peak in a voxel with a single-fiber population, so it should be recognized as a peak. But `dt` never falls below the `ANGLE_TOLERANCE` threshold and, thus, the peak is not found and `SD_STREAM` tracking is halted for that streamline, even though a peak/lobe to follow is there.

Can an additional convergence criterion be added (on the amplitude?), or a global parameter to control `ANGLE_TOLERANCE` in all functions that use the `SH::get_peak()` function?

PS: I have to admit that I didn’t fully understand the function (SH derivatives etc), so take my comments with caution… 😅

 ![Screenshot 5](https://community.mrtrix.org/uploads/default/original/2X/8/89773409f824f6e6154722272f7efa5875ff76b6.png)

---

<div class="post-metadata">

### Author: ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)
#### Post date: [April 9, 2026, 8:19pm UTC](https://community.mrtrix.org/t/missing-peaks-with-sh2peaks/8732/7 "2026-04-09T20:19:48Z")

</div>

Thanks for reporting, Ale! I’ll need to dig out my notes from 20 years ago, when I did all these derivations… Won’t have time to look into it till next week though… 🙄

Cheers!  
Donald.

---

<div class="post-metadata">

### Author: ![bjeurissen](https://community.mrtrix.org/user_avatar/community.mrtrix.org/bjeurissen/32/28_2.png) [@bjeurissen](https://community.mrtrix.org/u/bjeurissen)
#### Post date: [April 13, 2026, 1:30pm UTC](https://community.mrtrix.org/t/missing-peaks-with-sh2peaks/8732/8 "2026-04-13T13:30:29Z")

</div>

@daducci could you check if [Fix near-pole numerical issues in SH peak-finding by Copilot · Pull Request #3299 · MRtrix3/mrtrix3 · GitHub](https://github.com/MRtrix3/mrtrix3/pull/3299) adresses the issue?

---

<div class="post-metadata">

### Author: ![daducci](https://community.mrtrix.org/user_avatar/community.mrtrix.org/daducci/32/415_2.png) [@daducci](https://community.mrtrix.org/u/daducci)
#### Post date: [April 13, 2026, 4:11pm UTC](https://community.mrtrix.org/t/missing-peaks-with-sh2peaks/8732/9 "2026-04-13T16:11:34Z")

</div>

Hi @bjeurissen ,

Yes, it does the trick! thanks a lot for the quick patch!
