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.