Tck2fixel segmentation fault

Dear mrtrix experts,

I’m trying to run tck2fixel (== mrview 3.0_RC3-157-gf74685cd-dirty == 64 bit release version, built May 2 2019, using Eigen 3.3.5) but I’m getting the following segmentation error:

tck2fixel: [  0%] loading template fixel directions and positions... 
tck2fixel: [SYSTEM FATAL CODE: SIGSEGV (11)] Segmentation fault: Invalid memory access

Running it the command with the -degub option showed that there is a problem when loading fixel directions (I copy only the last lines, otherwise it’s too long):

tck2fixel: [ 0%] preloading data for  "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_tck2fixel: [100%] preloading data for "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor/directions.mif"... 
tck2fixel: [DEBUG] waiting for completion of threads "loop threads"...
tck2fixel: [DEBUG] threads "loop threads" completed OK
tck2fixel: [100%] preloading data for "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor/directions.mif"
tck2fixel: [DEBUG] image "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor/directions.mif" initialised with strides = [ -1 1726175 5178525 ], start = 1726174, using direct IO
tck2fixel: [ 0%] loading template fixel directions and positions... 
tck2fixel: [SYSTEM FATAL CODE: SIGSEGV (11)] Segmentation fault: Invalid memory access

Since the problem seems to be related to directions.mif, I checked (see below) whether the file is corrupted, but apparently it’s ok:

$ mrinfo /Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor/directions.mif 
************************************************
Image:               "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor/directions.mif"
************************************************
  Dimensions:        1726175 x 3 x 1
  Voxel size:        1.14717 x 1.16143 x 1.17269
  Data strides:      [ -1 2 3 ]
  Format:            MRtrix
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1    6.24e-06    0.001396      -89.81
                         6.24e-06           1   -0.008938      -106.5
                        -0.001396    0.008938           1      -70.72
  command_history:   dwiextract "/Users/adminuser/ANE/Data/RAW_DATA/sub01/data_norm_up.mif" "/Users/adminuser/ANE/Data/RAW_DATA/sub01/temp.mif"  (version=3.0_RC3-135-g2b8e7d0c-dirty)
  [6 entries]        dwi2fod "-mask" "/Users/adminuser/ANE/Data/RAW_DATA/sub01/dwi_mask_up_Ane.mif" "msmt_csd" "/Users/adminuser/ANE/Data/RAW_DATA/sub01/temp.mif" "/Users/adminuser/ANE/Data/average_response.txt" "/Users/adminuser/ANE/Data/RAW_DATA/sub01/FOD_up_Ane.mif" "-force"  (version=3.0_RC3-135-g2b8e7d0c-dirty)
                     ...
                     tck2fixel "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/Tracts_GC_R_V5_R_PT_Excluding_R_MTa_BothDirs_iFOD2_Len_3SD_Pos_3SD.tck" "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor" "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor" "fixelmask_Tracts_GC_R_V5_R_PT_Excluding_R_MTa_BothDirs_iFOD2_Len_3SD_Pos_3SD_non_bin.mif" "-force"  (version=3.0_RC3-135-g2b8e7d0c-dirty)
                     tck2fixel "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/Tracts_GC_R_V5_R_PT_Excluding_R_MTa_BothDirs_iFOD2_Len_3SD_Pos_3SD.tck" "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor" "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor" "fixelmask_Tracts_GC_R_V5_R_PT_Excluding_R_MTa_BothDirs_iFOD2_Len_3SD_Pos_3SD_non_bin.mif" "-force"  (version=3.0_RC3-135-g2b8e7d0c-dirty)
  comments:          FSL5.0
                     resliced using warp image "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/subject2template_warp.mif"
  dwi_norm_percentile: 50
  dwi_norm_scale_factor: 31.6666698
  mrtrix_version:    3.0_RC3-135-g2b8e7d0c-dirty
  prior_dw_scheme:   -0.9999998568,0.0001827434782,0.0005029499345,1500
  [60 entries]       -0.586315455,-0.3761666457,0.7174488427,1500
                     ...
                     -0.5317686978,0.8059705331,-0.2600645147,1500
                     -0.6650152693,0.4709984681,-0.5795818619,1500

What else could I check?
Thank you

Not sure what’s going on here, but I would suggest running mrinfo on all images in the fixel directory, and checking that their dimensions all match – apart from the index.mif. It looks like one of them may have been corrupted somehow (maybe truncated due to running out of space?).

I checked for corrupted files and dimension mismatches and that doesn’t seem to be the problem…I also recomputed the files and updated mrtrix just in case and still the same…I only have 3 files (index.mif, directions.mif and fd.mif) in the directory and all seem to be fine (please see output below)

It’s really strange because I was able to run it 2-3 months ago and I was also able to run it in another subject 4 days ago. Since I was able to run it in another subject, I assumed that some files were corrupted, but now I’m not able to run it in any subject…I dont think the update to Mojave has cause this, right?..

Thank you!

$ mrinfo .../index.mif 
************************************************
Image:               "/Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor/index.mif"
************************************************
  Dimensions:        153 x 190 x 139 x 2
  Voxel size:        1.14717 x 1.16143 x 1.17269 x 1
  Data strides:      [ -2 3 4 1 ]
  Format:            MRtrix
  Data type:         unsigned 32 bit integer (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1    6.24e-06    0.001396      -89.81
                         6.24e-06           1   -0.008938      -106.5
                        -0.001396    0.008938           1      -70.72
  command_history:   dwiextract "/Users/adminuser/ANE/Data/RAW_DATA/sub01/data_norm_up.mif" "/Users/adminuser/ANE/Data/RAW_DATA/sub01/temp.mif"  (version=3.0_RC3-135-g2b8e7d0c-dirty)
  [7 entries]        dwi2fod "-mask" "/Users/adminuser/ANE/Data/RAW_DATA/sub01/dwi_mask_up_Ane.mif" "msmt_csd" "/Users/adminuser/ANE/Data/RAW_DATA/sub01/temp.mif" "/Users/adminuser/ANE/Data/average_response.txt" "/Users/adminuser/ANE/Data/RAW_DATA/sub01/FOD_up_Ane.mif" "-force"  (version=3.0_RC3-135-g2b8e7d0c-dirty)
                     ...
                     tck2fixel "/Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub01/Tracts_GC_R_V5_R_PT_Excluding_R_MTa_BothDirs_iFOD2_Len_3SD_Pos_3SD.tck" "/Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor" "/Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor" "fixelmask_Tracts_GC_R_V5_R_PT_Excluding_R_MTa_BothDirs_iFOD2_Len_3SD_Pos_3SD_non_bin.mif" "-force"  (version=3.0_RC3-157-gf74685cd-dirty)
                     tck2fixel "/Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub01/Tracts_GC_R_V5_R_PT_Excluding_R_MTa_BothDirs_iFOD2_Len_3SD_Pos_3SD.tck" "/Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor" "/Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor" "fixelmask_Tracts_GC_R_V5_R_PT_Excluding_R_MTa_BothDirs_iFOD2_Len_3SD_Pos_3SD_non_bin.mif" "-debug" "-force"  (version=3.0_RC3-159-gdfda38fd-dirty)
  comments:          FSL5.0
                     resliced using warp image "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/subject2template_warp.mif"
  dwi_norm_percentile: 50
  dwi_norm_scale_factor: 31.6666698
  mrtrix_version:    3.0_RC3-159-gdfda38fd-dirty
  nfixels:           1726175
  prior_dw_scheme:   -0.9999998568,0.0001827434782,0.0005029499345,1500
  [60 entries]       -0.586315455,-0.3761666457,0.7174488427,1500
                     ...
                     -0.5317686978,0.8059705331,-0.2600645147,1500
                     -0.6650152693,0.4709984681,-0.5795818619,1500
$ mrinfo ..../directions.mif 
************************************************
Image:               "/Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor/directions.mif"
************************************************
  Dimensions:        1726175 x 3 x 1
  Voxel size:        1.14717 x 1.16143 x 1.17269
  Data strides:      [ -1 2 3 ]
  Format:            MRtrix
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1    6.24e-06    0.001396      -89.81
                         6.24e-06           1   -0.008938      -106.5
                        -0.001396    0.008938           1      -70.72
  command_history:   dwiextract "/Users/adminuser/ANE/Data/RAW_DATA/sub01/data_norm_up.mif" "/Users/adminuser/ANE/Data/RAW_DATA/sub01/temp.mif"  (version=3.0_RC3-135-g2b8e7d0c-dirty)
  [7 entries]        dwi2fod "-mask" "/Users/adminuser/ANE/Data/RAW_DATA/sub01/dwi_mask_up_Ane.mif" "msmt_csd" "/Users/adminuser/ANE/Data/RAW_DATA/sub01/temp.mif" "/Users/adminuser/ANE/Data/average_response.txt" "/Users/adminuser/ANE/Data/RAW_DATA/sub01/FOD_up_Ane.mif" "-force"  (version=3.0_RC3-135-g2b8e7d0c-dirty)
                     ...
                     tck2fixel "/Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub01/Tracts_GC_R_V5_R_PT_Excluding_R_MTa_BothDirs_iFOD2_Len_3SD_Pos_3SD.tck" "/Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor" "/Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor" "fixelmask_Tracts_GC_R_V5_R_PT_Excluding_R_MTa_BothDirs_iFOD2_Len_3SD_Pos_3SD_non_bin.mif" "-force"  (version=3.0_RC3-157-gf74685cd-dirty)
                     tck2fixel "/Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub01/Tracts_GC_R_V5_R_PT_Excluding_R_MTa_BothDirs_iFOD2_Len_3SD_Pos_3SD.tck" "/Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor" "/Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor" "fixelmask_Tracts_GC_R_V5_R_PT_Excluding_R_MTa_BothDirs_iFOD2_Len_3SD_Pos_3SD_non_bin.mif" "-debug" "-force"  (version=3.0_RC3-159-gdfda38fd-dirty)
  comments:          FSL5.0
                     resliced using warp image "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/subject2template_warp.mif"
  dwi_norm_percentile: 50
  dwi_norm_scale_factor: 31.6666698
  mrtrix_version:    3.0_RC3-159-gdfda38fd-dirty
  prior_dw_scheme:   -0.9999998568,0.0001827434782,0.0005029499345,1500
  [60 entries]       -0.586315455,-0.3761666457,0.7174488427,1500
                     ...
                     -0.5317686978,0.8059705331,-0.2600645147,1500
                     -0.6650152693,0.4709984681,-0.5795818619,1500
$ mrinfo /Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor/fd.mif 
************************************************
Image:               "/Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor/fd.mif"
************************************************
  Dimensions:        1726175 x 1 x 1
  Voxel size:        1.14717 x 1.16143 x 1.17269
  Data strides:      [ -1 2 3 ]
  Format:            MRtrix
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1    6.24e-06    0.001396      -89.81
                         6.24e-06           1   -0.008938      -106.5
                        -0.001396    0.008938           1      -70.72
  command_history:   dwiextract "/Users/adminuser/ANE/Data/RAW_DATA/sub01/data_norm_up.mif" "/Users/adminuser/ANE/Data/RAW_DATA/sub01/temp.mif"  (version=3.0_RC3-135-g2b8e7d0c-dirty)
                     dwi2fod "-mask" "/Users/adminuser/ANE/Data/RAW_DATA/sub01/dwi_mask_up_Ane.mif" "msmt_csd" "/Users/adminuser/ANE/Data/RAW_DATA/sub01/temp.mif" "/Users/adminuser/ANE/Data/average_response.txt" "/Users/adminuser/ANE/Data/RAW_DATA/sub01/FOD_up_Ane.mif" "-force"  (version=3.0_RC3-135-g2b8e7d0c-dirty)
                     mrtransform "/Users/adminuser/ANE/Data/RAW_DATA/sub01/FOD_up_Ane.mif" "-warp" "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/subject2template_warp.mif" "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/fod_in_template_space_REORIENTED.mif" "-force"  (version=3.0_RC3-157-gf74685cd-dirty)
                     fod2fixel "-mask" "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/template_mask.mif" "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/fod_in_template_space_REORIENTED.mif" "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/fixel_in_template_space_reor" "-afd" "fd.mif" "-force"  (version=3.0_RC3-157-gf74685cd-dirty)
  comments:          FSL5.0
                     resliced using warp image "/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC_UP/sub01/subject2template_warp.mif"
  dwi_norm_percentile: 50
  dwi_norm_scale_factor: 31.6666698
  mrtrix_version:    3.0_RC3-157-gf74685cd-dirty
  prior_dw_scheme:   -0.9999998568,0.0001827434782,0.0005029499345,1500
  [60 entries]       -0.586315455,-0.3761666457,0.7174488427,1500
                     ...
                     -0.5317686978,0.8059705331,-0.2600645147,1500
                     -0.6650152693,0.4709984681,-0.5795818619,1500

I forgot to mention that I have 900GB of free space, so I don’t think I’m running out of memory…Is that what you mean?

Thank you!

Can you post the command you’ve actually invoked? Is it the same as the last entry in the command history for the directions.mif? I’m struggling to understand why your history contains two repeats of that particular command…

The command I’m invoking it’s the last in the command history, yes:

tck2fixel path/template_SC_UP/sub01/Tracts.tck path/template_SC_UP/sub01/fixel_in_template_space_reor path/template_SC_UP/sub01/fixel_in_template_space_reor fixelmask_non_bin.mif

It appears twice in the command history because I tried running it several times (with and without -debug…)

I don’t see any reason why the command should appear in the index.mif or directions.mif command history… I think that might be related to the problem, we’ll need to investigate whether there’s a bug in that command…

true…

For some reason that I cannot understand recomputing the files using the commands in the history (with new-adapted paths) solved the issue. I had already tried this with no success but today, for some reason beyond my understanding, this solved the issue.

(In the non-corrupted directions.mif the command history does not mention tck2fixel)

Thank you!!

I think I found something…The SIGSEGV (11)] Segmentation fault error appears only when using -force option. This corrupts direction.mif (+ adds the tck2fixel command in the command_history) and then won’t work even if not using the -force option.

$ tck2fixel $input_tract_file $working_tmpl_fixel_dir $working_tmpl_fixel_dir $fixelmask_nb
tck2fixel: [100%] preloading data for “/Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub08/fixel_in_template_space_reor/directions.mif”
tck2fixel: [100%] loading template fixel directions and positions
tck2fixel: [100%] mapping tracks to fixels

$ tck2fixel $input_tract_file $working_tmpl_fixel_dir $working_tmpl_fixel_dir $fixelmask_nb -force
tck2fixel: [WARNING] existing output files will be overwritten
tck2fixel: [100%] preloading data for “/Users/adminuser/ANE/PROJECTS/SC_V5_diff/Exp_Trento_Diff/3_3_Data_Analysis/ROI_Analyses/template_SC_UP/sub08/fixel_in_template_space_reor/directions.mif”

tck2fixel: [SYSTEM FATAL CODE: SIGSEGV (11)] Segmentation fault: Invalid memory access

Hope this helps!

I don’t see any reason why the command should appear in the index.mif or directions.mif command history…

I believe this will be due to the fact that like a lot of fixel-related commands, fixel input and output directories are specified explicitly at the command-line, and the input index & directions files are explicitly copied from input to output directory within the command. I’ve never liked this aspect of fixel data handling, and it’s led to issues elsewhere as well in the context of parallelisation (#1043).

@anege: Try instructing tck2fixel to write the result to a brand new fixel directory, rather than creating a new fixel data file within the existing directory.

I think there might be a bug somewhere in tck2fixel. Using a new dataset, I tried writing the results to a brand new fixel directory but I still get the same ‘Segmentation fault’ error.

user$ tck2fixel $tck $natDiff_fixel_dir $natDiff_fixel_dir_temporary $fixelimg_natDiff
tck2fixel: [100%] preloading data for "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif"
tck2fixel: [100%] loading template fixel directions and positions

tck2fixel: [SYSTEM FATAL CODE: SIGSEGV (11)] Segmentation fault: Invalid memory access

What worked was, running the same command with the same files using the -debug option:

user$ tck2fixel $tck $natDiff_fixel_dir $natDiff_fixel_dir_temporary $fixelimg_natDiff -debug
tck2fixel: [DEBUG] No config file found at "/etc/mrtrix.conf"
tck2fixel: [DEBUG] No config file found at "/export/home/agurtubay/.mrtrix.conf"
tck2fixel: [INFO] opening image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif"...
tck2fixel: [DEBUG] reading key/value file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif"...
tck2fixel: [DEBUG] sanitising image information...
tck2fixel: [INFO] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif" opened with dimensions 129x157x131x2, voxel spacing 1.3356600000000001x1.39286x1.3841600000000001x3.6000000000000001, datatype UInt32LE
tck2fixel: [DEBUG] memory-mapping file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif"...
tck2fixel: [DEBUG] file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif" mapped at 0x7f0b9bb70000, size 21225144 (read-only)
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif" loaded
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif" initialised with strides = [ -2 258 40506 1 ], start = 256, using direct IO
tck2fixel: [INFO] opening image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif"...
tck2fixel: [DEBUG] reading key/value file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif"...
tck2fixel: [DEBUG] sanitising image information...
tck2fixel: [INFO] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif" opened with dimensions 129x157x131x2, voxel spacing 1.3356600000000001x1.39286x1.3841600000000001x3.6000000000000001, datatype UInt32LE
tck2fixel: [DEBUG] memory-mapping file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif"...
tck2fixel: [DEBUG] file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif" mapped at 0x7f0b98688000, size 21225144 (read-only)
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif" loaded
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif" initialised with strides = [ -2 258 40506 1 ], start = 256, using direct IO
tck2fixel: [INFO] opening image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/index.mif"...
tck2fixel: [DEBUG] reading key/value file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/index.mif"...
tck2fixel: [DEBUG] sanitising image information...
tck2fixel: [INFO] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/index.mif" opened with dimensions 129x157x131x2, voxel spacing 1.3356600000000001x1.39286x1.3841600000000001x3.6000000000000001, datatype UInt32LE
tck2fixel: [DEBUG] memory-mapping file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/index.mif"...
tck2fixel: [DEBUG] file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/index.mif" mapped at 0x7f0b97246000, size 21225144 (read-only)
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/index.mif" loaded
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/index.mif" initialised with strides = [ -2 258 40506 1 ], start = 256, using direct IO
tck2fixel: [DEBUG] transforms_match: FOV difference in scanner coordinates: 0
tck2fixel: [DEBUG] unmapping file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/index.mif"
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/index.mif" unloaded
tck2fixel: [DEBUG] unmapping file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif"
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif" unloaded
tck2fixel: [INFO] opening image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif"...
tck2fixel: [DEBUG] reading key/value file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif"...
tck2fixel: [DEBUG] sanitising image information...
tck2fixel: [INFO] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif" opened with dimensions 129x157x131x2, voxel spacing 1.3356600000000001x1.39286x1.3841600000000001x3.6000000000000001, datatype UInt32LE
tck2fixel: [INFO] opening image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif"...
tck2fixel: [DEBUG] reading key/value file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif"...
tck2fixel: [DEBUG] sanitising image information...
tck2fixel: [INFO] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif" opened with dimensions 713200x3x1, voxel spacing 1.3356600000000001x1.39286x1.3841600000000001, datatype Float32LE
tck2fixel: [DEBUG] memory-mapping file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif"...
tck2fixel: [DEBUG] file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif" mapped at 0x7f0b99298000, size 8558400 (read-only)
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif" loaded
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif" initialised with strides = [ -1 713200 2139600 ], start = 713199, using indirect IO
tck2fixel: [INFO] opening image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/directions.mif"...
tck2fixel: [DEBUG] reading key/value file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/directions.mif"...
tck2fixel: [DEBUG] sanitising image information...
tck2fixel: [INFO] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/directions.mif" opened with dimensions 713200x3x1, voxel spacing 1.3356600000000001x1.39286x1.3841600000000001, datatype Float32LE
tck2fixel: [DEBUG] memory-mapping file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/directions.mif"...
tck2fixel: [DEBUG] file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/directions.mif" mapped at 0x7f0b98a6a000, size 8558400 (read-only)
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/directions.mif" loaded
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/directions.mif" initialised with strides = [ -1 713200 2139600 ], start = 713199, using indirect IO
tck2fixel: [DEBUG] transforms_match: FOV difference in scanner coordinates: 0
tck2fixel: [DEBUG] unmapping file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/directions.mif"
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/directions.mif" unloaded
tck2fixel: [DEBUG] unmapping file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif"
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif" unloaded
tck2fixel: [INFO] opening image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif"...
tck2fixel: [DEBUG] reading key/value file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif"...
tck2fixel: [DEBUG] sanitising image information...
tck2fixel: [INFO] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif" opened with dimensions 129x157x131x2, voxel spacing 1.3356600000000001x1.39286x1.3841600000000001x3.6000000000000001, datatype UInt32LE
tck2fixel: [INFO] opening image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif"...
tck2fixel: [DEBUG] reading key/value file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif"...
tck2fixel: [DEBUG] sanitising image information...
tck2fixel: [INFO] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif" opened with dimensions 713200x3x1, voxel spacing 1.3356600000000001x1.39286x1.3841600000000001, datatype Float32LE
tck2fixel: [DEBUG] memory-mapping file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif"...
tck2fixel: [DEBUG] file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif" mapped at 0x7f0b98a66000, size 8558400 (read-only)
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif" loaded
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif" initialised with strides = [ -1 713200 2139600 ], start = 713199, using indirect IO
tck2fixel: [DEBUG] initialising threads...
tck2fixel: [DEBUG] launching 16 threads "loop threads"...
tck2fixel: [100%] preloading data for "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif"...
tck2fixel: [DEBUG] waiting for completion of threads "loop threads"...
tck2fixel: [DEBUG] threads "loop threads" completed OK
tck2fixel: [100%] preloading data for "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif"
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif" initialised with strides = [ -1 713200 2139600 ], start = 713199, using direct IO
tck2fixel: [100%] loading template fixel directions and positions
tck2fixel: [DEBUG] unmapping file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif"
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/directions.mif" unloaded
tck2fixel: [DEBUG] reading key/value file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/R_AF_200k_Len1.5SD_Pos1.5SD.tck"...
tck2fixel: [DEBUG] initialising threads...
tck2fixel: [DEBUG] launching thread "source"...
tck2fixel: [DEBUG] launching thread "pipe"...
tck2fixel: [DEBUG] launching thread "sink"...
tck2fixel: [DEBUG] waiting for completion of thread "source"...
tck2fixel: [100%] mapping tracks to fixels
tck2fixel: [DEBUG] no writers left on queue "source->pipe"
tck2fixel: [DEBUG] thread "source" completed OK
tck2fixel: [DEBUG] waiting for completion of thread "pipe"...
tck2fixel: [DEBUG] no writers left on queue "pipe->sink"
tck2fixel: [DEBUG] no readers left on queue "source->pipe"
tck2fixel: [DEBUG] thread "pipe" completed OK
tck2fixel: [DEBUG] waiting for completion of thread "sink"...
tck2fixel: [DEBUG] no readers left on queue "pipe->sink"
tck2fixel: [DEBUG] thread "sink" completed OK
tck2fixel: [INFO] creating image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/fixelimg_R_AF.mif"...
tck2fixel: [DEBUG] sanitising image information...
tck2fixel: [DEBUG] creating empty file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/fixelimg_R_AF.mif"
tck2fixel: [DEBUG] resizing file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/fixelimg_R_AF.mif" to 2867892
tck2fixel: [DEBUG] sanitising image information...
tck2fixel: [INFO] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/fixelimg_R_AF.mif" created with dimensions 713200x1x1, voxel spacing 1.3356600000000001x1.39286x1.3841600000000001, datatype Float32LE
tck2fixel: [DEBUG] memory-mapping file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/fixelimg_R_AF.mif"...
tck2fixel: [DEBUG] "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/fixelimg_R_AF.mif" appears to reside on a networked filesystem - using delayed write-back
tck2fixel: [DEBUG] file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/fixelimg_R_AF.mif" held in RAM at 0xf1ec50, size 2852800
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/fixelimg_R_AF.mif" loaded
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/fixelimg_R_AF.mif" initialised with strides = [ 1 713200 713200 ], start = 0, using direct IO
tck2fixel: [INFO] writing back contents of mapped file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/fixelimg_R_AF.mif"...
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor_temporary/fixelimg_R_AF.mif" unloaded
tck2fixel: [DEBUG] unmapping file "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif"
tck2fixel: [DEBUG] image "/export/home/agurtubay/agurtubay/Projects/Master_Nira/3_analysis/sub-02/fixel_templ_reor/index.mif" unloaded

Hope this helps!

I’ve just tried to replicate this issue, and everything looks fine as far as I can tell. I was worried we might have an uninitialised memory issue or something like this, as I can’t understand why a -debug run would work where a non-debug one would fail. It could also be a subtle memory access issue (buffer overrun or the like), but when I run the command through the tools I have to identify such issues (valgrind, basically), I get no errors or warnings – it runs clean as far as I can tell.

I’ve also tried to see what happens when mapping to a smaller ROI than spanned by the tracks, and that also runs with no errors. All this to say, I have to idea where the problem occurs.

Maybe if you could share your input data, I could try to replicate on my system? Feel free to use whatever file-sharing service you prefer, and send your data to jdtournier@gmail.com – assuming you’re happy to do that, of course.

OK, thanks for the data, I can now reproduce the error. This was indeed a bug in our loading of tck files – you’ll note you get the same error if you try to simply use tckinfo on your input tck files. The issue is that the ROI is specified in the tck header as none, whereas the code internally expects two fields (e.g. seed mask.mif or similar). I’m not sure how these files were generated, I find it difficult to see how MRtrix would have produced tck output from no ROI (typically you have at least a seed ROI), and even if it did, I can’t see anywhere in the code that would have inserted a none ROI. Maybe these were generated from some other package…?

In any case, it’s a simple fix, but does require modification to the code. I’m going to create a pull request for it, and it’ll hopefully land in master before too long. In the meantime, this is the specific change to the code, in case you want to get on with it. You just need to edit the code by adding the lines as shown and run ./build again.

I was hoping there would be a simple way of fixing your input files, which would require no modification to the code itself, but I don’t think there is unfortunately…

Thank you for the quick response!

The tck files were generated using tckedit with inclusion and exclusion ROIs in a Whole Brain tractogram (in mrtrix). However, after that, I did a cleaning using matlab (self-made script) to remove outlier fibers whose position is more than 3 SD away from the mean position. There I used the read_mtrtrix_tracks.m and write_mrtrix_tracks.m. I suppose somewhere along that cleaning the headers were messed.

Will try to dig a bit into that and fix the issue running ./build as you suggest.

Thank you again and have a nice day,
A

1 Like

I figured out what’s going on.
I specify the ROI field as none and the command_history as none

b2.command_history=‘none’;
b2.prior_roi=‘none’;

because otherwise I cannot use write_mrtrix_tracks.m in matlab. I get this error related to being fprint not being defiend for cells:

write_mrtrix_tracks(b2, outFileName)
Error using fprintf
Function is not defined for ‘cell’ inputs.

Error in write_mrtrix_tracks (line 25)
fprintf (f, ‘%s: %s\n’, names{i}, getfield(tracks, names{i}));

Is there perhaps a quick fix to write_mrtrix_tracks.m ?

Best,
Ane

OK, things make a lot more sense now. I suspect you tried to clear these fields using something like this?

b2.command_history={};
b2.prior_roi={};

In which case, that would indeed replace the text strings the script expects with empty cell arrays, which it won’t know what to do with. I think what you want to do is to simply remove the entries altogether, which I expect can be done with something like this:

b2 = rmfield (b2, 'command_history');
b2 = rmfield (b2, 'prior_roi');

After these changes, I no longer have problems with tck2fixel.

Thanks!!

1 Like