Child pages
  • Lobal Segment from neuromorphometrica
Skip to end of metadata
Go to start of metadata

This is a trial getting lobal measure from the whole brain segmentation from neuromorphometrica.

Development Directory: 

Testing Directory: /Shared/johnsonhj/HDNI/20150202_MALF_LobalDefinition

FreeSurfer White matter parcellation in a BAW space: 

/Shared/johnsonhj/HDNI/Neuromorphometrics/20141116_Neuromorphometrics_base_Results/Neuromorphometrics/2012Subscription/

  • Under TissueClassify directory: 
    • FS_lobes.nii.gz
    • FS_wmparc.nii.gz

FreeSurfer running script (Hans):

  • /Shared/johnsonhj/HDNI/20150206_FS_Neuromorphometric/scripts/

Color Table:

Start from BRAINSTools' neuromorphometrical color table: 

/Shared/johnsonhj/HDNI/20150202_MALF_LobalDefinition/MALFLabel_neuromorphometrics_colortable.txt

Modification for lobal definition: 

  • Initial Neuromorphometric Labe: /Shared/johnsonhj/HDNI/20150202_MALF_LobalDefinition/MALFLabel_Lobes.txt
  • FS + Nuero: /Shared/johnsonhj/HDNI/20150202_MALF_LobalDefinition/ConceptProofForJeremy/FreeSurferColorLUT20150222_Extended_FSWM_BAWVer.txt
  • FS + Neuro for Lobes: /Shared/johnsonhj/HDNI/20150202_MALF_LobalDefinition/ConceptProofForJeremy/FreeSurferColorLUT20150222_Extended_FSWM_Lobes.txt

Lobal definition:

  • Major
    • Frontal
    • Parietal
    • Occipital
    • Temporal
  • Additional/Extra
    • Cerebellum
    • Brain Stem
    • Subcortical
    • Cingulate

Talking to Jeremy on Feb. 06 2015:

  • Wiki page has a nice hierarchical table of the lobes: http://en.wikipedia.org/wiki/Gyrus
  • Free surfer white matter pacellation can be used to help our lobar definition with neuromorphometric.
  • Major four lobes are usefully regions of interest.
  • Extra regions are less important for now (e.g., subcortical, limbic system, cingulate). In addition, there is no general consensus on how each regions should belong to which lobes for cingulate, limbic and center of the brain.
  • Focus on a reasonable lobar definition in a short time period. Labels can be improved later in a long term with neuroanatomist.

 


FreeSurfer WM + Neuromorphometric GM Result on subject 633319246_20100409_30

A new Addition for Concept Proof:lobes_conceptProof.mov 

/Shared/johnsonhj/HDNI/20150202_MALF_LobalDefinition/ConceptProofForJeremy


Enjoy Movie: baw_lobar_model.mov

Result seems good in general BUT

  • I feel that the WM/GM edge is over-smoothed.
  • We cannot do further on this though. We should make it better for multi-modal HD atlases.

 



FreeSurfer WM trial

  1. Generate FreeSurfer Label for 20 neuromorphometric atlases in BAW space (Hans, done)
  2. Generate Lobar regions by combining neuromorphometric and FreeSurfer
    1. Identify lobar labels for white matter from FreeSurfer: FS_WM_label
    2. Mask out FS_WM_label with neuromorphometric white matter label (movie: FS_WM_masked_1001.mov)
      1. Somehow combine those two labels so that FS_WM_label does not contaminate neuromorphometric's clean manual label. 
    3. Include FS_WM_label into our lobar definition
  3. Investigate results


Distance Map WM trial

Initial segment movie:

lobal_segment_initial.mov

Neuromorphometrical Label To Lobar label (and distance map):

Working Directory: 

/Shared/johnsonhj/HDNI/20150202_MALF_LobalDefinition/DistanceMapTrial

Idea:

  1. Compute distance maps from four major lobes: Frontal, parietal, occipital, and temporal lobe
  2. Assign one of four major lobes based on above distance maps
  3. Mask out brain region, excluding blood and ventricles
  4. Over-write additional regions:
    1. Cingulate
    2. Limbic --> Not sure we have these yet.
    3. Cerebellum
    4. Subcortical
    5. Brain Stem

 

Distance Map Trial  ~ 20150204: Looks reasonable. We will try with FreeSurfer WM parcellation and see which one is better. 

  1. Read in label map between neuromorphometric and lobar (done)
  2. Relabel all the cortex into lobar label (done)
  3. Compute distance maps for each lobar label  (done)
  4. Assign the lobar label that has the least distance value. (done)
    1. movie on Neuromorphometrica neuromorphometrica_2012_1001_lobar_parcellation.mov
    2. movie on Track HD trackHD_158312991_20131008_30_lobar_parcellation.mov
  • See the results and compare

    Note on results

    Corpus Callosum should NOT be included.  


import SimpleITK as sitk
import csv
import collections 
lobarLabelDict = {"frontal_lobe":231,
              'temporal_lobe':232,
              'parietal_lobe':233,
              'occipital_lobe':234}
              
extraLobarLabelDict={'cingulate':235,
                     'subcortical':236,
                     'cerebellum':237,
                     'insula':238}

"""
read label, name, lobes, r,g,b,alpha
"""
with open("../wholeBrain2LobarLabelMap.csv") as f:
    reader = csv.DictReader( f )
    Data = collections.namedtuple('Data', reader.fieldnames)
    LabelInfo = [Data(**row) for row in reader]
conversionLobarLabelMapDict = dict()
conversionExtraLobarLabelMapDict = dict()
for row in LabelInfo:
   if row.lobes != '':
        if row.lobes in lobarLabelDict:
            conversionLobarLabelMapDict[row.label] = lobarLabelDict[ row.lobes ]
        elif row.lobes in extraLobarLabelDict:
            conversionExtraLobarLabelMapDict[row.label] = extraLobarLabelDict[ row.lobes ]
        else:
            print "ERROR:Label "+row.lobes +" is not defined or valid label."
            
inputLabel=sitk.ReadImage("/Shared/johnsonhj/HDNI/Neuromorphometrics/20141116_Neuromorphometrics_base_Results/Neuromorphometrics/2012Subscription/1001/TissueClassify/neuro_lbls.nii.gz", sitk.sitkInt32)
inputLabel=sitk.ReadImage("/Shared/sinapse/CACHE/20141124_TrackOn_long_Results/HDNI_001/158312991/158312991_20131008_30/TissueClassify/neuro2012_20fusion_merge_seg.nii.gz", sitk.sitkInt32)
"""
Relabel label map
"""
lobarLabel=inputLabel*0
for originalLabel in conversionLobarLabelMapDict.keys():
    labelImage = sitk.BinaryThreshold(inputLabel, float(originalLabel), float(originalLabel)  )
    labelImage = labelImage * conversionLobarLabelMapDict[originalLabel]
    labelImage = sitk.Cast(labelImage, lobarLabel.GetPixelID())
    
    lobarLabel = labelImage + lobarLabel
    
lobarLabel = sitk.Cast( lobarLabel, sitk.sitkInt32)
sitk.WriteImage(lobarLabel,
                "158312991_20131008_30_Lobar_label.nii.gz")
extLobarLabel=inputLabel*0
for originalLabel in conversionExtraLobarLabelMapDict.keys():
    labelImage = sitk.BinaryThreshold(inputLabel, float(originalLabel), float(originalLabel)  )
    labelImage = labelImage * conversionExtraLobarLabelMapDict[originalLabel]
    labelImage = sitk.Cast(labelImage, extLobarLabel.GetPixelID())
    
    extLobarLabel = labelImage + extLobarLabel
    
extLobarLabel = sitk.Cast( extLobarLabel, sitk.sitkInt32)
sitk.WriteImage(extLobarLabel,
                "158312991_20131008_30_extraLobar_label.nii.gz")
"""
brain Mask without ventricles nor brain stem
"""
NonLobarRegion = {'3rd_Ventricle':4,
                '4th_Ventricle':5,
                '5th_Ventricle':15,
                'Brain_Stem':35,
                'Left_Lateral_Ventricle':52,
                'Right_Lateral_Ventricle':51
                }
lobarMask=inputLabel
for nonBrainRegion in NonBrainDict.keys():
    lobarMask = lobarMask - sitk.Threshold(inputLabel, NonBrainDict[nonBrainRegion],NonBrainDict[nonBrainRegion])
    
sitk.WriteImage( lobarMask>0, "158312991_20131008_30_lobarMask.nii.gz")

"""
get the distance map
"""
distMapImageDict = dict()
for lobe in lobarLabelDict.keys():
    oneLobeImage = sitk.BinaryThreshold(lobarLabel, 
                                        float(lobarLabelDict[lobe]),
                                        float(lobarLabelDict[lobe]) )
    distMapImageDict[lobe] = sitk.DanielssonDistanceMap( oneLobeImage, True )
    sitk.WriteImage(distMapImageDict[lobe] ,
                    "distMap_158312991_20131008_30_" + lobe + ".nii.gz")
"""
get the minimum dist label
"""
minimumDistLabel = sitk.Cast(lobarMask * 0, sitk.sitkInt32)
minimumDistValue = sitk.Cast(lobarMask * 0, sitk.sitkFloat32)
imageSize = lobarMask.GetSize()
for i in range(imageSize[0]):
    for j in range(imageSize[1]):
        for k in range(imageSize[2]):
            if lobarMask[i,j,k] == 0:
                pass
            else:
                minValue = 1000
                minLabel = 0
                for lobe in distMapImageDict.keys():
                    currentDist = distMapImageDict[lobe][i,j,k]
                    if currentDist < minValue:
                        minLabel = lobarLabelDict[ lobe ]
                        minValue = currentDist
                minimumDistLabel[i,j,k]=minLabel 
                minimumDistValue[i,j,k]=minValue
 
sitk.WriteImage(minimumDistLabel,
                "./test_158312991_20131008_30_DistMinLabels.nii.gz")
sitk.WriteImage(minimumDistValue,
                "./test_158312991_20131008_30_DistMinValues.nii.gz")
"""
Clean up labels for cerebellum, cinculate, subcortical, and insula
"""
for i in range(imageSize[0]):
    for j in range(imageSize[1]):
        for k in range(imageSize[2]):
            if extLobarLabel[i,j,k] == 0:
                pass
            else:
                minimumDistLabel[i,j,k]=extLobarLabel[i,j,k]

sitk.WriteImage(minimumDistLabel,
                "./test_158312991_20131008_30_DistMinLabels_cleaned.nii.gz")

 

 

 

 

  • No labels