Edit tck header to make tckedit -maxlength work


#1

Dear Mrtrix experts,

I am trying to run the tckedit command with -maxlength option:

tckedit WB_tractogram.tck -include ROI1.nii.gz -include ROI2.nii.gz -maxlength 100 OUTPUT.tck -force

The problem is that this works with a whole brain tractogram (WB_sift.tck) file but not with another (WB_scil.tck).

When I run the previous command with “WB_sift.tck”, everything works fine: when I visualize the fibers, none of them exceeds the 100mm length.

However, when I run the same command with “WB_scil.tck”, I dont get any error but when I visualize the fibers, some of them are 130mm-long. So the maxlength option is not working.

I checked the difference between both tractograms and the main difference is the header information:

For WB_sift.tck (this is the one that works):

tckinfo WB_sift.tck


Tracks file: “/Users/adminuser/Desktop/ANE/Data/RAW_DATA/sub01/WB_sift.tck”
SIFT_mu: 0.0023769219808288207
act: sub_1/T1/5tt.nii
backtrack: 1
count: 1000000
crop_at_gmwmi: 1
downsample_factor: 3
fod_power: 0.25
init_threshold: 0.100000001
lmax: 6
max_angle: 45
max_dist: 200
max_num_attempts: 12530000
max_num_tracks: 12530000
max_seed_attempts: 5000
max_trials: 1000
method: iFOD2
min_dist: 2.29045677
mrtrix_version: 0.3.15-14-gfe1c8fff
output_step_size: 0.572614193
rk4: 0
samples_per_step: 4
sh_precomputed: 1
source: sub_1/DWI/FOD.mif
step_size: 0.572614193
stop_on_all_include: 0
threshold: 0.100000001
timestamp: 1488294706.9555587769
total_count: 10541097
unidirectional: 0
ROI: seed sub_1.mif

And for WB_scil.tck (the one not working):

tckinfo WB_sift.tck


Tracks file: “/Users/adminuser/Desktop/ANE/Data/RAW_DATA/sub01/WB_scil.tck”
count: 10541097
mrtrix_version: 0.3.15-14-gfe1c8fff
timestamp: 1490172345.8748898506
total_count: 10541097

Could this problem be related to the fact that there is no stepsize information in the header? How could I add info to the header of tck files? (mrconvert allows adding header info to .mif files but I dont think there is an analog for tck files)

Thank you and congratulations for your work. It is really helpful for a lot of people


#2

I continued trying to fix the problem and I found out that apparently, the header has nothing to do with the misbehavior:
I over wrote the header of the WB_sift.tck file to make it useless (despite maintaining datatype and file keys). Then I runned tckedit -maxlength, and keeps working…

If the header is not the issue why would tckedit -maxlength work properly with a file and not the other? Any suggestions?


#3

Hi @anege,

Firstly, can you provide the output of tckedit -version? I seem to recall there’s been issues in the past around filtering tracks based on length that have since been fixed.

The difference in the presence of step size information in the header will definitely have an effect, but up-to-date code should be robust against this, assuming that the distance between streamline vertices is in fact constant; on review, if there’s a variable distance between vertices, this will cause issues with the current tckedit code. This may be an area where I need to sacrifice speed for accuracy. So it depends in part on the source of the second file, which was presumably generated by a tool outside of MRtrix3.

How could I add info to the header of tck files?

While the .tck format could conceivably have an analogue to the MRtrix3 .mih image format, i.e. have the header information in a text-editor-friendly file and the raw data in a second file, this has simply never been implemented. So one is stuck using a hex editor to modify the header contents if necessary. It’s crucial though that the contents of the “file: . #” entry remain accurate with respect to where the raw data begins within the file.


If there’s no answer here, you can send me some example data (preferably with less tracks in them!) to look at.

Rob