sina-mansour / UKB-connectomics

This repository will host scripts used to map structural and functional brain connectivity matrices for the UK biobank dataset.
https://www.biorxiv.org/content/10.1101/2023.03.10.532036v1
62 stars 7 forks source link

tck2connectome unexpected mean output #28

Closed sina-mansour closed 2 years ago

sina-mansour commented 2 years ago

I was just looking into the mapped connectomes using tck2connectome and realized that the connectomes mapping mean FA and mean length produce incorrect outputs. Basically, the output matrix only contains 1s and 0s (like a binary mask):

array([[1., 1., 0., ..., 1., 1., 1.],
       [1., 1., 0., ..., 0., 1., 1.],
       [0., 0., 1., ..., 1., 1., 1.],
       ...,
       [1., 0., 1., ..., 1., 1., 1.],
       [1., 1., 1., ..., 1., 1., 1.],
       [1., 1., 1., ..., 1., 1., 1.]])

I checked and the streamline count and sift2 measures don't have this issue. So far, my guess is that there is a problem in tck2connectome -stat_edge mean that produces the incorrect maps.

This is an example of the complete command producing the binary csv: tck2connectome -nthreads 0 -info -symmetric -assignment_radial_search 4 -tck_weights_in "${streamline_mean_fa}" -stat_edge mean "${endpoints}" "${combined_atlas_dwi}" "${mean_fa}"

If -stat_edge is changed to sum, the output matrices will contain various float values as expected. That's why I'm suspecting the mean computation to be the cause of the issue.

sina-mansour commented 2 years ago

Could it possibly be about using -tck_weights_in vs. -scale_file .... I may be using -tck_weights_in incorrectly instead of -scale_file. I'll just check if that resolves the issue.

sina-mansour commented 2 years ago

Yes, that's it.

I'm still confused about the difference of the flags though.

For mean length and FA, I've replaced -tck_weights_in with -scale_file. @Lestropie do you reckon it's more correct if I also include sift weights in computing mean FA or mean length? i. e. something like the following:

tck2connectome -nthreads 0 -info -symmetric -assignment_radial_search 4 -tck_weights_in "${sift_weights}" -scale_file "${streamline_mean_fa}" -stat_edge mean "${endpoints}" "${combined_atlas_dwi}" "${mean_fa}"

Also, should FBC be computed with -tck_weights_in or -scale_file?

Lestropie commented 2 years ago

The SIFT2 track weights operate fractionally differently to "any arbitrary per-streamline quantitative value", in various places throughout the software; there are specific circumstances where their specific physical interpretation necessitates different handling. Indeed the fact that you can do something like mean FA or mean length and include SIFT2 weights, as you query about, is another demonstration of why these are two different options. When you compute for each edge a weighted mean across streamlines, you need to know that it's the mean FA that you're taking an average of and the SIFT2 weights that modulate which streamlines contribute more or less to the mean, rather than the other way around.

If a software container for generating connectomes is provided, it should be a binary flag as to whether or not SIFT2 weight information is utilised in connectome construction. For a set of connectomes to be pre-computed with other connectivity metrics, it would be my preference to include those weights in the calculation, but in reality they are unlikely to have a massive effect on those measures. For FBC, use of -tck_weights_in is technically the intended approach, though instead using -scale_file would produce an identical result.