External Email - Use Caution        

Hi Freesurfer Developers,

I believe I found a work around for the mri_binarize error I was running into regarding the thalamic nuclei segmentation during trac-all prep as described in greater detail in my previous message (MailScanner has detected a possible fraud attempt from "secure-web.cisco.com" claiming to be https://www.mail-archive.com/freesurfer@nmr.mgh.harvard.edu/msg73324.html). I'm using FS v7.3.2 on OS Monterey, with the segmentThalamicNuclei.sh script producing the segmentation file mri/ThalamicNuclei.v13.T1.FSvoxelSpace.mgz.

From what I can tell, the error seems to arise from the following section from the trac-preproc script, specifically the line "set cmd = ($cmd `printf "--replaceonly-nn %s 11 " $ids`)":
  # Replace thalamus in main segmentation with nearest neighbor labels
    set ids = ()
    foreach label (Left-Thalamus Right-Thalamus)
      set ids = ($ids `grep -i " ${label}[ \t]" $fslut | awk '{print $1}'`)
    end

    set cmd = mri_binarize
    set cmd = ($cmd --i $fsdir/mri/$segname.mgz)
    set cmd = ($cmd `printf "--replaceonly-nn %s 11 " $ids`)
    set cmd = ($cmd --o $labdir/anatorig/${segname}+thalnuc.nii.gz)
    echo $cmd
    $cmd

I made the following edits to print the $ids for the left and right thalamus, then input those values (10 49) as the window required by --replaceonly-nn:
  # Replace thalamus in main segmentation with nearest neighbor labels
    set ids = ()
    foreach label (Left-Thalamus Right-Thalamus)
      set ids = ($ids `grep -i " ${label}[ \t]" $fslut | awk '{print $1}'`)
printf "\n \n label is $label \n \n"
printf "\n \n ids are $ids \n \n"
    end

    set cmd = mri_binarize
    set cmd = ($cmd --i $fsdir/mri/$segname.mgz)
    set cmd = ($cmd --replaceonly-nn 11 10-49)
    set cmd = ($cmd --o $labdir/anatorig/${segname}+thalnuc.nii.gz)
    echo $cmd
    $cmd

This seems to successfully circumvent the error I was previously receiving ("printf: illegal option -- -"), which resulted in a missing --replaceonly-nn command and prevented the mri_binarize output file from being created. The rest of the script then runs without error, and the final trac-all output seems to have been successful.

I'm not sure why I was receiving this printf error, but I would greatly appreciate any feedback or corrections to this potential solution. Thank you in advance for any guidance you are able to provide, and please let me know if any further information is needed.

Best,
Makenna

Makenna McGill (she/her)
Doctoral Student in Clinical Psychology
The University of Texas at Austin