saving tracks in T1W/T2W space from command line - bug???

97 views
Skip to first unread message

Ian Wiggins

unread,
Apr 27, 2022, 10:08:06 AM4/27/22
to DSI Studio
Hi Frank,

Trying to make sense of some tractography output generated from the command line.

We are using the --ref option in an attempt to save track data in T1w/T2w space.

But the saved .trk files don't seem to reflect this. The data appear to be in the original dMRI space.

Looking at the source (trk.cpp, ~lines 483-500), unless I am misreading it, I think possibly the data are being saved in T1w/T2w space, but then immediately overwritten by the standard save_tracts_to_file function?

Grateful for your advice on this.

Many thanks,

Ian

Frank Yeh

unread,
Apr 27, 2022, 10:25:05 AM4/27/22
to dsi-s...@googlegroups.com
Currently, the command line only saves tracts in the original dMRI space.
A quick workaround is to resample DWI to the T1W/T2W space at
--action=rec --rotate_to=t1w.nii.gz
Then the following analysis will be in the T1W space.
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/a89956ea-bed6-4763-885d-6f3852f5adc7n%40googlegroups.com.

Ian Wiggins

unread,
Apr 27, 2022, 11:09:02 AM4/27/22
to dsi-s...@googlegroups.com
Hi Frank,

Thanks for the quick reply.

I've tried both --rotate_to and --align_to at the rec stage, but the subsequent .trk output looks the same as before (original dMRI space). 

The image we're trying to register to is an aparc+aseg.nii parcellation from Freesurfer. When I added this as a slice in the GUI and saved the tracks in T1w/T2w space, it seemed to work fine. But so far I haven't been able to reproduce this at the command line (needed as we are working with a large number of subjects). 

We're post-processing the results in Matlab. Would there be an obvious way to transform the .trk coordinates into the same space as aparc+aseg.nii after the fact? I'm getting a bit lost in all the different coordinate spaces.

Many thanks,

Ian

You received this message because you are subscribed to a topic in the Google Groups "DSI Studio" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dsi-studio/gWUJIcIFNs4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dsi-studio+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dsi-studio/CAG_QrtJx%3DXMt5uUHGZiQY%3DjXFjPONz_4q8is_%3D4EEde%2BuOeJ3w%40mail.gmail.com.

Frank Yeh

unread,
Apr 27, 2022, 11:17:58 AM4/27/22
to dsi-s...@googlegroups.com
I see your point.
This should be a quick fix and I will touch base with you soon.
Frank
> To view this discussion on the web visit https://groups.google.com/d/msgid/dsi-studio/CAKgS7KmYJBX6YFDrwi6uk8-ou0MNvfRh51A6E%3DdjjwFT_U6jYA%40mail.gmail.com.

Ian Wiggins

unread,
Apr 27, 2022, 11:20:36 AM4/27/22
to dsi-s...@googlegroups.com
Brilliant, thanks Frank. Will wait to hear from you.

All the best,

Ian

Frank Yeh

unread,
Apr 27, 2022, 11:28:50 AM4/27/22
to dsi-s...@googlegroups.com
Hi Ian,

A new build is undergoing (status:
https://github.com/frankyeh/DSI-Studio/actions/runs/2234055863). Once
completed (in an hour), you can download DSI Studio again and see if
it works for you.

Also, I am sorry for my wrong and false information: "the command
line only saves tracts in the original dMRI space."

Many times I implemented something and forgot I did it. Much
appreciated your detailed explanation to help me fix the bug.

Thank you very much!

Best regards,
Frank
> To view this discussion on the web visit https://groups.google.com/d/msgid/dsi-studio/CAKgS7Kn3BVjZHDn0-BUoS7qjMCsheEVBAiisXm_Bgq8%3DYayP%3DQ%40mail.gmail.com.

Ian Wiggins

unread,
Apr 27, 2022, 11:31:34 AM4/27/22
to dsi-s...@googlegroups.com
Great, thanks Frank. Will try it out and report back. 

Ian Wiggins

unread,
Apr 27, 2022, 12:16:12 PM4/27/22
to dsi-s...@googlegroups.com
Stupid question: how can I download the new build (Windows)? I can't find the zip file on GitHub (other than for the source code)

Frank Yeh

unread,
Apr 27, 2022, 12:56:32 PM4/27/22
to dsi-s...@googlegroups.com

Ian Wiggins

unread,
Apr 27, 2022, 1:01:49 PM4/27/22
to dsi-s...@googlegroups.com
Yep, sorry, hadn't realised that the new build would get pulled straight through to the website... :-)

Using the --ref command line option seems to work now. I got an error (copied below), although I'm not sure if it was a false alarm as the output (alignTest3.trk) exists and is readable in Matlab.

ref=aparc+aseg.nii
no transformation. running registration...
applying linear registration.
0.5 0 0 -25
0 0.5 0 -18.5946
0 0 0.5 -31.8784
saving alignTest3.trk
saving alignTest3.trk
ERROR: cannot save tracks as D:\[PATH]\alignTest3.trk. Please check write permission, directory, and disk space.

Ian Wiggins

unread,
Apr 27, 2022, 1:31:41 PM4/27/22
to dsi-s...@googlegroups.com
It's a bit of a mystery to me what's going on here.

I've run the same command a handful of times - I am no longer getting the ERROR message ('cannot save tracks...'), but the output .trk file is back in the original dMRI space again. Is it possible that there are somehow two save processes getting launched and ending up in a race condition? (hence the repeat of 'saving alignTest3.trk' in the command line output and the inconsistent results)

Frank Yeh

unread,
Apr 27, 2022, 1:33:07 PM4/27/22
to dsi-s...@googlegroups.com
No problem at all.
The error message seems not right, and I am still looking for possible bugs.
Frank
> To view this discussion on the web visit https://groups.google.com/d/msgid/dsi-studio/CAKgS7KnEBLi7oZ5d8_zofZ%3DUJDn8XV-DiKZ4_AySRznvqQLSjQ%40mail.gmail.com.

Frank Yeh

unread,
Apr 27, 2022, 1:37:22 PM4/27/22
to dsi-s...@googlegroups.com
How about saving it to a different name?
There seems to be an unfinished process using the previous versions of
DSI Studio.

Ian Wiggins

unread,
Apr 28, 2022, 5:46:10 AM4/28/22
to dsi-s...@googlegroups.com
Yes, I think you are right. Things look to have straightened out following a reboot:

no transformation. running registration...
iso loaded
MI:274795808
translocation:0.400689 -5.84046 -6.33343
rotation:-0.122021 0.0228507 0.0406832
scaling:1 1 1
shear:-3.72529e-09 1.86265e-09 2.23517e-08
applying linear registration.
0.499456 0.0203307 -0.0114243 -25.9166
-0.0215742 0.495815 -0.0608435 -8.43396
0.00885475 0.0612702 0.496153 -41.9802
saving test1.trk
Warning: --seed_plan is not used. Please check command line syntax.
Warning: --interpolation is not used. Please check command line syntax.
Warning: --random_seed is not used. Please check command line syntax.

Not sure why the three new warnings are appearing at the end - is the command line documentation on the website out of date?

Many thanks for your help!

Ian


Frank Yeh

unread,
Apr 28, 2022, 9:21:54 AM4/28/22
to dsi-s...@googlegroups.com
I am going to revise the documentation.
Frank
> To view this discussion on the web visit https://groups.google.com/d/msgid/dsi-studio/CAKgS7Km0PB1nfNoOU02x-P554d57uZdYUhuU58Br6ieLv9SKpA%40mail.gmail.com.

Ian Wiggins

unread,
Apr 28, 2022, 9:54:50 AM4/28/22
to dsi-s...@googlegroups.com
Thanks Frank, I can see the revised documentation.

Is the current operation the same as under the defaults for these removed options?
 i.e. seed_plan = 0 (subvoxel random)
       interpolation = 0 (trilinear)
       random_seed = 0 (same seed points every time)

Would there be any way of reinstating the random_seed option please? In our application, we were running fibre tracking multiple times (with random seeds) and collating the results afterwards. This will be broken if the seed points are identical for every run.

Many thanks,

Ian

Frank Yeh

unread,
Apr 28, 2022, 10:03:19 AM4/28/22
to dsi-s...@googlegroups.com
Yes, you are right. The alternatives are no longer available in DSI Studio.

About random_seed, would assigning a higher seed or tract count in the
first place work?

Frank
> To view this discussion on the web visit https://groups.google.com/d/msgid/dsi-studio/CAKgS7KnkBG2%3D137PgO3p-bv4tv8Z%2BLoSdSSG9CaFtXsECm_0Mw%40mail.gmail.com.

Ian Wiggins

unread,
Apr 28, 2022, 10:58:04 AM4/28/22
to dsi-s...@googlegroups.com
We inherited the code. I think it was originally done that way due to resource (presumably memory) constraints. I'll try running it all in a single step and see if our cluster can handle doing it all in one go.

Thanks,

Ian

Ian Wiggins

unread,
May 10, 2022, 4:53:18 AM5/10/22
to dsi-s...@googlegroups.com
Hi Frank,

Any possibility of reinstating the random_seed command line option please? Upping the track count is causing problems for us downstream. Very grateful for you giving this your consideration.

All the best,

Ian

Frank Yeh

unread,
May 10, 2022, 9:58:31 AM5/10/22
to dsi-s...@googlegroups.com
I am sorry that the function was removed so that it won't cause
consistency issues.
One quick solution is to use the older versions to get the tracts:
https://www.dropbox.com/sh/ectib64vhctkl8b/AADBRYp_aPLEuAOdNw393tO-a?dl=0
The other analysis can still use the updated version.

Sorry again for the hassle, and hope this works for you.
Frank
> To view this discussion on the web visit https://groups.google.com/d/msgid/dsi-studio/CAKgS7KnxKgBk%2Bh6%2BXasM9GrxvtFvB9pdy77br64T0U4FnW_Wiw%40mail.gmail.com.

Ian Wiggins

unread,
May 11, 2022, 1:24:11 PM5/11/22
to dsi-s...@googlegroups.com
Thanks Frank, I think we have it now by post-processing the .trk output to split it up into multiple smaller sets.

All the best,

Ian

> On 10 May 2022, at 14:58, Frank Yeh <fran...@gmail.com> wrote:
>
> I am sorry that the function was removed so that it won't cause
> To view this discussion on the web visit https://groups.google.com/d/msgid/dsi-studio/CAG_QrtJtbL-_id8SbGZ9H3xGsm9YQ1nzGtXe6bUTi1syAQyyXA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages