# New tractography by using a weights.csv file

**URL:** https://community.mrtrix.org/t/new-tractography-by-using-a-weights-csv-file/4181
**Category:** Uncategorized
**Created:** [October 13, 2020, 1:50am UTC](https://community.mrtrix.org/t/new-tractography-by-using-a-weights-csv-file/4181 "2020-10-13T01:50:35Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![mferrandino80](https://community.mrtrix.org/user_avatar/community.mrtrix.org/mferrandino80/32/2717_2.png) [@mferrandino80](https://community.mrtrix.org/u/mferrandino80)
#### Post date: [October 13, 2020, 1:50am UTC](https://community.mrtrix.org/t/new-tractography-by-using-a-weights-csv-file/4181/1 "2020-10-13T01:50:35Z")

</div>

Hello,  
I created a streamlines tractography by one million of seeds:

```auto
tckgen -algorithm iFOD2 -act DTI.nii.gz -backtrack -seed_gmwmi gmwmSeed_coreg.mif -nthreads 8 -minlength 15 -maxlength 250 -cutoff 0.06 -select 1000000 -mask mask.nii.gz wmfod_norm.mif tracks.tck

```

After that I used tcksift2:

```auto
tcksift2 -act 5tt2.nii.gz -out_mu sift_mu.txt -out_coeffs sift_coeffs.txt -nthreads 8 tracks.tck wmfod_norm.mif weights.csv

```

In this way I obtained my weights.csv file.

I have created the connectometry (tck2connectome) by using both methods: with and without the weights.csv file. The two connectometry files are different. However, I wanted to re-created my tractography by using the weights.csv file. I do not know if my procedure is correct, however, I did:

```auto
tckedit -tck_weights_in weights.csv tracks.tck tracks_tcksift2.tck

```

The issue is the the output file containing the tracks generated (tracks\_tcksift2.tck) is the same of my input file.

Do I make some error? Which is the correct method to re-create the filtered tractography by using a weights.csv file

Thanks,  
Best,

Michele

---

<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: [October 13, 2020, 8:48am UTC](https://community.mrtrix.org/t/new-tractography-by-using-a-weights-csv-file/4181/2 "2020-10-13T08:48:11Z")

</div>

I think there is confusion as to what the SIFT2 weights represent, and how that relates to the streamlines themselves. Have a look at @rsmith’s [wiki post on the topic](https://community.mrtrix.org/t/handling-sift2-weights/2242), hopefully it’ll clarify how things work.

---

<div class="post-metadata">

### Author: ![mferrandino80](https://community.mrtrix.org/user_avatar/community.mrtrix.org/mferrandino80/32/2717_2.png) [@mferrandino80](https://community.mrtrix.org/u/mferrandino80)
#### Post date: [October 13, 2020, 9:51am UTC](https://community.mrtrix.org/t/new-tractography-by-using-a-weights-csv-file/4181/3 "2020-10-13T09:51:30Z")

</div>

HI,  
thank you so much for the link. Therefore, if I understand correctly, there is not method to create a new tract with the SIFT2 weights. Correct?  
Michele

---

<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: [October 13, 2020, 9:52am UTC](https://community.mrtrix.org/t/new-tractography-by-using-a-weights-csv-file/4181/4 "2020-10-13T09:52:56Z")

</div>

That’s right. The SIFT2 weights are additional information that complements the streamlines.The tck file is entirely unaffected by that information, and can’t store that type of information anyway.

---

<div class="post-metadata">

### Author: ![mferrandino80](https://community.mrtrix.org/user_avatar/community.mrtrix.org/mferrandino80/32/2717_2.png) [@mferrandino80](https://community.mrtrix.org/u/mferrandino80)
#### Post date: [October 13, 2020, 1:28pm UTC](https://community.mrtrix.org/t/new-tractography-by-using-a-weights-csv-file/4181/5 "2020-10-13T13:28:56Z")

</div>

Thanks!  
Michele

---

<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: [October 14, 2020, 6:44am UTC](https://community.mrtrix.org/t/new-tractography-by-using-a-weights-csv-file/4181/6 "2020-10-14T06:44:41Z")

</div>

Hi Michele,

The `.tck` file format is described [here](https://mrtrix.readthedocs.io/en/latest/getting_started/image_data.html#tracks-file-format-tck), and while it doesn’t say so explicitly, has no capacity for storing the per-streamline weights. Given you’re not the first person to attempt to “embed” the SIFT2 weights within a `.tck` file like this, I might make a little addition to the documentation mentioning such.

* * *

Mildly on-topic: If anybody is both interested in the prospect of an alternative format for storing streamlines data that would have the capacity to internally store per-streamline weights (along with a wealth of other information), and doesn’t mind a little bleeding from the eyes, check out [this `nibabel` thread](https://github.com/nipy/nibabel/issues/942).

Rob

---

<div class="post-metadata">

### Author: ![mferrandino80](https://community.mrtrix.org/user_avatar/community.mrtrix.org/mferrandino80/32/2717_2.png) [@mferrandino80](https://community.mrtrix.org/u/mferrandino80)
#### Post date: [October 14, 2020, 6:16pm UTC](https://community.mrtrix.org/t/new-tractography-by-using-a-weights-csv-file/4181/7 "2020-10-14T18:16:13Z")

</div>

@rsmith  
Thank you for the link.  
I have read that it is not possible to recreate a new tractography after filtering.  
Only last question: what is the utility of -tck\_weights\_in tckedit?  
Michele

---

<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: [October 21, 2020, 2:14am UTC](https://community.mrtrix.org/t/new-tractography-by-using-a-weights-csv-file/4181/8 "2020-10-21T02:14:44Z")

</div>

> [@mferrandino80](#):
>
> what is the utility of `-tck_weights_in tckedit`?

Let’s say you’ve got a whole-brain tractogram, have applied SIFT2, and now want to extract a specific tract of interest using `tckedit`. If you just run `tckedit` on your whole-brain tractogram, then the output of `tckedit` will be a new track file, but of those streamlines in the output file, you will have lost the information about what weight was ascribed to each. By using `-tck_weights_in` _and_ `-tck_weights_out`, in addition to the output track file, `tckedit` will also output a new weights file, containing only the weights of those streamlines that were written to the output file.

It’s also possible to select which streamlines are written to the output file and which are not [based on the streamline weights](https://mrtrix.readthedocs.io/en/3.0.2/reference/commands/tckedit.html#thresholds-pertaining-to-per-streamline-weighting); esoteric and not useful to most people, but it’s nevertheless a valid answer to your question.
