Visualising/processing tck2connectome output

Hi,

I am relatively new to connectomics and have been using tck2connectome to produce my first connectomes. I have found mrview great for some visualisation, however I am struggling to find a convenient way to manipulate/examine this data. I was hoping there is some software that can use the tck2connectome .csv to produce connectome matrices, and which can combine my data for each patient group, and compare between them.

I have been investigating various software options for this, and note that connectome workbench is recommended, but it appears to require different inputs to the .csv that tck2connectome produces (or do I need to persevere with this?).

I wondered if anyone can recommend a simple (ideally gui based) tool that I can use for this, that can use the tck2connectome output.

Many thanks in advance,

Josh

Hi Josh,

mrview has a dedicated Connectome Tool that took me a long time to implement; I hope it hasnā€™t been entirely overlooked :tired_face: Admittedly the documentation page really needs to be filled with example images, but it was written way back when we couldnā€™t easily embed images in our documentation.

As far as ā€œcombining data for each patient groupā€, if youā€™re simply referring to calculating the mean of the connectomes across subjects within a group, this can be performed within any one of a range of softwares (e.g. Matlab, Octave, Python, ā€¦) and exported back to CSV.

Rob

Hi Rob,

Thank you for getting back to me. I have used the connectome tool in mrview for viewing the connectomes and it works really well for visualisation. I donā€™t think I have overlooked your hard work with it. The guide was good and easy to follow, even without images.

What I am looking for is an easy way to make matrices such as this (the SC one):

https://www.researchgate.net/publication/262381692/figure/fig4/AS:324983248179230@1454493452534/Figure2-Structural-and-functional-connectivity-matrices-of-the-neonatal-connectome.png

or this http://community.mrtrix.org/uploads/default/original/1X/dc87397f70a2063222829a06b64cdfbb857c6bc4.png

I donā€™t think the mrtrix connectome viewer does this, unless I have missed it?

I was also hoping that there was an easy way to run the various connectome graph metrics. I am sure that I can do this manually in matlab (with a lot of time), but was wondering if anyone was aware of something that would automate/help with doing this a little? Maybe that was a little hopeful.

Thanks again for your help.

Josh

What I am looking for is an easy way to make matrices such as this (the SC one) ā€¦ I donā€™t think the mrtrix connectome viewer does this, unless I have missed it?

No, mrview doesnā€™t have any such capability. I kept connectome visualisation capabilities within the scope of ā€œthat that may sensibly be visualised in 3D space alongside other mrview capabilitiesā€; matrix-based plots such as these arenā€™t located within 3D space, and simply werenā€™t worth the investment of development time since thereā€™s all sorts of other softwares that can generate such. The latter of your two examples Iā€™m pretty sure can be generated using the image visualisation toolbox in MatLab.

I was also hoping that there was an easy way to run the various connectome graph metrics.

There was some progress made on this, but the features are not yet available.

If you use python, MNE (https://martinos.org/mne/stable/index.html) can be used to make one of those connectome circle plots pretty easily. Load your labels and colors from the same file you used with labelconvert (I use a slightly edited version of FreeSurferColorLUT.txt), and make sure you use the -symmetric and -zero_diagonal options with tck2connectome. Hereā€™s an example with code (I also exclude the cerebellum but left that out in the code for simplicity):

import mne
labels = []
    node_colors = []
    unknown_found = None
    with open('freesurfer_labels.txt') as f:
        for x in f.readlines():
            if unknown_found and x.split():
                labels.append(x.split()[2]) 
                node_colors.append(tuple([float(color)/255 for color in x.split()[3:6]]))
            if 'Unknown' in x:
                unknown_found = True

    node_angles = mne.viz.circular_layout(labels, labels)

    connectome = np.loadtxt(os.path.join('connectome.csv'))
    mne.viz.plot_connectivity_circle(connectome, labels, node_angles = node_angles, node_colors = node_colors )

6 Likes

As for those matrices, you can start by just plotting the connectome matrix with imshow:

import matplotlib.pyplot as plt
plt.imshow(connectome)

You just need to pretty it up.

image

2 Likes

Hi Rob,

fair enough, I will explore MatLabā€™s image visualisation a bit more.

Thanks for getting back to be.

Josh

Hi Jolinda,

These are exactly what I was looking for. I will give them a try now.

I really appreciate the help,

Thanks a lot,

Josh

Hi Jolinda,
thanks for your helpful example.
Since I am a beginner of python. I met some errors when I run the with loop.

ValueError: could not convert string to float: ā€˜duplicatesā€™

I think maybe the problem comes from readlines?
And I also wonder what is ā€˜Unknowā€™? Is it default?
I donā€™t if these are too simple questions for you.
Looking forward you replay.

Best,
Ziqian

Hi Jolinda,
problem solved. Thank you!

Best,
Ziqian