Tracts recognition and clustering via GUI and CLI

95 views
Skip to first unread message

Alexander Ershov

unread,
Oct 31, 2023, 1:48:45 PM10/31/23
to DSI Studio
Hi Frank, 
I have a question about tract recognition and clustering. There is a file group.t25.fdr0.05.t_statistics.fib.gz and a tract file group.t25.fdr0.05.neg_corr.tt.gz.
Through the GUI I can open the fib.gz file in [Step T3 Fiber Tracking], then load the tract file and run [Tracts Misc][Recognise and Cluster].
2023-10-31-202753.png
As a result I'll get clustered tracts with the option to save each one separately in tt.gz.
2023-10-31-202757.png

Is there any way to get the same result via cli?
The documentation mentions clustering https://dsi-studio.labsolver.org/doc/cli_t3.html#clustering-settings, but output is only a cluster label, with no option to save tracts to tt.gz. I couldn't find a solution among several similar questions (1, 2) in the DSI Studio group.

Regards,
Alex

Frank Yeh

unread,
Oct 31, 2023, 2:13:18 PM10/31/23
to alexande...@gmail.com, DSI Studio
I am listing on my to-do list and will see what I can do.
Frank

--
You received this message because you are subscribed to the Google Groups "DSI Studio" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dsi-studio+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dsi-studio/d364bf1f-5bb1-48e8-8636-f0925c991fe4n%40googlegroups.com.

Alexander Ershov

unread,
Nov 5, 2023, 3:31:55 PM11/5/23
to DSI Studio
Are there any updates on tract clustering through CLI?

вторник, 31 октября 2023 г. в 21:13:18 UTC+3, Frank Yeh:

Frank Yeh

unread,
Nov 6, 2023, 11:42:44 AM11/6/23
to alexande...@gmail.com, DSI Studio
This task has been requested before by other users, and I will revisit
again to see if it can be implemented.
Frank

On Sun, Nov 5, 2023 at 3:31 PM Alexander Ershov
<alexande...@gmail.com> wrote:
>
> Are there any updates on tract clustering through CLI?
>
> вторник, 31 октября 2023 г. в 21:13:18 UTC+3, Frank Yeh:
>>
>> I am listing on my to-do list and will see what I can do.
>> Frank
>>
>> On Tue, Oct 31, 2023 at 1:48 PM Alexander Ershov <alexande...@gmail.com> wrote:
>>>
>>> Hi Frank,
>>> I have a question about tract recognition and clustering. There is a file group.t25.fdr0.05.t_statistics.fib.gz and a tract file group.t25.fdr0.05.neg_corr.tt.gz.
>>> Through the GUI I can open the fib.gz file in [Step T3 Fiber Tracking], then load the tract file and run [Tracts Misc][Recognise and Cluster].
>>> As a result I'll get clustered tracts with the option to save each one separately in tt.gz.
>>>
>>> Is there any way to get the same result via cli?
>>> The documentation mentions clustering https://dsi-studio.labsolver.org/doc/cli_t3.html#clustering-settings, but output is only a cluster label, with no option to save tracts to tt.gz. I couldn't find a solution among several similar questions (1, 2) in the DSI Studio group.
>>>
>>> Regards,
>>> Alex
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups "DSI Studio" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an email to dsi-studio+...@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/msgid/dsi-studio/d364bf1f-5bb1-48e8-8636-f0925c991fe4n%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups "DSI Studio" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to dsi-studio+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/dsi-studio/71245e1e-7559-41c4-85ec-3080f7d255e2n%40googlegroups.com.

Frank Yeh

unread,
Nov 6, 2023, 11:59:50 AM11/6/23
to alexande...@gmail.com, DSI Studio
Just did a code review.
Have you tried adding --recognize to the CLI and see if the output
works for you?

Alexander Ershov

unread,
Nov 6, 2023, 2:41:35 PM11/6/23
to DSI Studio
Yes, I tried --recognize: dsi_studio --action=ana --source=group.t25.fdr0.05.t_statistics.fib.gz --tract=group.t25.fdr0.05.neg_corr.tt.gz -- recognize=1. The output is two files: 1.name.txt and 1.labels.txt.
In 1.name.txt there are pathways names like Cingulum_Frontal_Parietal_R, Cingulum_Frontal_Parahippocampal_R, Cingulum_Frontal_Parahippocampal_L, etc, in 1.labels.txt - set of numbers with spaces like 3 9 4 0 1 4 0 3 3 6 5 ... .
I would like to get files like Cingulum_Frontal_Parietal_R.trk, Cingulum_Frontal_Parahippocampal_R.trk, Cingulum_Frontal_Parahippocampal_L.trk, etc.

понедельник, 6 ноября 2023 г. в 19:59:50 UTC+3, Frank Yeh:

Frank Yeh

unread,
Nov 6, 2023, 7:29:43 PM11/6/23
to alexande...@gmail.com, DSI Studio
Currently there is no such a function in CLI because the CLI pipeline
assumes "single tract"

This function was previously requested and is still waiting for many
modifications to be done.
(may not be readily available in a short time).

Best regards,
Frank

On Mon, Nov 6, 2023 at 2:41 PM Alexander Ershov
> To view this discussion on the web visit https://groups.google.com/d/msgid/dsi-studio/5953defe-6c23-4001-b0dc-1f901d5671c6n%40googlegroups.com.

Wenjun Huang

unread,
Jul 5, 2024, 1:00:45 AMJul 5
to DSI Studio
Hi, all

I was wondering if there has been any progress with clustering through the CLI?"  

Best regards,
Wenjun

Wenjun Huang

unread,
Jul 5, 2024, 6:36:20 AMJul 5
to DSI Studio
Hi all

I think the set of numbers should correspond to the labels. For example, if there are 4 labels, the highest number should be 3, where 0 represents the first label, 1 represents the second label, 2 represents the third label, and 3 represents the fourth label. Then, if there are 10 zeros, it means the number of tracts for the first label is 10, and so on. This seems to match the stats I exported from the GUI. Do I understand this correctly? Additionally, I don't know how to export other data from the stats, such as mean length (mm) and total volume (mm^3). Do you know how to do that?

Best,
Wenjun

Frank Yeh

unread,
Jul 5, 2024, 6:39:41 AMJul 5
to wh2...@nyu.edu, DSI Studio

Frank Yeh

unread,
Jul 5, 2024, 6:40:30 AMJul 5
to wh2...@nyu.edu, DSI Studio

I think the set of numbers should correspond to the labels. For example, if there are 4 labels, the highest number should be 3, where 0 represents the first label, 1 represents the second label, 2 represents the third label, and 3 represents the fourth label. Then, if there are 10 zeros, it means the number of tracts for the first label is 10, and so on. This seems to match the stats I exported from the GUI. Do I understand this correctly? Additionally, I don't know how to export other data from the stats, such as mean length (mm) and total volume (mm^3). Do you know how to do that?

Wenjun Huang

unread,
Jul 8, 2024, 12:06:16 AMJul 8
to DSI Studio
I have checked the webpage, and I can indeed use dsi_studio --action=ana --source=**.fib.gz --tract="%RESOURSE_DIR%\!EM_name!.t25.length30.dec.tt.gz" --recognize=cluster --export=qa to export QA. However, the data exported through the GUI also includes additional information such as the total volume and total surface area of each cluster after recognition and clustering. I tried to find a way to export results using the --export option on the website, but it seems I couldn't find it. I attempted to use dsi_studio --action=ana --source=**.fib.gz --tract="%RESOURSE_DIR%\!EM_name!.t25.length30.dec.tt.gz" --recognize=cluster --export=volume, but the log reported that "volume" is invalid.  

Best,
Wenjun

Frank Yeh

unread,
Jul 8, 2024, 12:08:27 AMJul 8
to wh2...@nyu.edu, DSI Studio
I would write a script to remove additional information. This may be the easiest solution.

Best regards 
Frank

Wenjun Huang

unread,
Jul 8, 2024, 12:26:27 AMJul 8
to DSI Studio

I might not have expressed myself clearly just now. What I meant to say is that when we use the GUI for recognition and clustering, we can export a lot of data for each cluster. For example, we can get data like this:

Tract Name Commissure_CorpusCallosum_Tapetum Commissure_CorpusCallosum_ForcepsMajor Commissure_CorpusCallosum_Body ProjectionBasalGanglia_CorticostriatalTractL_Posterior
number of tracts 58 3975 1193 1
mean length(mm) 69.5699 68.8097 66.8984 59.9843
span(mm) 27.4314 26.8529 24.3158 20.8234
curl 2.53614 2.56433 2.75124 2.88062
elongation 4.86619 5.08232 6.09876 48.1881
total volume(mm^3) 11168 9928 6322 73
1st quarter volume(mm^3) 2700 2052 1377 18
2nd and 3rd quarter volume(mm^3) 5768 5824 3568 37
4th quarter volume(mm^3) 2700 2082 1377 18
total surface area(mm^2) 17078 15763 11968 765
total radius of end regions(mm) 13.8701 13.8418 12.4328 0
total area of end regions(mm^2) 3209 2976 1225 2
irregularity 5.46555 5.29611 5.19136 3.26119
area of end region 1(mm^2) 1605 1502 589 1
radius of end region 1(mm) 7.43103 6.92757 6.24207 0
volume of end branches 1 2700 2052 1377 18
area of end region 2(mm^2) 1604 1474 636 1
radius of end region 2(mm) 6.43912 6.91425 6.19072 0
volume of end branches 2 2700 2052 1377 18
qa 0.543826 0.642542 0.534644 0.382738
iso 0.455073 0.494049 0.454302 0.446953
ICBM152_adult.T1W 210.615 203.806 209.772 214.414
ICBM152_adult.T2W 133.446 139.411 137.594 126.626
ICBM152_adult.WM 233.59 221.69 268.592 249.871

However, if I use the CLI with the command, I can only export QA(dsi_studio --action=ana --source=**.fib.gz --tract="%RESOURSE_DIR%\!EM_name!.t25.length30.dec.tt.gz" --recognize=cluster --export=qa). If I want to export the total volume, how should I do it? I tried using dsi_studio --action=ana --source=**.fib.gz --tract="%RESOURSE_DIR%\!EM_name!.t25.length30.dec.tt.gz" --recognize=cluster --export=volume, but the log reported that "volume" is invalid. Currently, I do not urgently need to get the volume through the CLI, I am just curious about how to obtain it.


Best,

Wenjun

Frank Yeh

unread,
Jul 8, 2024, 12:29:16 AMJul 8
to wh2...@nyu.edu, DSI Studio
There are some examples about getting tract statistics at https://dsi-studio.labsolver.org/doc/cli_ana.html

Hope it helps
Frank

Wenjun Huang

unread,
Jul 8, 2024, 9:38:41 AMJul 8
to DSI Studio
I have reviewed webpage and the description of the export flag, but I couldn't find the output statements for total volume, mean length, etc. I followed the instructions and made some attempts:
 
1. Use --export=stat to export tract statistics like along tract mean FA, ADC, or morphology index such as volume, length, etc. (dsi_studio --action=ana --source=**.fib.gz --tract="%RESOURSE_DIR%!EM_name!.t25.length30.dec.tt.gz" --recognize=cluster --export=stat), but this command exports data for the entire !EM_name!.t25.length30.dec.tt.gz. I hope to get the data after recognition and clustering.
2. Use --export=qa,iso,dti_fa,ad,rd,md to export the diffusion metrics as NIfTI files. (dsi_studio --action=ana --source=**.fib.gz --tract="%RESOURSE_DIR%!EM_name!.t25.length30.dec.tt.gz" --recognize=cluster --export=qa,iso,dti_fa,ad,rd,md), but it still does not seem to contain results for total volume or mean length. Additionally, when entering this command, the log shows: invalid export option iso. 
The details are as follows:
[1;34mDSI Studio version: Chen"陳" Mar 19 2024 [0m
| cannot obtain GPU driver and device information (CUDA ERROR 35). please update the Nvidia driver and install CUDA Toolkit.
| [0;33mDSI Studio version [0m: Chen"陳"
| [0;32maction [0m=ana
| [0;32msource [0m=E:\
| [0;32mloop [0m=E:\
|- [1;34mrun ana [0m
| | loading E:**.fib.gz...
| |- [1;34mopen FIB file Accel.t25.length30.t_statistics.fib.gz [0m
| | | loading fiber and image data
| | |- [1;34mloading image volumes [0m
| | | |_11 ms
| | | initiating data
| | | [0;33mmatched template (by image size) [0m: ICBM152_adult
| | | FIB file loaded
| | |_156 ms
| | [0;32moutput [0m=
| | [0;32mtract [0m=E:\Accel.t25.length30.dec.tt.gz
| |- [1;34mloading [0m
| | |_56 ms
| | [0;33mhost space (mni) [0m:
| | -2 0 0 78
| | 0 -2 0 76
| | 0 0 2 -50
| | 0 0 0 1
| | [0;33mtractography space (native) [0m:
| | -2 0 0 78
| | 0 -2 0 76
| | 0 0 2 -50
| | 0 0 0 1
| | A total of 10197 tracks loaded
| | a total of 1 tract file(s) loaded
| | merging all tracts into one for post-tract analysis
| |- [1;34mpost-tracking analysis [0m
| | | [0;32mtip_iteration [0m=0
| | |- [1;34mloading tractography atlas [0m
| | | |- [1;34mloading [0m
| | | | |_94 ms
| | | | [0;33mhost space (mni) [0m:
| | | | -2 0 0 78
| | | | 0 -2 0 76
| | | | 0 0 2 -50
| | | | 0 0 0 1
| | | | [0;33mtractography space (mni) [0m:
| | | | -1 0 0 78
| | | | 0 -1 0 76
| | | | 0 0 1 -50
| | | | 0 0 0 1
| | | | [0;33mapply transform to tracts [0m:
| | | | 0.5 0 0 0
| | | | 0 0.5 0 0
| | | | 0 0 0.5 0
| | | | 0 0 0 1
| | | |_122 ms
| | |- [1;34mloading tractography atlas [0m
| | | |_0 ms
| | | [0;32mrecognize [0m=cluster
| | | recognized labels saved to cluster.label.txt
| | | recognized names saved to cluster.name.txt
| | | [0;32mexport [0m=qa,iso,dti_fa,ad,rd,md
| | | invalid export option iso
| | |_46.65 s
| |_46.879 s
|_46.888 s

  Could it be that I missed some information? If you could point it out to me, I would really appreciate it.  


Best,
Wenjun

Frank Yeh

unread,
Jul 8, 2024, 9:40:03 AMJul 8
to wh2...@nyu.edu, DSI Studio
How about --export=stat

Wenjun Huang

unread,
Jul 8, 2024, 11:04:05 AMJul 8
to DSI Studio
I tried dsi_studio --action=ana --source=**.fib.gz --tract="%RESOURSE_DIR%!EM_name!.t25.length30.dec.tt.gz" --recognize=cluster --export=stat), but this command exports data for the entire !EM_name!.t25.length30.dec.tt.gz. I hope to get the data after recognition and clustering.

Best,
Wenjun

Frank Yeh

unread,
Jul 8, 2024, 11:06:16 AMJul 8
to wh2...@nyu.edu, DSI Studio
You would need to separate tt.gz file into multiple tt.gz files for each cluster.
There are some discussion in the forum about this. Hope that helps.

Best regards,
Frank

Wenjun Huang

unread,
Jul 8, 2024, 10:55:41 PMJul 8
to DSI Studio
Sure, I will search for the related discussions. Thank you for your reply.

Best,
Wenjun  

Frank Yeh

unread,
Jul 8, 2024, 11:04:34 PMJul 8
to wh2...@nyu.edu, DSI Studio
I did a quick review of this issue. Separating tracts has not been implemented yet in DSI Studio (still on the to-do).

I will see if I can implement it in the next major release.

Best,
Frank

Frank Yeh

unread,
Jul 25, 2024, 11:45:16 PM (3 days ago) Jul 25
to wh2...@nyu.edu, DSI Studio
The new DSI Studio release (the Hou version) at
https://github.com/frankyeh/DSI-Studio/releases/tag/2024.06.12
is now providing the function to deal with recognizing results like
GUI in two steps:

1. Using --action=trk to recognize tracts and save clusters with the
tractography file (*.tt.gz):

dsi_studio --action=trk --source=sub-01.src.gz.gqi.1.25.fib.gz
--track_id=Arcuate --fiber_count=10000
--recognize=cluster--output=tractography.tt.gz

2. --action=ana will load cluster information from the tractography
file and cluster name from the test file and output statistics for
each cluster:

dsi_studio --action=ana --source=sub-01.src.gz.gqi.1.25.fib.gz
--tract=tractography.tt.gz --name=cluster.name.txt --export=stat

The Hou version is at pre-release stage, and the DSI Studio website is
still providing the previous Chen version.
Please make sure you have the latest version from the github.

Best regards,
Frank
Reply all
Reply to author
Forward
0 new messages