5ttgen fsl issues

FIRST failure

The following error messages have frequently been observed from the 5ttgen fsl script:

FSL FIRST has failed; not all structures were segmented successfully
Waiting for creation of new file "first-L_Accu_first.vtk" FSL FIRST job has been submitted to SGE; awaiting completion (note however that FIRST may fail silently, and hence this script may hang indefinitely)

Error messages that may be found in the log files within the script’s temporary directory include:

Cannot open volume first-L_Accu_corr for reading!
Image Exception : #22 :: ERROR: Could not open image first_all_none_firstseg
WARNING: NO INTERIOR VOXELS TO ESTIMATE MODE
vector::_M_range_check
terminate called after throwing an instance of 'RBD_COMMON::BaseException'
/bin/sh: line 1: 6404 Aborted /usr/local/packages/fsl-5.0.1/bin/fslmerge -t first_all_none_firstseg first-L_Accu_corr first-R_Accu_corr first-L_Caud_corr first-R_Caud_corr first-L_Pall_corr first-R_Pall_corr first-L_Puta_corr first-R_Puta_corr first-L_Thal_corr first-R_Thal_corr

These various messages all relate to the fact that this script makes use of FSL’s FIRST tool to explicitly segment sub-cortical grey matter structures, but this segmentation process is not successful in all circumstances. Moreover, there are particular details with regards to the implementation of the FIRST tool that make it awkward for the 5ttgen fsl script to invoke this tool and appropriately detect whether or not the segmentation was successful.

It appears as though a primary source of this issue is the use of FSL’s flirt tool to register the T1 image to the DWIs before running 5ttgen fsl . While this is consistent with the recommendation in the Anatomically-Constrained Tractography (ACT) documentation, there can in some instances be an unintended consequence of performing this registration step specifically with the flirt tool prior to 5ttgen fsl. With its default usage, flirt will not only register the T1 image to the DWIs, but also resample the T1 to the voxel grid of the DWIs, greatly reducing its spatial resolution. This may have a concomitant effect during the sub-cortical segmentation by FIRST: the voxel grid is so coarse that it is impossible to find any voxels that are entirely encapsulated by the surface corresponding to the segmented structure, resulting in an error within the FIRST script.

It is highly recommended that the T1 image not be resampled to the DWI voxel grid following registration: not only for the issue mentioned above, but also because ACT is explicitly designed to take full advantage of the higher spatial resolution of the T1 image. If flirt is still to be used for registration, the solution is to instruct flirt to provide a transformation matrix , rather than a translated & resampled image:

$ flirt -in T1.nii -ref DWI.nii -omat T12DWI_flirt.mat -dof 6

The transformation matrix provided by flirt should then applied to the T1 image in a manner that only influences the transformation stored within the image header, and does not resample the image to a new voxel grid:

$ transformconvert T12DWI_flirt.mat T1.nii DWI.nii flirt_import T12DWI_mrtrix.txt
$ mrtransform T1.nii T1_registered.mif -linear T12DWI_mrtrix.txt

If the T1 image provided to 5ttgen fsl has not been erroneously down-sampled, but issues are still encountered with the FIRST step, another possible cause of problems is erroneous brain extraction by bet within the internal 5ttgen fsl processing. If this is the case (which can be confirmed by examining the intermediate image files within the script scratch directory), another possible solution to try is to first obtain an accurate brain extraction (using any method of choice), and then run 5ttgen fsl using the --premasked option. This results in the registration step of FIRST being performed based on a brain-extracted template image, which in some cases may make the process more robust.


For any further issues, the only remaining recommendations are:

  • Investigate the temporary files that are generated within the script’s scratch directory, particularly the FIRST log files, and search for any indication of the cause of failure.

  • Try running the FSL run_first_all script directly on your original T1 image. Whether or not this is successful may provide some insight into whether the 5ttgen fsl is performing any image manipulation that is subsequently leading to the failure of the FSL script, or whether there are command-line options available in the run_first_all script that may be necessary for your particular data.

standard_space_roi failure

The FSL command standard_space_roi is used in the 5ttgen fsl script to constrain the image field of view to encompass the brain parenchyma / brain stem / cerebellum but not too much more. Doing so appears to make brain extraction via the FSL command bet more reliable. It can however sometimes fail, for possibly more than one reason. The underlying issue may be possible to identify by running 5ttgen fsl with the -debug option, and interrogating the resulting terminal output:

  • If standard_space_roi complains about a missing image, it is possible that the standard space template / atlas images provided with FSL are not correctly installed.

  • If standard_space_roi complains about “'NEWMAT::SingularException'”, it’s possible that your T1-weighted image is so far out of alignment with the MNI152 template image that FSL’s first command fails to achieve adequate alignment. Try checking the spatial location & orientation of your image relative to the template.

  • if you can spot “dc: command not found” near the top of the output text (i.e. before a bunch of concomitant errors further down), you need to install the Unix command “dc” on your system.