===========================================================

When using this code please cite the paper:
S. Roy, Q. He, E. Sweeney, A. Carass, D. S. Reich, J.L. Prince, and D. L. Pham,
``Subject-Specific Sparse Dictionary Learning for Atlas-Based Brain MRI Segmentation'', 
IEEE Journal of Biomedical and Health Informatics, 19(5):1598-1609, 2015.

http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=7114201

DOI: 10.1109/JBHI.2015.2439242
===========================================================


1) Please download Matlab Compiler Runtime v8.1 for 64bit Linux from Mathworks:
http://www.mathworks.com/supportfiles/MCR_Runtime/R2013a/MCR_R2013a_glnxa64_installer.zip

Unzip it and install it in a suitable directory. Currently this code only works on 64-bit Linux.
The script also requires FSL, ANTs and AFNI to be installed and their binaries included in $PATH.


2) Open these four scripts run_hallucination_v15.sh, fix_memberships.sh, run_make_memberships_from_seg.sh, 
and run_SparseDictionaryLearn.sh. Change the MCRROOT variable inside each of the script to the 
installed v81 directory.


3) The subject (as well as the atlas) T1-w images must be preprocessed,
    a) skull-stripped (We recommend MONSTR http://www.nitrc.org/projects/monstr)
    b) N4 corrected to remove any intensity inhomogeneity
   
   
4) Make one directory containing the atlas image and its segmentation with the following names,
    atlas.nii, 
    atlas_seg.nii
    
The segmentation should have discreet labels, with background as zero. An atlas with 10-class
segmentation is provided with this tool. Parts of the code is optimized for 10 classes, the same 
classes as the TOADS-CRUISE (http://www.nitrc.org/projects/toads-cruise). TOADS tissue classes are,
SulcalCSF       (label 5)
Ventricles      (label 6)
CerebellarGM    (label 14)
CerebralGM      (label 15)
Caudate         (label 16)
Thalamus        (label 17)
Putamen         (label 18)
Brainstem       (label 22)
CerebellarWM    (label 24)
CerebralWM      (label 25)


6) The main script is S3DL_nolesion.sh. It requires preprocessed images as described above. 

 Example usage:
 ./S3DL_nolesion.sh data/T1_stripped_N4Corrected.nii atlas/ 10 3x3x3 12 classification ./ false
 
 
 
