This repository has been archived by the owner on Apr 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
params.json
1 lines (1 loc) · 9.82 KB
/
params.json
1
{"name":"Neuroimaging codes","tagline":"Pipeline for NeuroImaging","body":"##Required Programs\r\nThese are the programs that we use in this pipeline. All of these except for Mango and a batch renaming application are called from the terminal.\r\n\r\n*\t[dcm2nii](http://www.mccauslandcenter.sc.edu/mricro/mricron/dcm2nii.html)\r\n*\tANTS (nightly build: git://github.com/stnava/ANTs.git)\r\n*\tITK (nightly build: git clone git://itk.org/ITK.git )\r\n*\t[FMRIB Software Library (FSL)](http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/)\r\n*\t[Convert3D](http://www.itksnap.org/pmwiki/pmwiki.php?n=Convert3D.Documentation)\r\n*\t[R Statistical Computing Language](http://www.r-project.org)\r\n*\t[Mango](http://ric.uthscsa.edu/mango/)\r\n*\tBatch renaming application that is capable of using regular expressions (i.e., [Better Rename](http://www.publicspace.net/ABetterFinderRename/))\r\n*\tTerminal set to Bourne Again Script (bash)\r\n\r\n\r\n---\r\n\r\n##unzip .tar.gz files\r\n\r\n\tgunzip ./original/*.tar.gz\r\n\r\n\tfor i in ./original/*.tar ; do\r\n\t sudo tar xopvf $i\r\n\tdone\r\n\r\n---\r\n\r\n\r\n##Convert DICOM files to NIfTI format\r\nThis program batch converts DICOM files into NIfTI format (nii.gz). It also crops the output of neck and non brain tissues, rsulting in a file with a \"co\" prefix and also attempts to align the images to a standard orientation.\r\n\r\n\t./dcm2nii -a y -d n -e n -f n -g n -i n -p n -r n -x y ./original/*/\r\n\r\n\tfind ./original/ -type f -name co*.nii.gz -exec cp {} ./data/ \\;\r\n\r\nAt this point, rename the files with BetterRename.app or another program capable of batch renaming files using regular expressions to format names to mmu12345_Xwk.nii.gz for later steps using the following regular expression:\r\n\r\n\t(\\w{2})+(\\d{8})+(\\_)+(\\d{10})+(\\w{6})+(\\w{3})+(\\d{5})(\\d{1})+(\\w*)\r\n\r\nReplace the regular expression with (X = the age of the Subject at scan):\r\n\r\n\t\\6\\7_Xwk\r\n\t\t\r\n---\r\n\r\n##Rigid affine alignment to a template to AC-PC Align\r\nThis aligns all of the scans within the same general template space, but does not effect the size or shape of the scan being aligned to the template. However, this does **not** explicitly AC-PC align the images and does **not** change the scan origin like the acpcdetect program in the ART package.\r\n\r\n\tfor i in ./data/*.nii.gz ; do\r\n\t\tcd ./Template Directory/\r\n\t\t$ANTSPATH/ANTS 3 -m MI[<Template>.nii.gz,$(dirname $i)/$(basename $i .nii.gz).nii.gz,1,32] -o $(dirname $i)/$(basename $i .nii.gz)ACPC -i 0 --number-of-affine-iterations 1x1x1 --rigid-affine true\r\n\t\t$ANTSPATH/WarpImageMultiTransform 3 $(dirname $i)/$(basename $i .nii.gz).nii.gz $(dirname $i)/$(basename $i .nii.gz)_acpc.nii.gz $(dirname $i)/$(basename $i .nii.gz)ACPCAffine.txt -R <Template>.nii.gz\r\n\tdone\r\n\t\t\r\n---\r\n\r\n##Reslice images to .35mm isotropic resolution and set a consistent field of view\r\n\r\n\tfor i in ./data/*_acpc.nii.gz ; do\r\n\t\t./c3d $(dirname $i)/$(basename $i .nii.gz).nii.gz -interpolation Cubic -resample-mm .35x.35x.35mm -trim-to-size 256x256x256vox -verbose -o $(dirname $i)/$(basename $i .nii.gz)_resampled.nii.gz\r\n\tdone\r\n\r\n---\r\n\r\n##N4ITK Bias Field Correction\r\n\r\nThis removes the bias field generated by the magnetic inhomogeneity in the MRI scanning procedures. This is done by iteratively running the script three time with increasingly fine parameters. \r\n\r\n\tfor i in /Users/thehunsakers/Documents/MPRAGE/*/*_resampled.nii.gz ; do\r\n\t\t$ANTSPATH/N4BiasFieldCorrection -d 3 -i $(dirname $i)/$(basename $i .nii.gz).nii.gz -o $(dirname $i)/$(basename $i .nii.gz)_n4.nii.gz -s 8 -b [200] -c [50x50x50x50,0.000001]\r\n\t\t$ANTSPATH/N4BiasFieldCorrection -d 3 -i $(dirname $i)/$(basename $i .nii.gz)_n4.nii.gz -o $(dirname $i)/$(basename $i .nii.gz)_n4.nii.gz -s 4 -b [200] -c [50x50x50x50,0.000001]\r\n\t\t$ANTSPATH/N4BiasFieldCorrection -d 3 -i $(dirname $i)/$(basename $i .nii.gz)_n4.nii.gz -o $(dirname $i)/$(basename $i .nii.gz)_n4.nii.gz -s 2 -b [200] -c [50x50x50x50,0.000001]\r\n\tdone\r\n\t\r\n---\r\n\r\n##Landmark Guided Template Matching to Generate Region of Interest\r\nPlace control point landmarks of control points in the ROI located at regions of maximal anatomical variability across scans and this will take the traced, gold standard ROI in the templates folder and map it onto each scan. The guided registration script is located [Here](https://github.com/mrhunsaker/ANTS_Scripts/blob/master/guidedregistration.sh).\r\n\r\n\tfor i in ./data/*_n4.nii.gz ; do\r\n\t\tcd ./data/Template Folder/\r\n\t\tsh guidedregistration.sh <Template>.nii.gz <Template_roi>.nii.gz $(dirname $i)/$(basename $i .nii.gz).nii.gz $(dirname $i)/$(basename $i .nii.gz)_roi.nii.gz $(dirname $i)/$(basename $i .nii.gz)_OUTPUT 100x100x10 3\r\n\tdone\r\n\r\n\tfor i in ./data/*_OUTPUTSEGMENTED.nii.gz ; do\r\n\t\t./c3d $(dirname $i)/$(basename $i .nii.gz).nii.gz -binarize -o $(dirname $i)/$(basename $i .nii.gz)_binary.nii.gz\r\n\tdone\r\n\r\n---\r\n\r\n##Learning Based Wrapper to Fix Landmark Matching ROI\r\nAt this point, trace a number of primates regions of interest to be gold standard and run through the SegAdapter pipeline that uses machine learning to correct systematic errors introduced during the Landmark Guided Template Matching Step\r\n\r\n\t./bl ./data/inputIMAGEFILE.txt ./data/manualSegmentationFile.txt ./data/autoSegmentationFile.txt 1 2 4x4x4 .1 500 ./data/TRAINING/training\r\n\r\n\tfor i in ./data/*.nii.gz ; do\r\n\t\t./sa $(dirname $i)/$(basename $i .nii.gz).nii.gz $(dirname $i)/$(basename $i .nii.gz).nii.gz ./data/TRAINING/training $(dirname $i)/$(basename $i .nii.gz)_CORR.nii.gz\r\n\tdone\r\n\r\n##Compute DICE Coefficient\r\n\r\n\tfor i in ./data/*.nii.gz; do\r\n\t\tc3d -verbose -overlap 1 $(dirname $i)/$(basename $i .nii.gz).nii.gz $(dirname $i)/$(basename $i .nii.gz)_OUTPUThipp_binary.nii.gz $(dirname $i)/$(basename $i .nii.gz)_CORR.nii.gz > ./data/$(basename $i .nii.gz).txt\r\n\tdone\r\n\r\n---\r\n\r\n##Extract ROI Volumes for Analysis\r\nThis will compute the Volumes and number of Voxels contained within each region of interest for analysis.\r\n\r\n\tfind ./data/ -type f -name *_forANALYSIS.nii.gz -exec cp -fpv {} ./data/FINAL_ROI/ \\;\r\n\r\n\tfor i in $(find ./data/FINAL_ROI/ -type f -name \"_CORR.nii.gz\"); do\r\n\t\tval=$(fslval $i dim1)\r\n\t\txsize=$(echo \"$val/2\" | bc)\r\n\t\tfslroi $i $(dirname $i)/$(basename $i .nii.gz)_HPCl.nii.gz 0 $xsize 0 -1 0 -1\r\n\t\txmin=$xsize; xsize=$(echo \"$val-$xmin\" | bc)\r\n\t\tfslroi $i $(dirname $i)/$(basename $i .nii.gz)_HPCr.nii.gz $xmin $xsize 0 -1 0 -1\r\n\t\tfslmaths $(dirname $i)/$(basename $i .nii.gz)_HPCr.nii.gz -mul 2 $(dirname $i)/$(basename $i .nii.gz)_HPCr.nii.gz\r\n\t\tfslmerge -x $(dirname $i)/$(basename $i .nii.gz)_HPC.nii.gz $(dirname $i)/$(basename $i .nii.gz)_HPCr.nii.gz $(dirname $i)/$(basename $i .nii.gz)_HPCl.nii.gz\r\n\t\tc3d $(dirname $i)/$(basename $i .nii.gz)_HPC.nii.gz -split -oo $(dirname $i)/temp.nii.gz $(dirname $i)/$(basename $i .nii.gz)_HPCl.nii.gz $(dirname $i)/$(basename $i .nii.gz)_HPCr.nii.gz\r\n\tdone\r\n\r\n\tfor i in ./data/FINAL_ROI/*_forANALYSIS.nii.gz; do\r\n\t\t$FSLDIR/bin/fslstats $i -V >$(dirname $i)/$(basename $i .nii.gz).txt\r\n\tdone\r\n\r\n\tfor i in ./data/FINAL_ROI/*right.txt; do\r\n\t\tnewname=`echo \"$i\" | sed 's/_acpc_resampled_n4_OUTPUTSEGMENTED_binary_Corrected_forANALYSIS_right/_right/g'`\r\n\t\t mv \"$i\" \"$newname\"\r\n\tdone\r\n\r\n\tfor i in ./data/FINAL_ROI/*left.txt; do\r\n\t\tnewname=`echo \"$i\" | sed 's/_acpc_resampled_n4_OUTPUTSEGMENTED_binary_Corrected_forANALYSIS_left/_left/g'`\r\n\t\t mv \"$i\" \"$newname\"\r\n\tdone\r\n\r\n\tfor i in ./data/FINAL_ROI/*forANALYSIS.txt; do\r\n\t\trm -f $i\r\n\tdone\r\n\r\n\tfind ./data/FINAL_ROI/ -type f -name *.txt -exec cp -fpv {} ./data/FINAL_ROI/Volumes/ \\;\r\n\r\n---\r\n\r\n##Trim ROIs for 3D Rendering\r\nThis trims the ROIs to have a 5 voxel padding. This greatly reduces the file size as well as makes 3D visualization much more clear.\r\n\r\n\tfor i in ./data/*_Corrected.nii.gz ; do\r\n\t\t./c3d $(dirname $i)/$(basename $i) -trim 5vox -o $(dirname $i)/$(basename $i .nii.gz)_forRENDERING.nii.gz\r\n\tdone\r\n\r\n---\r\n\r\n##Organize ROI into a File using R\r\nThis script takes the region of interest volumes generated above and tabulates them in a single text file with Subject ID, Age, Left Volume, and Right \r\n\r\n\tR\r\n\trm(list = ls(all = TRUE))\r\n\tlibrary(limma)\r\n\tlibrary(reshape)\r\n\tlibrary(outliers)\r\n\tlibrary(psych)\r\n\tlibrary(doBy)\r\n\tlibrary(gdata)\r\n\tlibrary(gplots)\r\n\tlibrary(lattice)\r\n\tsetwd(\"./data/FINAL_ROI/Volumes/\")\r\n\tfiles=list.files(path=\".\", recursive=TRUE)\r\n\tall_files=data.frame(files=NULL)\r\n\tfor(i in seq(along=files))\r\n\t{\r\n\torig=read.table(files[i], header=FALSE, sep=\" \")\r\n\torig=rename(orig,c(V1=\"voxels\",V2=\"volume\"))\r\n\tall_files=rbind(all_files,orig)\r\n\t}\r\n\tall_files=subset(all_files, select=-c(V3))\r\n\tfiles=removeExt(files)\r\n\tall_files=cbind(files,all_files)\r\n\tdata=all_files\r\n\tallRIGHT=subset(data,grepl(\"_HPCr\",data$files)\r\n\tallLEFT=subset(data,grepl(\"_HPCl\",data$files))\r\n\tSubjects=allRIGHT$files\r\n\tSubjects=as.character(Subjects)\r\n\tAge=gsub(\"(\\\\w+)_(\\\\d+)(\\\\w+)\", \"\\\\2\", Subjects)\r\n\tSubjects=gsub(\"(\\\\w+)_(\\\\d+)(\\\\w+)\", \"\\\\1\", Subjects)\r\n\tR_Voxels=allRIGHT$voxels\r\n\tR_Volume=allRIGHT$volume\r\n\tL_Voxels=allLEFT$voxels\r\n\tL_Volume=allLEFT$volume\r\n\tHippocampal_Volumes=cbind(Subjects,Age,R_Volume,L_Volume)\r\n\twrite.table(Hippocampal_Volumes, file=\"./data/FINAL_ROI/Volumes/Hippocampal_ROI.txt\",sep=\",\",row.names=FALSE,col.names=TRUE)\r\n\r\n##Have yet to be implemented\r\n\r\n*\tSet up and pilot acpcdetect for primate scans\r\n*\tHistogram clipping to normalize grayscale levels\r\n*\tBrain extraction (via Atropos)\r\n*\tDBM analyses to analyze ROI change over time","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}