Deep-MI / fsqc

A set of quality control scripts for FreeSurfer- and FastSurfer-processed structural MRI data

Home Page:https://deep-mi.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Replace all FreeSurfer calls with python

m-reuter opened this issue · comments

Feature Description

We call FreeSurfer binaries in a few places e.g. to binarize, map images, compute centroids of labels. All this can easily be implemented directly. We should drop FreeSurfer as a dependency as it is too large.

Maybe also some other dependencies can be dropped (transform3d) ?

  • lta_convert
  • mri_convert
  • mri_binarize
  • mri_vol2label
  • mri_segcentroids

Commands:

  • evaluateFornixSegmentation.py
   cmd = "mri_convert -i "+os.path.join(SUBJECTS_DIR,SUBJECT,"mri","aseg.mgz")+" -at "+os.path.join(OUTPUT_DIR,"cc_up.xfm")+" -rt nearest -o "+os.path.join(OUTPUT_DIR,"asegCCup.mgz")
   cmd = "mri_convert -i "+os.path.join(SUBJECTS_DIR,SUBJECT,"mri","norm.mgz")+" -at "+os.path.join(OUTPUT_DIR,"cc_up.xfm")+" -rt cubic -o "+os.path.join(OUTPUT_DIR,"normCCup.mgz")
   cmd = "mri_binarize --i "+os.path.join(OUTPUT_DIR,"asegCCup.mgz")+" --match 251 252 253 254 255 --dilate 2 --erode 2 --surf "+os.path.join(OUTPUT_DIR,"cc.surf")+" --surf-smooth 1 --o "+os.path.join(OUTPUT_DIR,"cc.mgz")
   cmd = "lta_convert --inlta "+os.path.join(SUBJECTS_DIR,SUBJECT,"mri","transforms","cc_up.lta")+" --outmni "+os.path.join(OUTPUT_DIR,"cc_up.xfm")    
  • evaluateHippocampalSegmentation.py
   cmd = "mri_binarize --i "+os.path.join(SUBJECTS_DIR,SUBJECT,"mri",HEMI+".hippoAmygLabels-"+LABEL+".FSvoxelSpace.mgz")+" --min 1 --surf "+os.path.join(OUTPUT_DIR,"hippocampus-"+HEMI+".surf")+" --surf-smooth 1 --o "+os.path.join(OUTPUT_DIR,"hippocampus-"+HEMI+".mgz")
   cmd = "mri_vol2label --i " + os.path.join(SUBJECTS_DIR,SUBJECT, "mri", HEMI+".hippoAmygLabels-"+LABEL+".FSvoxelSpace.mgz") + " --id " + str(i) + " --l " + os.path.join(OUTPUT_DIR, "hippocampus_labels_" + str(i) + "-"+HEMI+".txt")
   cmd = "mri_segcentroids --i " + os.path.join(SUBJECTS_DIR, SUBJECT, "mri", HEMI+".hippoAmygLabels-"+LABEL+".FSvoxelSpace.mgz") + " --o " + os.path.join(OUTPUT_DIR, "hippocampus_centroids-"+HEMI+".txt")
  • evaluateHypothalamicSegmentation.py
   cmd = "mri_binarize --i "+os.path.join(SUBJECTS_DIR,SUBJECT,"mri","hypothalamic_subunits_seg.v1.mgz")+" --match 801 802 803 804 805 806 807 808 809 810 --surf "+os.path.join(OUTPUT_DIR,"hypothalamus.surf")+" --surf-smooth 1 --o "+os.path.join(OUTPUT_DIR,"hypothalamus.mgz")
   cmd = "mri_vol2label --i " + os.path.join(SUBJECTS_DIR,SUBJECT, "mri", "hypothalamic_subunits_seg.v1.mgz") + " --id " + str(i) + " --l " + os.path.join(OUTPUT_DIR, "hypothalamus_labels_" + str(i) + ".txt")
   cmd = "mri_segcentroids --i " + os.path.join(SUBJECTS_DIR, SUBJECT, "mri", "hypothalamic_subunits_seg.v1.mgz") + " --o " + os.path.join(OUTPUT_DIR, "hypothalamus_centroids.txt")

The above freesurfer programs have been replaced by custom implementation or functions from e.g. the scipy package. Changes live now in the dev branch and have undergone initial testing. They will be subject to more comprehensive testing prior to release of version 2.0, and will eventually be merged into the stable branch, which is the future default branch.

OK, see #35

This has been merged now, which closes the issue.