# Streamline length

**URL:** <https://community.mrtrix.org/t/streamline-length/369>\
**Category:** Uncategorized\
**Tags:** connectomics\
**Created:** [July 31, 2016, 10:21am UTC](https://community.mrtrix.org/t/streamline-length/369 "2016-07-31T10:21:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmccolgan](https://community.mrtrix.org/user_avatar/community.mrtrix.org/pmccolgan/32/1753_2.png) [@pmccolgan](https://community.mrtrix.org/u/pmccolgan)\
**Post date:** [July 31, 2016, 10:21am UTC](https://community.mrtrix.org/t/streamline-length/369/1 "2016-07-31T10:21:48Z")

</div>

Dear MRtrix team,

Is there a way of outputing streamline length for each ROI-ROI connection in a connectome analysis.

Thanks

Peter

---

<div class="post-metadata">

**Author:** ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)\
**Post date:** [August 2, 2016, 4:23pm UTC](https://community.mrtrix.org/t/streamline-length/369/2 "2016-08-02T16:23:43Z")

</div>

Yep: in the `tck2connectome` [help page](http://mrtrix.readthedocs.io/en/latest/reference/commands/tck2connectome.html), check out the options for the connectivity metric, as well as the `-stat_edge` option (note that the command interface here changed as part of the [last tagged update](https://community.mrtrix.org/t/mrtrix3-version-incremented-to-0-3-15/300/1)).

So, for instance, if you want the mean streamline length in each edge:

- Use `-scale_length`: This makes the contribution of each streamline to the relevant edge equal to the length of that streamline, rather than unity.
- Use `-stat_edge mean`: This takes the value of each edge as the _mean_ of the values contributed by each streamline within that edge, rather than their sum.

“Calculate the lengths, take the mean” = mean length 😛 It’s not as immediately obvious as the old interface, but it’s a lot more flexible.

Have fun!  
Rob

---

<div class="post-metadata">

**Author:** ![Chris\_Steele](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/c/9dc877/32.png) [@Chris\_Steele](https://community.mrtrix.org/u/Chris_Steele)\
**Post date:** [March 29, 2017, 11:39am UTC](https://community.mrtrix.org/t/streamline-length/369/3 "2017-03-29T11:39:01Z")

</div>

I was looking at this today and edges that don’t have any length end up being recorded in the file as -nan (i.e., when I set -scale\_length -stat\_edge mean). Is this the correct behaviour? It makes parsing the file a bit difficult and I think that this also results in the file taking up much more space than it would if the -nan was simply 0.

… since I am on a space and memory optimization kick at the moment! 🙂  
Chris

---

<div class="post-metadata">

**Author:** ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)\
**Post date:** [March 30, 2017, 6:01am UTC](https://community.mrtrix.org/t/streamline-length/369/4 "2017-03-30T06:01:33Z")

</div>

> Is this the correct behaviour?

No, that’s a mistake I introduced when making the `tck2connectome` memory-saving changes (the problem isn’t there in `master`). Pushed the fix to `tag_0.3.16` straight away since it’s a trivial thing.

---

<div class="post-metadata">

**Author:** ![Chris\_Steele](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/c/9dc877/32.png) [@Chris\_Steele](https://community.mrtrix.org/u/Chris_Steele)\
**Post date:** [March 30, 2017, 7:53am UTC](https://community.mrtrix.org/t/streamline-length/369/5 "2017-03-30T07:53:48Z")

</div>

Perfect, thank you!

---

<div class="post-metadata">

**Author:** ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)\
**Post date:** [March 3, 2019, 5:10am UTC](https://community.mrtrix.org/t/streamline-length/369/6 "2019-03-03T05:10:04Z")

</div>

A post was split to a new topic: [SIFT2 weights & streamlines lengths](https://community.mrtrix.org/t/sift2-weights-streamlines-lengths/2325)
