Skip to end of metadata
Go to start of metadata

20130225 - Description of Notes

Table of Contents

Notes on Atropos From Publication( 2011 Neuroinfomatics)

Avants et al._2008_Medical image analysis.pdf

Brainweb Application:

  • Sequential Processing of N4 and Atropos
  • 40% RF with 3% noise
  • Beta of MRF = 0.2
  • Initial K-Means K=3
  • With Brian Mask

"The multivariate segmentation result, in combination with the low PD segmentation performance, suggests PD and T1 provide complementary information that may improve 3-tissue segmentation and serves to validate the multivariate Atropos implementation. In this case, the benefit is likely to derive from the fact that the PD image has no bias"

 

5. Atropos Trial on BSD with brain mask from BABC

Directory:

/IPLlinux/hjohnson/HDNI/20130125_BRAINSABC_Publication/Atropos_brainweb

Script:

brainWebDir=/hjohnson/HDNI/brainweb/
mask=/IPLlinux/hjohnson/HDNI/20130125_BRAINSABC_Publication/Atropos_brainweb/brainMask.nii.gz
for pn in pn0 pn1 pn3 pn5 pn7 pn9
do
    for rf in rf0 rf20 rf40
    do
        inputDir="$brainWebDir/"
        t1="$inputDir/T1_ai_msles2_1mm_${pn}_${rf}.nii"
        t2="$inputDir/T2_ai_msles2_1mm_${pn}_${rf}.nii"

        outputDir="/hjohnson/HDNI/20130125_BRAINSABC_Publication/Atropos_brainweb/Image_1mm_${pn}_${rf}_T1T2"
        mkdir  -p $outputDir
        cd $outputDir
        time Atropos -d 3 \
            -a $t1 \
            -a $t2 \
            --mask-image ${mask} \
            -i KMeans[3] \
            -k Gaussian  \
            -m [0.3,1x1x1] \
            -g [1,1] \
            -c [5,0.000001] \
            -p Socrates[1] \
            -o [LabelImage.nii.gz,POSTERIOR_%02d.nii.gz] \
            |tee logger 2>&1
        wait
        cd /hjohnson/HDNI/20130125_BRAINSABC_Publication/Atropos_brainweb/
    done
done
~                   

Brain mask is created by thresholding brain_seg label from BRAINS ABC. (CHEATING!?)

import SimpleITK as sitk
image = sitk.ReadImage( "../BRAINSABC_brainweb/Image_1mm_pn3_rf0/brain_label_seg.nii.gz" )
binary = sitk.BinaryThreshold( image, 1, 255 )
binary = sitk.BinaryFillhole( binary, False )
sitk.WriteImage( binary, "./brainMask.nii.gz" )

Resut:

Similarity Index

Hausdorrf Distance

As they mentioned in their paper, yes multi-modality does not really helpful in their setting.

I have not succeeded with Prior initialization.

 

4. Data Delievery to Nict Tustison for Consult

From Attemp3

Directory:

/IPLlinux/hjohnson/HDNI/20130125_BRAINSABC_Publication/AtroposTest/BigTestFromHans_WithSyn_MRF0.05_data2/ToNictTustison

ZipFile:

/hjohnson/HDNI/20130125_BRAINSABC_Publication/AtroposTest/BigTestFromHans_WithSyn_MRF0.05_data2/atroposTrial20130208.tar.gz

Script:

AToS="../data2/atlas_to_subject.h5"
PREFIX="/hjohnson/HDNI/20130125_BRAINSABC_Publication/AtroposTest/data2"
## inputs
TEMPLATE="${PREFIX}/Cropped_BCD_ACPC_Aligned.nii.gz"
time Atropos -d 3 \
  ${REG_IMAGES} \
  -a ./IntraSubjecRegister/Cropped_BCD_ACPC_Aligned_fixed.nii.gz \
  -a ./IntraSubjecRegister/288066870_288066870_20100622_30_T1-30_3_fixed.nii.gz \
  -a ./IntraSubjecRegister/288066870_288066870_20100622_30_T2-30_4_fixed.nii.gz \
  --mask-image ./IntraSubjecRegister/Cropped_BCD_ACPC_Aligned_roi.nii.gz\
  -i PriorProbabilityImages[17,./priorProbImages%02d.nii.gz,0.9,0.0001] \
   -k Gaussian  \
   -m [0.05,1x1x1] \
   -g [1,1] \
   -c [5,0.000001] \
   -p Socrates[1] \
   -o [LabelImage.nii.gz,POSTERIOR_%02d.nii.gz] \
   |tee logger 2>&1

 

 

3. Same Attempt to (2) but with SIEMENS data

Similar failure: Bright center of brain resulting in extended white matter

Data Info

fileList="/nfsscratch/PREDICT/hjohnson/TrackOn/Experiments/20130109_TrackOn_CACHE/288066870/BAW_20120813/WF_288066870_288066870_20100622_30_HDNI_001_PHASE_1/TissueClassify/BABC/atlas_to_subject.h5 \
/nfsscratch/PREDICT/hjohnson/TrackOn/Experiments/20130109_TrackOn_CACHE/288066870/BAW_20120813/WF_288066870_288066870_20100622_30_HDNI_001_PHASE_1/TissueClassify/BABC/atlas_to_subject_Inverse.h5 \
/nfsscratch/PREDICT/hjohnson/TrackOn/Experiments/20130109_TrackOn_CACHE/288066870/BAW_20120813/WF_288066870_288066870_20100622_30_HDNI_001_PHASE_1/LandmarkInitialize/BLI/landmarkInitializer_atlas_to_subject_transform.h5 \
/nfsscratch/PREDICT/hjohnson/TrackOn/Experiments/20130109_TrackOn_CACHE/288066870/BAW_20120813/WF_288066870_288066870_20100622_30_HDNI_001_PHASE_1/LandmarkInitialize/BROIAuto_cropped/Cropped_BCD_ACPC_Aligned.nii.gz \
/nfsscratch/PREDICT/hjohnson/TrackOn/HDNI_001/288066870/288066870_20100622_30/ANONRAW/288066870_288066870_20100622_30_T1-30_3.nii.gz \
/nfsscratch/PREDICT/hjohnson/TrackOn/HDNI_001/288066870/288066870_20100622_30/ANONRAW/288066870_288066870_20100622_30_T2-30_4.nii.gz \
"

for file in $fileList
do
targetFilename=(`basename $file`)
rsync helium.hpc.uiowa.edu:$file $targetFilename
done

 

 

2. Attempt with SyN Atlas to Subject Registration with 17 Priors

Below image is what I got from this trial. In general, images are real bright. I have to adjust constrast to see differecces in white and grey matter. It seems like Atropos made real bright sub-cortical area than surface, and saying all the center tissue is whiate matter.

How should I adjust?!

 

 

Data: (Phillps data- bad choice as a trial..)

fileList="/nfsscratch/PREDICT/hjohnson/TrackOn/Experiments/20130109_TrackOn_CACHE/349964982/BAW_20120813/WF_349964982_349964982_20090629_30_HDNI_004_PHASE_1/TissueClassify/BABC/atlas_to_subject.h5 \
  /nfsscratch/PREDICT/hjohnson/TrackOn/Experiments/20130109_TrackOn_CACHE/349964982/BAW_20120813/WF_349964982_349964982_20090629_30_HDNI_004_PHASE_1/TissueClassify/BABC/atlas_to_subject_Inverse.h5 \
  /nfsscratch/PREDICT/hjohnson/TrackOn/Experiments/20130109_TrackOn_CACHE/349964982/BAW_20120813/WF_349964982_349964982_20090629_30_HDNI_004_PHASE_1/LandmarkInitialize/BLI/landmarkInitializer_atlas_to_subject_transform.h5 \
  /nfsscratch/PREDICT/hjohnson/TrackOn/Experiments/20130109_TrackOn_CACHE/349964982/BAW_20120813/WF_349964982_349964982_20090629_30_HDNI_004_PHASE_1/LandmarkInitialize/BROIAuto_cropped/Cropped_BCD_ACPC_Aligned.nii.gz \
  /nfsscratch/PREDICT/hjohnson/TrackOn/HDNI_004/349964982/349964982_20090629_30/ANONRAW/349964982_349964982_20090629_30_T1-30_601.nii.gz \
  /nfsscratch/PREDICT/hjohnson/TrackOn/HDNI_004/349964982/349964982_20090629_30/ANONRAW/349964982_349964982_20090629_30_T2-30_801.nii.gz \
  "
for file in $fileList
do
  targetFilename=(`basename $file`)
  rsync helium.hpc.uiowa.edu:$file $targetFilename
done

 

Script:

AToS="../data/atlas_to_subject.h5"
PREFIX="/hjohnson/HDNI/20130125_BRAINSABC_Publication/AtroposTest/data"
## inputs
TEMPLATE="${PREFIX}/Cropped_BCD_ACPC_Aligned.nii.gz"
ALLIAMGES=" ${PREFIX}/Cropped_BCD_ACPC_Aligned.nii.gz  ${PREFIX}/349964982_349964982_20090629_30_T1-30_601.nii.gz ${PREFIX}/349964982_349964982_20090629_30_T2-30_801.nii.gz"
BASEDIR=.
SAFETYMARGIN=13
PHASE1_DIR=${BASEDIR}/IntraSubjecRegister
mkdir -p ${PHASE1_DIR}
REG_IMAGES=""
for i in $(echo $ALLIAMGES); do
  MOVING=$i
  OUTPUT=${PHASE1_DIR}/$(basename ${i//.nii.gz/_fixed.nii.gz})
  OUTPUTMASK=${PHASE1_DIR}/$(basename ${TEMPLATE//.nii.gz/_roi.nii.gz})
  if [ ! -f ${OUTPUT} ] || [ ! -f ${OUTPUTMASK} ]; then
    BRAINSFit \
      --fixedVolume  ${TEMPLATE} \
      --movingVolume ${MOVING} \
      --initializeTransformMode useCenterOfHeadAlign \
      --useRigid \
      --outputVolumePixelType short \
      --backgroundFillValue 0.0 \
      --maskInferiorCutOffFromCenter 65.0 \
      --interpolationMode Linear \
      --maskProcessingMode ROIAUTO \
      --medianFilterSize 1,1,1 \
      --debugLevel 0 \
      --ROIAutoDilateSize ${SAFETYMARGIN} \
      --outputVolume ${OUTPUT} \
      --outputFixedVolumeROI ${OUTPUTMASK}
      if [ $? -ne 0 ]; then
          echo "FAILURE"
          exit -1;
      fi
  fi
  REG_IMAGES="${REG_IMAGES} -a ${OUTPUT}"
done
let counter=1;
for probMap in \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_AIR.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_ACCUMBEN.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_CAUDATE.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_CRBLGM.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_CRBLWM.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_CSF.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_GLOBUS.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_HIPPOCAMPUS.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_NOTCSF.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_NOTGM.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_NOTVB.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_NOTWM.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_PUTAMEN.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_SURFGM.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_THALAMUS.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_VB.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_WM.nii.gz; do \
  if [ $counter -eq 1 ]; then
     BGVALUE=1;
  else
     BGVALUE=0;
  fi
  OUTPROB=$(printf "${BASEDIR}/priorProbImages%02d.nii.gz" ${counter})
  if [ ! -f ${OUTPROB} ]; then
    BRAINSResample \
      --inputVolume ${probMap} \
      --referenceVolume ${TEMPLATE} \
      --outputVolume ${OUTPROB} \
      --warpTransform ${AToS} \
      --defaultValue ${BGVALUE}
      if [ $? -ne 0 ]; then
          echo "FAILURE"
          exit -1;
      fi
  fi
  let counter+=1
done

time Atropos -d 3 \
  ${REG_IMAGES} \
  --mask-image ${OUTPUTMASK} \
  -i PriorProbabilityImages[17,./priorProbImages%02d.nii.gz,0.9,0.0001] \
   -k Gaussian  \
   -m [0.05,1x1x1] \
   -g [1,1] \
   -c [5,0.000001] \
   -p Socrates[1] \
   -o [LabelImage.nii.gz,POSTERIOR_%02d.nii.gz] \
   |tee logger 2>&1


 

 

1. Attempt with Big Test

Attempt with Big Test from Hans and Nick Tustison's test ( a while ago, Thank you Jess for finding this! )

1-A. Original Script

Orignal Directory: /hjohnson/HDNI/EXPERIEMENTS/AtroposBigTest/AtroposRun.sh

1. Input Description 
TEMPLATE="${PREFIX}/Stage1/3DSPGR_0_COR_ACPC.nii.gz"
ALLIAMGES=" ${PREFIX}/Stage1/3DSPGR_0_COR_ACPC.nii.gz ${PREFIX}/Stage1/3DSPGR_1_COR_ACPC_InPlace.nii.gz ${PREFIX}/Stage1/3DSPGR_2_COR_ACPC_InPlace.nii.gz ${PREFIX}/Stage1/T2_0_COR_ACPC_InPlace.nii.gz ${PREFIX}/Stage1/T2_1_COR_ACPC_InPlace.nii.gz"
BASEDIR=.
source ~/src/BRAINS3-Darwin-SuperBuildTest/src/bin/brains3_setup.sh
2. Start with Rigid trasnformation intersubject images
SAFETYMARGIN=3
PHASE1_DIR=${BASEDIR}/IntraSubjecRegister
mkdir -p ${PHASE1_DIR}
REG_IMAGES=""
for i in $(echo $ALLIAMGES); do
  MOVING=$i
  OUTPUT=${PHASE1_DIR}/$(basename ${i//.nii.gz/_fixed.nii.gz})
  OUTPUTMASK=${PHASE1_DIR}/$(basename ${TEMPLATE//.nii.gz/_roi.nii.gz})
  if [ ! -f ${OUTPUT} ] || [ ! -f ${OUTPUTMASK} ]; then
    BRAINSFit \
      --fixedVolume  ${TEMPLATE} \
      --movingVolume ${MOVING} \
      --initializeTransformMode useCenterOfHeadAlign \
      --useRigid \
      --outputVolumePixelType short \
      --backgroundFillValue 0.0 \
      --maskInferiorCutOffFromCenter 65.0 \
      --interpolationMode Linear \
      --maskProcessingMode ROIAUTO \
      --medianFilterSize 1,1,1 \
      --debugLevel 0 \
      --ROIAutoDilateSize ${SAFETYMARGIN} \
      --outputVolume ${OUTPUT} \
      --outputFixedVolumeROI ${OUTPUTMASK}
      if [ $? -ne 0 ]; then
          echo "FAILURE"
          exit -1;
      fi
  fi
  REG_IMAGES="${REG_IMAGES} -a ${OUTPUT}"
done
3. Atlas to Subject BSpline Registration
PHASE2_DIR=${BASEDIR}/AtlasSubjecRegister
mkdir -p ${PHASE2_DIR}
AToS=${PHASE2_DIR}/AtlasToSub.mat
ATLAS=/raid0/homes/hjohnson/src/BRAINS3-Darwin-SuperBuildTest/src/bin/Atlas/Atlas_20101105/avg_t1.nii.gz
if [ ! -f ${AToS} ]; then
  BRAINSFit \
    --fixedVolume ${TEMPLATE} \
    --movingVolume ${ATLAS} \
    --initializeTransformMode useCenterOfHeadAlign \
    --useRigid \
    --useScaleVersor3D \
    --useScaleSkewVersor3D \
    --useAffine \
    --useBSpline \
    --outputVolumePixelType short \
    --numberOfSamples 10000 \
    --splineGridSize 24,24,24 \
    --maxBSplineDisplacement 10.0 \
    --backgroundFillValue 0.0 \
    --maskInferiorCutOffFromCenter 65.0 \
    --interpolationMode Linear \
    --maskProcessingMode ROIAUTO \
    --medianFilterSize 1,1,1 \
    --numberOfHistogramBins 50 \
    --numberOfMatchPoints 10 \
    --ROIAutoDilateSize 3.0 \
    --bsplineTransform ${AToS}
      if [ $? -ne 0 ]; then
          echo "FAILURE"
          exit -1;
      fi
fi
4. Warp Priors to Subject Space
let counter=1;
for probMap in \
  /raid0/homes/hjohnson/src/BRAINS3-Darwin-SuperBuildTest/src/bin/Atlas/Atlas_20101105/AIR_prob.nii.gz \
  /raid0/homes/hjohnson/src/BRAINS3-Darwin-SuperBuildTest/src/bin/Atlas/Atlas_20101105/BGM_prob.nii.gz \
  /raid0/homes/hjohnson/src/BRAINS3-Darwin-SuperBuildTest/src/bin/Atlas/Atlas_20101105/CSF_prob.nii.gz \
  /raid0/homes/hjohnson/src/BRAINS3-Darwin-SuperBuildTest/src/bin/Atlas/Atlas_20101105/GM_prob.nii.gz \
  /raid0/homes/hjohnson/src/BRAINS3-Darwin-SuperBuildTest/src/bin/Atlas/Atlas_20101105/NOTCSF_prob.nii.gz \
  /raid0/homes/hjohnson/src/BRAINS3-Darwin-SuperBuildTest/src/bin/Atlas/Atlas_20101105/NOTGM_prob.nii.gz \
  /raid0/homes/hjohnson/src/BRAINS3-Darwin-SuperBuildTest/src/bin/Atlas/Atlas_20101105/NOTVB_prob.nii.gz \
  /raid0/homes/hjohnson/src/BRAINS3-Darwin-SuperBuildTest/src/bin/Atlas/Atlas_20101105/NOTWM_prob.nii.gz \
  /raid0/homes/hjohnson/src/BRAINS3-Darwin-SuperBuildTest/src/bin/Atlas/Atlas_20101105/VB_prob.nii.gz \
  /raid0/homes/hjohnson/src/BRAINS3-Darwin-SuperBuildTest/src/bin/Atlas/Atlas_20101105/WM_prob.nii.gz ; do
  if [ $counter -eq 1 ]; then
     BGVALUE=1;
  else
     BGVALUE=0;
  fi
  OUTPROB=$(printf "${PHASE2_DIR}/priorProbImages%02d.nii.gz" ${counter})
  if [ ! -f ${OUTPROB} ]; then
    BRAINSResample \
      --inputVolume ${probMap} \
      --referenceVolume ${TEMPLATE} \
      --outputVolume ${OUTPROB} \
      --warpTransform ${AToS} \
      --defaultValue ${BGVALUE}
      if [ $? -ne 0 ]; then
          echo "FAILURE"
          exit -1;
      fi
  fi
  let counter+=1
done

5. Run Atropos
time /scratch/johnsonhj/src/ANTS-Darwin-Build/Atropos -d 3 \
  ${REG_IMAGES} \
  --mask-image ${OUTPUTMASK} \
  -i PriorProbabilityImages[10,./AtlasSubjecRegister/priorProbImages%02d.nii.gz,0.9,0.0001] \
   -k Gaussian  \
   -m [0.2,1x1x1] \
   -g [1,1] \
   -c [5,0.000001] \
   -p Socrates[1] \
   -o [LabelImage.nii.gz,POSTERIOR_%02d.nii.gz] \
   |tee logger 2>&1

 

1-B. My Trial

Script: 

Change input information

PREFIX="/hjohnson/HDNI/20130125_BRAINSABC_Publication/AtroposTest/"
TEMPLATE="${PREFIX}/subject_t1_01.nii.gz"
ALLIAMGES=" ${PREFIX}/subject_t1_01.nii.gz  ${PREFIX}/subject_t1_02.nii.gz ${PREFIX}/subject_t2_01.nii.gz"
BASEDIR=.

Unchanged part

Did not changed
SAFETYMARGIN=3
PHASE1_DIR=${BASEDIR}/IntraSubjecRegister
mkdir -p ${PHASE1_DIR}
REG_IMAGES=""
for i in $(echo $ALLIAMGES); do
  MOVING=$i
  OUTPUT=${PHASE1_DIR}/$(basename ${i//.nii.gz/_fixed.nii.gz})
  OUTPUTMASK=${PHASE1_DIR}/$(basename ${TEMPLATE//.nii.gz/_roi.nii.gz})
  if [ ! -f ${OUTPUT} ] || [ ! -f ${OUTPUTMASK} ]; then
    BRAINSFit \
      --fixedVolume  ${TEMPLATE} \
      --movingVolume ${MOVING} \
      --initializeTransformMode useCenterOfHeadAlign \
      --useRigid \
      --outputVolumePixelType short \
      --backgroundFillValue 0.0 \
      --maskInferiorCutOffFromCenter 65.0 \
      --interpolationMode Linear \
      --maskProcessingMode ROIAUTO \
      --medianFilterSize 1,1,1 \
      --debugLevel 0 \
      --ROIAutoDilateSize ${SAFETYMARGIN} \
      --outputVolume ${OUTPUT} \
      --outputFixedVolumeROI ${OUTPUTMASK}
      if [ $? -ne 0 ]; then
          echo "FAILURE"
          exit -1;
      fi
  fi
  REG_IMAGES="${REG_IMAGES} -a ${OUTPUT}"
done
PHASE2_DIR=${BASEDIR}/AtlasSubjecRegister
mkdir -p ${PHASE2_DIR}
AToS=${PHASE2_DIR}/AtlasToSub.mat
ATLAS=/ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/template_t1.nii.gz
if [ ! -f ${AToS} ]; then
  BRAINSFit \
    --fixedVolume ${TEMPLATE} \
    --movingVolume ${ATLAS} \
    --initializeTransformMode useCenterOfHeadAlign \
    --useRigid \
    --useScaleVersor3D \
    --useScaleSkewVersor3D \
    --useAffine \
    --useBSpline \
    --outputVolumePixelType short \
    --numberOfSamples 10000 \
    --splineGridSize 24,24,24 \
    --maxBSplineDisplacement 10.0 \
    --backgroundFillValue 0.0 \
    --maskInferiorCutOffFromCenter 65.0 \
    --interpolationMode Linear \
    --maskProcessingMode ROIAUTO \
    --medianFilterSize 1,1,1 \
    --numberOfHistogramBins 50 \
    --numberOfMatchPoints 10 \
    --ROIAutoDilateSize 3.0 \
    --bsplineTransform ${AToS}
      if [ $? -ne 0 ]; then
          echo "FAILURE"
          exit -1;
      fi
fi

Update Atlas to Recent Ones

let counter=1;
for probMap in \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_ACCUMBEN.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_AIR.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_CAUDATE.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_CRBLGM.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_CRBLWM.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_CSF.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_GLOBUS.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_HIPPOCAMPUS.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_NOTCSF.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_NOTGM.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_NOTVB.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_NOTWM.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_PUTAMEN.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_SURFGM.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_THALAMUS.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_VB.nii.gz \
  /ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/ReferenceAtlas-build/Atlas/Atlas_20130106/EXTENDED_WM.nii.gz; do \
  if [ $counter -eq 1 ]; then
     BGVALUE=1;
  else
     BGVALUE=0;
  fi
  OUTPROB=$(printf "${PHASE2_DIR}/priorProbImages%02d.nii.gz" ${counter})
  if [ ! -f ${OUTPROB} ]; then
    BRAINSResample \
      --inputVolume ${probMap} \
      --referenceVolume ${TEMPLATE} \
      --outputVolume ${OUTPROB} \
      --warpTransform ${AToS} \
      --defaultValue ${BGVALUE}
      if [ $? -ne 0 ]; then
          echo "FAILURE"
          exit -1;
      fi
  fi
  let counter+=1
done

Unchanged Atropos Part

time /scratch/johnsonhj/src/ANTS-Darwin-Build/Atropos -d 3 \
  ${REG_IMAGES} \
  --mask-image ${OUTPUTMASK} \
  -i PriorProbabilityImages[10,./AtlasSubjecRegister/priorProbImages%02d.nii.gz,0.9,0.0001] \
   -k Gaussian  \
   -m [0.2,1x1x1] \
   -g [1,1] \
   -c [5,0.000001] \
   -p Socrates[1] \
   -o [LabelImage.nii.gz,POSTERIOR_%02d.nii.gz] \
   |tee logger 2>&1
                             

Console Out: 

Running Atropos for 3-dimensional images.
Warning: the sum of the priors from the the prior probability images are less than the probability threshold within the mask region.  As a result each zero probability voxel will be initially assigned a random label.  The user might want to consider various alternative strategies like assigning an additional "background" label to the zero probability voxels or propagating the probabilities within the mask region.

Progress: 
  Iteration 0 (of 5): posterior probability = 0 (annealing temperature = 1)
  Iteration 1 (of 5): posterior probability = 0.754047 (annealing temperature = 1)
Writing output:
  Writing posterior image (class 1)
  Writing posterior image (class 2)
  Writing posterior image (class 3)
  Writing posterior image (class 4)
  Writing posterior image (class 5)
  Writing posterior image (class 6)
  Writing posterior image (class 7)
  Writing posterior image (class 8)
  Writing posterior image (class 9)
  Writing posterior image (class 10)
  AtroposSegmentationImageFilter (0x7fb42180f840)
    RTTI typeinfo:   itk::ants::AtroposSegmentationImageFilter<itk::Image<float, 3u>, itk::Image<unsigned int, 3u>, itk::Image<unsigned int, 3u> >
    Reference Count: 1
    Modified Time: 1385125
    Debug: Off
    Observers: 
      IterationEvent(Command)
    Inputs: 
      Primary: (0x7fb4218328a0) *
      IndexedDataObject1: (0x7fb421832230)
      IndexedDataObject2: (0x7fb422200760)
      IndexedDataObject3: (0x7fb421837c10)
      IndexedDataObject4: (0x7fb42183abb0)
    Required Input Names: Primary
    Outputs: 
      Primary: (0x7fb4219012f0)
    NumberOfIndexedInputs: 5
    NumberOfRequiredInputs: 1
    NumberOfIndexedOutputs: 1
    NumberOfRequiredOutputs: 1
    Number Of Threads: 24
    ReleaseDataFlag: Off
    ReleaseDataBeforeUpdateFlag: Off
    AbortGenerateData: Off
    Progress: 0
    Multithreader: 
      RTTI typeinfo:   itk::MultiThreader
      Reference Count: 1
      Modified Time: 200
      Debug: Off
      Observers: 
        none
      Thread Count: 24
      Global Maximum Number Of Threads: 128
      Global Default Number Of Threads: 24
    CoordinateTolerance: 1e-06
    DirectionTolerance: 1e-06
    Maximum number of iterations: 5
    Convergence threshold: 1e-06
    Mask label: 1
    Number of tissue classes: 10
    Number of partial volume classes: 0
    Minimize memory usage: false
    Initialization strategy: Prior probability images
      Use Euclidean distance for prior labels: false
    Posterior probability formulation: Socrates
      initial annealing temperature = 1
      annealing rate = 1
      minimum annealing temperature = 0.1
    MRF parameters
      MRF smoothing factor = 0.2
      MRF radius = [1, 1, 1]
    Use asynchronous updating of the labels.
      ICM parameters
        maximum ICM code = 14
        maximum number of ICM iterations = 1
    No outlier handling.
    Adaptive smoothing weights: [0, 0, 0]
    B-spline smoothing
      spline order = 3
      number of levels = [6, 6, 6]
      number of initial control points = [4, 4, 4]
    Tissue class 1: proportion = 0.00239001
      GaussianListSampleFunction (0x7fb4218375b0)
        mean = [169.634, 171.583, 116.546], covariance = [3365.76, 3354.22, -1407.39; 3354.22, 3410.2, -1397.26; -1407.39, -1397.26, 3268.57]
    Tissue class 2: proportion = 0.434279
      GaussianListSampleFunction (0x7fb421836d10)
        mean = [154.567, 155.147, 56.0725], covariance = [13071.1, 12893.2, 4336.99; 12893.2, 12980.9, 4324.19; 4336.99, 4324.19, 1832.26]
    Tissue class 3: proportion = 0.00504298
      GaussianListSampleFunction (0x7fb421836f20)
        mean = [190.043, 189.247, 109.151], covariance = [2532.52, 2416.32, -1270.85; 2416.32, 2413.33, -1220.65; -1270.85, -1220.65, 2278.05]
    Tissue class 4: proportion = 0.0495242
      GaussianListSampleFunction (0x7fb421834df0)
        mean = [175.175, 176.652, 97.52], covariance = [3578.33, 3556.46, 795.486; 3556.46, 3600.41, 820.084; 795.486, 820.084, 1897.22]
    Tissue class 5: proportion = 0.0204789
      GaussianListSampleFunction (0x7fb4218398c0)
        mean = [175.967, 177.063, 101.669], covariance = [3814.3, 3733.92, 596.577; 3733.92, 3759.85, 613.922; 596.577, 613.922, 1836.2]
    Tissue class 6: proportion = 0.369985
      GaussianListSampleFunction (0x7fb421839a30)
        mean = [140.64, 142.595, 107.935], covariance = [3544.99, 3533.17, -212.757; 3533.17, 3585.08, -189.711; -212.757, -189.711, 3639.84]
    Tissue class 7: proportion = 0.00786538
      GaussianListSampleFunction (0x7fb421833d40)
        mean = [193.067, 196.122, 111.999], covariance = [2252.52, 2236.55, -1489.72; 2236.55, 2302.5, -1478.94; -1489.72, -1478.94, 2335.11]
    Tissue class 8: proportion = 0.00579222
      GaussianListSampleFunction (0x7fb421833df0)
        mean = [151.589, 152.521, 110.648], covariance = [4419.94, 4446.48, 597.022; 4446.48, 4574.39, 638.588; 597.022, 638.588, 3241.76]
    Tissue class 9: proportion = 0.0596998
      GaussianListSampleFunction (0x7fb42183a7c0)
        mean = [131.833, 132.17, 70.2918], covariance = [7542.36, 7360.06, 1873.85; 7360.06, 7410.35, 1862.28; 1873.85, 1862.28, 2374.14]
    Tissue class 10: proportion = 0.044617
      GaussianListSampleFunction (0x7fb42183a930)
        mean = [153.913, 153.94, 62.6276], covariance = [12555.7, 12445.1, 3986.81; 12445.1, 12521.7, 3994.24; 3986.81, 3994.24, 2227.87]
Elapsed time: 725.398
real	16m19.348s
user	16m24.168s
sys	0m9.367s

Output:

Apparently, Atropos is not going to work in this setting, because of tons of possible reasons: wrong priors, registration parameters, wrong initializations..

I will try with their priors in their setting.

 

Set Paths

Add the bin directory containing Atropos to the PATH:

  • export PATH=$PATH:/ipldev/scratch/eunyokim/src/BRAINS2012Dec/build/bin

Add the build directory to the PYTHONPATH:

  • export PYTHONPATH=$PYTHONPATH:your_BRAINSStandAlone-build_dir/NIPYPE

Code

test_Atropos.py
from nipype.interfaces.ants import Atropos
at = Atropos()
at.inputs.dimension = 3
at.inputs.intensity_images = ['T1_0.nii.gz','T1_1_fixed.nii.gz','T1_2_fixed.nii.gz','T2_0_fixed.nii.gz','T2_1_fixed.nii.gz']
at.inputs.mask_image = 'T1_0_roi.nii.gz'
at.inputs.initialization = 'PriorProbabilityImages'
at.inputs.prior_probability_images = ['priorProbImages01.nii.gz', 'priorProbImages04.nii.gz', 'priorProbImages07.nii.gz',
                                      'priorProbImages10.nii.gz','priorProbImages02.nii.gz', 'priorProbImages05.nii.gz',
                                      'priorProbImages08.nii.gz','priorProbImages03.nii.gz', 'priorProbImages06.nii.gz',
                                      'priorProbImages09.nii.gz']
at.inputs.number_of_tissue_classes = 10
at.inputs.prior_weighting = 0.8
at.inputs.prior_probability_threshold = 0.0000001
at.inputs.likelihood_model = 'Gaussian'
at.inputs.mrf_smoothing_factor = 0.2
at.inputs.mrf_radius = [1, 1, 1]
at.inputs.icm_use_synchronous_update = True
at.inputs.maximum_number_of_icm_terations = 1
at.inputs.n_iterations = 5
at.inputs.convergence_threshold = 0.000001
at.inputs.posterior_formulation = 'Socrates'
at.inputs.use_mixture_model_proportions = True
at.inputs.save_posteriors = True
print at.cmdline

result = at.run()
print result.outputs
 
command = 'Atropos --image-dimensionality 3 --icm [1,1] --initialization PriorProbabilityImages[10,priors/priorProbImages%02d.nii.gz,0.8,1e-07] --intensity-image T1_0.nii.gz --intensity-image T1_1_fixed.nii.gz --intensity-image T1_2_fixed.nii.gz --intensity-image T2_0_fixed.nii.gz --intensity-image T2_1_fixed.nii.gz --likelihood-model Gaussian --mask-image T1_0_roi.nii.gz --mrf [0.2,1x1x1] --convergence [5,1e-06] --output [T1_0_labeled.nii.gz,POSTERIOR_%02d.nii.gz] --posterior-formulation Socrates[1]'
/IPLlinux/hjohnson/HDNI/EXPERIEMENTS/AtroposSimpleTest/TestAtropos.sh
/ipldev/scratch/johnsonhj/src/ANTS-Darwin-clang/bin/Atropos \
   -d 3  \
   -a T1_0.nii.gz  \
   -a T1_1_fixed.nii.gz  \
   -a T1_2_fixed.nii.gz  \
   -a T2_0_fixed.nii.gz  \
   -a T2_1_fixed.nii.gz  \
   --mask-image T1_0_roi.nii.gz  \
   -i PriorProbabilityImages[10,priorProbImages%02d.nii.gz,0.8,0.0000001]  \
   -k Gaussian  \
   -m  [0.2,1x1x1]  \
   -g [1,1]  \
   -c [5,0.000001]  \
   -p Socrates[1]  \
   -o [LabelImage.nii.gz,POSTERIOR_%02d.nii.gz]

Notes

A new folder in the current working directory called "priors" will be created. It contains renamed copies of all of the input Prior Probability Images in the form of priorProbImages%02d.nii.gz. These are then used as the input in the --initialization flag for the priors.

For example:

--initialization PriorProbabilityImages[10,priors/priorProbImages%02d.nii.gz,0.8,1e-07]

I found a directory containing bash scripts and tests for Atropos:

/IPLlinux/hjohnson/HDNI/EXPERIEMENTS/

    • AtroposSimpleTest --- I used AtroposSimpleTest for the example inputs and outputs seen below.
    • AtroposBigTest
    • AtroposTest

Example Inputs

Test Directory : /raid0/homes/jforbes/Desktop/test_Atropos/20130130_10priors

Intensity Images
T1_0.nii.gz
T1_1_fixed.nii.gz
T1_2_fixed.nii.gz
T2_0_fixed.nii.gz
T2_1_fixed.nii.gz
Mask Image

T1_0_roi.nii.gz

Prior Probability Images
priorProbImages01.nii.gz
priorProbImages02.nii.gz
priorProbImages03.nii.gz
priorProbImages04.nii.gz
priorProbImages05.nii.gz
priorProbImages06.nii.gz
priorProbImages07.nii.gz
priorProbImages08.nii.gz
priorProbImages09.nii.gz
priorProbImages10.nii.gz

Example Outputs

The output files will be placed in the current working directory.

POSTERIOR_01.nii.gz
POSTERIOR_02.nii.gz
POSTERIOR_03.nii.gz
POSTERIOR_04.nii.gz
POSTERIOR_05.nii.gz
POSTERIOR_06.nii.gz
POSTERIOR_07.nii.gz
POSTERIOR_08.nii.gz
POSTERIOR_09.nii.gz
POSTERIOR_10.nii.gz

T1_0_labeled.nii.gz

priors/

priorProbImages01.nii.gz
priorProbImages02.nii.gz
priorProbImages03.nii.gz
priorProbImages04.nii.gz
priorProbImages05.nii.gz
priorProbImages06.nii.gz
priorProbImages07.nii.gz
priorProbImages08.nii.gz
priorProbImages09.nii.gz
priorProbImages10.nii.gz

 

User Information

interfaces.ants.segment

Link to user information on Nipype site

Atropos

Link to code

Wraps command Atropos

A finite mixture modeling (FMM) segmentation approach with possibilities for specifying prior constraints. These prior constraints include the specification of a prior label image, prior probability images (one for each class), and/or an MRF prior to enforce spatial smoothing of the labels. Similar algorithms include FAST and SPM.

Examples

>>> from nipype.interfaces.ants import Atropos
>>> at = Atropos()
>>> at.inputs.dimension = 3
>>> at.inputs.intensity_images = 'structural.nii'
>>> at.inputs.mask_image = 'mask.nii'
>>> at.inputs.initialization = 'PriorProbabilityImages'
>>> at.inputs.prior_probability_images = ['rc1s1.nii', 'rc1s2.nii']
>>> at.inputs.number_of_tissue_classes = 2
>>> at.inputs.prior_weighting = 0.8
>>> at.inputs.prior_probability_threshold = 0.0000001
>>> at.inputs.likelihood_model = 'Gaussian'
>>> at.inputs.mrf_smoothing_factor = 0.2
>>> at.inputs.mrf_radius = [1, 1, 1]
>>> at.inputs.icm_use_synchronous_update = True
>>> at.inputs.maximum_number_of_icm_terations = 1
>>> at.inputs.n_iterations = 5
>>> at.inputs.convergence_threshold = 0.000001
>>> at.inputs.posterior_formulation = 'Socrates'
>>> at.inputs.use_mixture_model_proportions = True
>>> at.inputs.save_posteriors = True
>>> at.cmdline
'Atropos --image-dimensionality 3 --icm [1,1] --initialization PriorProbabilityImages[2,priors/priorProbImages%02d.nii,0.8,1e-07] 
--intensity-image structural.nii --likelihood-model Gaussian --mask-image mask.nii --mrf [0.2,1x1x1] --convergence [5,1e-06] 
--output [structural_labeled.nii,POSTERIOR_%02d.nii.gz] --posterior-formulation Socrates[1]'

Inputs:

[Mandatory]

initialization: ('Random' or 'Otsu' or 'KMeans' or 'PriorProbabilityImages' or
         'PriorLabelImage')
        requires: number_of_tissue_classes
mask_image: (an existing file name)
number_of_tissue_classes: (an integer)

[Optional]

args: (a string)
        Additional parameters to the command
convergence_threshold: (a float)
        requires: n_iterations
dimension: (3 or 2 or 4, nipype default value: 3)
        image dimension (2, 3, or 4)
environ: (a dictionary with keys which are a value of type 'str' and with values which
         are a value of type 'str', nipype default value: {})
        Environment variables
icm_use_synchronous_update: (a boolean)
ignore_exception: (a boolean, nipype default value: False)
        Print an error message instead of throwing an exception in case the interface fails to
        run
intensity_images: (an existing file name)
likelihood_model: (a string)
maximum_number_of_icm_terations: (an integer)
        requires: icm_use_synchronous_update
mrf_radius: (a list of items which are an integer)
        requires: mrf_smoothing_factor
mrf_smoothing_factor: (a float)
n_iterations: (an integer)
num_threads: (an integer, nipype default value: 1)
        Number of ITK threads to use
out_classified_image_name: (a file name)
output_posteriors_name_template: (a string, nipype default value: POSTERIOR_%02d.nii.gz)
posterior_formulation: (a string)
prior_probability_images: (an existing file name)
prior_probability_threshold: (a float)
        requires: prior_weighting
prior_weighting: (a float)
save_posteriors: (a boolean)
use_mixture_model_proportions: (a boolean)
        requires: posterior_formulation

Outputs:

classified_image: (an existing file name)
posteriors: (a file name)

 

  • No labels