Problems running labelsgmfix

Hi,

I am running the labelsgmfix script as follows:

labelsgmfix ${subj}_parcels.mif ${subj}_T1.nii.gz fs_default.txt ${subj}_parcels_fixSGM.mif -premasked

whereby
${subj}_parcels.mif = is the output image from labelconvert
${subj}_T1.nii.gz = the original T1.mgz from the freesurfer parcellation

It seems to be running fine and all the files seem to be generated in the tempdir, but I keep getting the following error:

Command: mrcalc parc.mif 0 -min sgm.mif
Traceback (most recent call last):
  File "/usr/local/bin/labelsgmfix", line 88, in <module>
    with open(sgm_lut_file_path) as f:
IOError: [Errno 2] No such file or directory: '/usr/local/bin/data/FreeSurferSGM.txt'

I’d really appreciate if you could help with this!

Cheers, Lena

Hi Lena,

This looks to be either a softlinking problem, or a copy-and-paste-script-file problem.

The script is searching in a fixed location relative to its own location in order to find the data file it requires. The labelsgmfix script is located in /usr/local/bin; from here, it is going down one directory, into “data/”, and expecting to find the text file there. So either:

  • You have created a softlink to the actual location of labelsgmfix within /usr/local/bin, but the script is erroneously searching relative to the location of the softlink rather than the actual file;

  • You have created a hard copy of labelsgmfix within /usr/local/bin, in which case the script has no plausible way of determining the location of that file.

The former I can fix; though it looks like you’re using MRtrix3 version 0.3.15, so if you were to execute a pull request you’re going to get a whole lot of other changes. For the latter, although I could have the script give a more meaningful error, there is simply no possible “fix”; though I will note that some of the changes we made in the 3.0_RC1 update were to alter the overall structure of the code repository in order to simplify packaging the software for direct installation to more “default” locations such as /usr/local/.

The quick fix is to invoke the labelsgmfix script wherever it resides in the MRtrix3 installation, rather than a softlink or copy thereof.

Rob

Thanks, Rob.

I reinstalled mrtrix and it’s working now…

Cheers, Lena