In [1]:
## Boiler plate code common to many notebooks.  See the TestFilesCommonCode.ipynb for details
from __future__ import print_function
%run TestFilesCommonCode.ipynb


SimpleITK Version: 0.9.0.dev2151-g2a716
Compiled: Dec 23 2014 21:10:53


In [55]:
import os
import glob
import sys

#\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
#####################################################################################
#     Prepend the shell environment search paths
PROGRAM_PATHS = '/scratch/NAMICExternalProjects/release/bin'
PROGRAM_PATHS = PROGRAM_PATHS.split(':')
PROGRAM_PATHS.extend(os.environ['PATH'].split(':'))
os.environ['PATH'] = ':'.join(PROGRAM_PATHS)

CUSTOM_ENVIRONMENT=dict()

# Platform specific information
#     Prepend the python search paths
PYTHON_AUX_PATHS = '/scratch/BS/BRAINSTools/AutoWorkup'
PYTHON_AUX_PATHS = PYTHON_AUX_PATHS.split(':')
PYTHON_AUX_PATHS.extend(sys.path)
sys.path = PYTHON_AUX_PATHS

import SimpleITK as sitk
import nipype
from nipype.interfaces.base import CommandLine, CommandLineInputSpec, TraitedSpec, File, Directory
from nipype.interfaces.base import traits, isdefined, BaseInterface
from nipype.interfaces.utility import Merge, Split, Function, Rename, IdentityInterface
import nipype.interfaces.io as nio   # Data i/oS
import nipype.pipeline.engine as pe  # pypeline engine
import nipype.interfaces.matlab as matlab
from SEMTools import *

In [56]:
SRC_DIR='/scratch/TESTS/BS/DWIWorkflow_Nipype/7_repeatTest6InFloat/19568/Outputs'
FA = os.path.join(SRC_DIR,'FA.nrrd')
MD = os.path.join(SRC_DIR,'MD.nrrd')
RD = os.path.join(SRC_DIR,'RD.nrrd')
frob_norm = os.path.join(SRC_DIR,'frobenius_norm_output.nrrd')
L1 = os.path.join(SRC_DIR,'lambda1_output.nrrd')
L2 = os.path.join(SRC_DIR,'lambda2_output.nrrd')
L3 = os.path.join(SRC_DIR,'lambda3_output.nrrd')
DWIBrainMask = os.path.join(SRC_DIR,'BrainMaskForDWI.nrrd')
T2LabelMap = '/Shared/sinapse/CACHE/20141001_PREDICTHD_long_Results/PHD_024/1155/19568/TissueClassify/fswm_extended_neuro2012_20_merge_seg.nii.gz'

In [57]:
#\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
###### UTILITY FUNCTIONS #######
# This function returns a label map that only covers the FOV of the input DWI scan
def CreateDWILabelMap(T2LabelMapVolume,DWIBrainMask):
    import os
    import SimpleITK as sitk
    T2LabelMapVolume = sitk.ReadImage(T2LabelMapVolume,sitk.sitkUInt8)
    DWIBrainMask = sitk.ReadImage(DWIBrainMask)
    # 1- Dilate input DWI mask
    dilateFilter = sitk.BinaryDilateImageFilter()
    dilateFilter.SetKernelRadius(1)
    dilated_mask = dilateFilter.Execute( DWIBrainMask )
    # 2- Resample dilated mask to the space of T2LabelMap (1x1x1)
    # Use Linear interpolation + thresholding
    resFilt = sitk.ResampleImageFilter()
    resFilt.SetReferenceImage(T2LabelMapVolume)
    resFilt.SetOutputPixelType(sitk.sitkFloat32)
    resFilt.SetInterpolator(sitk.sitkLinear)
    resampled_dilated_mask = resFilt.Execute(dilated_mask)
    # Thresholding by 0
    threshFilt = sitk.BinaryThresholdImageFilter()
    thresh_resampled_dilated_mask = threshFilt.Execute(resampled_dilated_mask,0.0001,1.0,1,0)
    # 3- Multiply this binary mask to the T2 labelmap volume
    DWILabelMapVolume = thresh_resampled_dilated_mask * T2LabelMapVolume
    outputVolume = os.path.realpath('DWILabelMapVolume.nrrd')
    sitk.WriteImage(DWILabelMapVolume, outputVolume)
    return outputVolume

def MakeResamplerInFileList(FAImage,MDImage,RDImage,FrobeniusNormImage,Lambda1Image,Lambda2Image,Lambda3Image):
    RISsList = [FAImage,MDImage,RDImage,FrobeniusNormImage,Lambda1Image,Lambda2Image,Lambda3Image]
    return RISsList

# This functions computes statistics of each input RIS volume over input labels 
# and writes the results as a CSV file
def ComputeStatistics(inputVolume,T2LabelMapVolume,DWILabelMapVolume,labelCodesFile): 
    import os
    import SimpleITK as sitk
    #### Util Funcs ####
    def createLabelsDictionary(labelCodesFile):
        import csv
        labelsDictionary={}
        with open(labelCodesFile) as lf:
            reader = csv.reader(lf, delimiter=',')
            for line in reader:
              if line[0][0] == "#":
                 continue
              else:
                 labelsDictionary[line[0]] = line[1]
        return labelsDictionary
    
    def computeVoxelVolume(inputVolume):
        import operator
        return reduce(operator.mul, inputVolume.GetSpacing())
    
    def ReturnStatisticsList(labelID,voxelVolume,resampledRISVolume,DWILabelMap,T2LabelMap):
        statFilter = sitk.LabelStatisticsImageFilter()
        # RIS stats over input label ID
        statFilter.Execute(resampledRISVolume, DWILabelMap)
        mean = statFilter.GetMean(labelID)
        std = statFilter.GetSigma(labelID)
        maximum = statFilter.GetMaximum(labelID)
        minimum = statFilter.GetMinimum(labelID)
        median = statFilter.GetMedian(labelID)
        effectiveVolume = statFilter.GetCount(labelID)*voxelVolume
        # compute total volume of input label ID in the non-cropped labelmap (T2LabelMap)
        statFilter.Execute(resampledRISVolume, T2LabelMap)
        totalVolume = statFilter.GetCount(labelID)*voxelVolume
        # if effectiveVolume is 0, the label is missed in dwi scan, or it doesn't exists in current labelmaps
        # in both cases we need zero confidence coefficient for that.
        if effectiveVolume == 0:
            confidence_coeficient = 0
            maximum = 0
            minimum = 0
        else:
            confidence_coeficient=effectiveVolume/totalVolume
        # Now create statistics list
        statsList = [format(mean,'.4f'),
                     format(std,'.4f'),
                     format(maximum,'.4f'),
                     format(minimum,'.4f'),
                     format(median,'.4f'),
                     effectiveVolume,
                     totalVolume,
                     format(confidence_coeficient,'.3f')]
        return statsList
    
    def writeLabelStatistics(filename,statisticsDictionary):
        import csv
        with open(filename, 'wb') as lf:
            headerdata = [['#Label', 'mean', 'std', 'max', 'min', 'median', 'effective_volume', 'total_volume', 'confidence_coeficient']]
            wr = csv.writer(lf, delimiter=',')
            wr.writerows(headerdata)
            for key, value in sorted(statisticsDictionary.items()):
                wr.writerows([[key] + value])
    #### #### #### ####
    resampledRISVolume = sitk.ReadImage(inputVolume)
    T2LabelMap = sitk.ReadImage(T2LabelMapVolume)
    DWILabelMap = sitk.ReadImage(DWILabelMapVolume)
    labelsDictionary = createLabelsDictionary(labelCodesFile)
    statisticsDictionary={}
    voxelVolume=computeVoxelVolume(resampledRISVolume)
    for key in labelsDictionary:
        labelID = int(key)   
        statisticsDictionary[labelsDictionary[key]] = ReturnStatisticsList(labelID,voxelVolume,resampledRISVolume,DWILabelMap,T2LabelMap)
    inputBaseName = os.path.basename(inputVolume)
    inputName = os.path.splitext(inputBaseName)[0]
    RISName = inputName.split('_',1)[0]
    CSVStatisticsFile = os.path.realpath(RISName + '_statistics.csv')
    writeLabelStatistics(CSVStatisticsFile,statisticsDictionary)
    return CSVStatisticsFile

# This function helps to pick desirable output from the output list
def pickFromList(inputlist,item):
    return inputlist[item]
#################################
#\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

In [58]:
BASE_DIR = '/scratch/TESTS/IpythonNotebook/4_measureWF'
WFname = "MeasurementWF"

MeasurementWF = pe.Workflow(name=WFname)
MeasurementWF.base_dir = BASE_DIR

inputsSpec = pe.Node(interface=IdentityInterface(fields=['T2LabelMapVolume','DWIBrainMask','inputLabelCodes',
                                                         'FAImage','MDImage','RDImage','FrobeniusNormImage',
                                                         'Lambda1Image','Lambda2Image','Lambda3Image']),
                     name='inputsSpec')

inputsSpec.inputs.inputLabelCodes = '/Shared/sinapse/scratch/aghayoor/NAMICExternalProjects/release/BRAINSTools/AutoWorkup/DWIProcessingWorkflows/FS_Extended_Labels_Config.csv'
inputsSpec.inputs.T2LabelMapVolume = T2LabelMap
inputsSpec.inputs.DWIBrainMask = DWIBrainMask
inputsSpec.inputs.FAImage = FA
inputsSpec.inputs.MDImage = MD
inputsSpec.inputs.RDImage = RD
inputsSpec.inputs.FrobeniusNormImage = frob_norm
inputsSpec.inputs.Lambda1Image = L1
inputsSpec.inputs.Lambda2Image = L2
inputsSpec.inputs.Lambda3Image = L3

outputsSpec = pe.Node(interface=IdentityInterface(fields=['FA_stats','MD_stats','RD_stats','FrobeniusNorm_stats',
                                                          'Lambda1_stats','Lambda2_stats','Lambda3_stats']),
                      name='outputsSpec')

# Step1: Create the labelmap volume for DWI scan
CreateDWILabelMapNode = pe.Node(interface=Function(function = CreateDWILabelMap,
                                                   input_names=['T2LabelMapVolume','DWIBrainMask'],
                                                   output_names=['DWILabelMapVolume']),
                                name="CreateDWILabelMap")
MeasurementWF.connect(inputsSpec, 'T2LabelMapVolume', CreateDWILabelMapNode, 'T2LabelMapVolume')
MeasurementWF.connect(inputsSpec, 'DWIBrainMask', CreateDWILabelMapNode, 'DWIBrainMask')

# Now we have two labelmap volumes (both have 1x1x1 voxel lattice):
# (1) T2LabelMap: Used to compute total_volume for each label
# (2) DWILabelMap: It is probably cropped and missed some part of labels,
#                  and is used to compute all stats like [mean,std,max,min,median,effective_volume].

# Step2: Resample each RIS to T2LabelmapVolume voxel lattice 
MakeResamplerInFilesListNode = pe.Node(Function(function=MakeResamplerInFileList,
                                                input_names=['FAImage','MDImage','RDImage','FrobeniusNormImage',
                                                                 'Lambda1Image','Lambda2Image','Lambda3Image'],
                                                output_names=['RISsList']),
                                       name="MakeResamplerInFilesListNode")
MeasurementWF.connect([(inputsSpec, MakeResamplerInFilesListNode, [('FAImage','FAImage'),
                                                                   ('MDImage','MDImage'),
                                                                   ('RDImage','RDImage'),
                                                                   ('FrobeniusNormImage','FrobeniusNormImage'),
                                                                   ('Lambda1Image','Lambda1Image'),
                                                                   ('Lambda2Image','Lambda2Image'),
                                                                   ('Lambda3Image','Lambda3Image')])])

ResampleRISsNode = pe.MapNode(interface=BRAINSResample(), name="ResampleRISs",
                              iterfield=['inputVolume', 'outputVolume'])
ResampleRISsNode.inputs.interpolationMode = 'Linear'
ResampleRISsNode.inputs.pixelType = 'float'
ResampleRISsNode.inputs.outputVolume = ['FA_res.nrrd','MD_res.nrrd','RD_res.nrrd','FrobeniusNorm_res.nrrd',
                                        'Lambda1_res.nrrd','Lambda2_res.nrrd','Lambda3_res.nrrd']
MeasurementWF.connect(inputsSpec,'T2LabelMapVolume',ResampleRISsNode,'referenceVolume')
MeasurementWF.connect(MakeResamplerInFilesListNode,'RISsList',ResampleRISsNode,'inputVolume')

# Step3: Deal with labels
ComputeStatisticsNode = pe.MapNode(interface=Function(function = ComputeStatistics,
                                                   input_names=['inputVolume','T2LabelMapVolume','DWILabelMapVolume','labelCodesFile'],
                                                   output_names=['CSVStatisticsFile']),
                                name="ComputeStatistics",
                                iterfield=['inputVolume'])
MeasurementWF.connect(ResampleRISsNode, 'outputVolume', ComputeStatisticsNode, 'inputVolume')
MeasurementWF.connect(inputsSpec, 'T2LabelMapVolume', ComputeStatisticsNode, 'T2LabelMapVolume')
MeasurementWF.connect(CreateDWILabelMapNode, 'DWILabelMapVolume', ComputeStatisticsNode, 'DWILabelMapVolume')
MeasurementWF.connect(inputsSpec, 'inputLabelCodes', ComputeStatisticsNode, 'labelCodesFile')
MeasurementWF.connect(ComputeStatisticsNode, ('CSVStatisticsFile', pickFromList, 0), outputsSpec, 'FA_stats')
MeasurementWF.connect(ComputeStatisticsNode, ('CSVStatisticsFile', pickFromList, 1), outputsSpec, 'MD_stats')
MeasurementWF.connect(ComputeStatisticsNode, ('CSVStatisticsFile', pickFromList, 2), outputsSpec, 'RD_stats')
MeasurementWF.connect(ComputeStatisticsNode, ('CSVStatisticsFile', pickFromList, 3), outputsSpec, 'FrobeniusNorm_stats')
MeasurementWF.connect(ComputeStatisticsNode, ('CSVStatisticsFile', pickFromList, 4), outputsSpec, 'Lambda1_stats')
MeasurementWF.connect(ComputeStatisticsNode, ('CSVStatisticsFile', pickFromList, 5), outputsSpec, 'Lambda2_stats')
MeasurementWF.connect(ComputeStatisticsNode, ('CSVStatisticsFile', pickFromList, 6), outputsSpec, 'Lambda3_stats')

MeasurementWF.write_graph()
MeasurementWF.run()


INFO:workflow:Converting dotfile: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/graph.dot to png format
INFO:workflow:['check', 'execution', 'logging']
INFO:workflow:Running serially.
INFO:workflow:Executing node CreateDWILabelMap in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/CreateDWILabelMap
INFO:workflow:Executing node MakeResamplerInFilesListNode in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/MakeResamplerInFilesListNode
INFO:workflow:Collecting precomputed outputs
INFO:workflow:Executing node ResampleRISs in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/ResampleRISs
INFO:workflow:Executing node _ResampleRISs0 in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/ResampleRISs/mapflow/_ResampleRISs0
INFO:workflow:Running:  BRAINSResample  --inputVolume /scratch/TESTS/BS/DWIWorkflow_Nipype/7_repeatTest6InFloat/19568/Outputs/FA.nrrd --interpolationMode Linear --outputVolume FA_res.nrrd --pixelType float --referenceVolume /Shared/sinapse/CACHE/20141001_PREDICTHD_long_Results/PHD_024/1155/19568/TissueClassify/fswm_extended_neuro2012_20_merge_seg.nii.gz
INFO:interface:stdout 2015-03-22T17:24:07.001221:WARNING: neither warpTransform nor deformationVolume are defined, so warpTransform is set as identity.
INFO:interface:stdout 2015-03-22T17:24:07.001221:=====================================================
INFO:interface:stdout 2015-03-22T17:24:07.001221:Input Volume:     /scratch/TESTS/BS/DWIWorkflow_Nipype/7_repeatTest6InFloat/19568/Outputs/FA.nrrd
INFO:interface:stdout 2015-03-22T17:24:07.001221:Reference Volume: /Shared/sinapse/CACHE/20141001_PREDICTHD_long_Results/PHD_024/1155/19568/TissueClassify/fswm_extended_neuro2012_20_merge_seg.nii.gz
INFO:interface:stdout 2015-03-22T17:24:07.001221:Output Volume:    FA_res.nrrd
INFO:interface:stdout 2015-03-22T17:24:07.001221:Pixel Type:       float
INFO:interface:stdout 2015-03-22T17:24:07.001221:Interpolation:    Linear
INFO:interface:stdout 2015-03-22T17:24:07.001221:Background Value: 0
INFO:interface:stdout 2015-03-22T17:24:07.001221:Warp By Transform: Identity
INFO:interface:stdout 2015-03-22T17:24:07.001221:=====================================================
INFO:workflow:Executing node _ResampleRISs1 in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/ResampleRISs/mapflow/_ResampleRISs1
INFO:workflow:Running:  BRAINSResample  --inputVolume /scratch/TESTS/BS/DWIWorkflow_Nipype/7_repeatTest6InFloat/19568/Outputs/MD.nrrd --interpolationMode Linear --outputVolume MD_res.nrrd --pixelType float --referenceVolume /Shared/sinapse/CACHE/20141001_PREDICTHD_long_Results/PHD_024/1155/19568/TissueClassify/fswm_extended_neuro2012_20_merge_seg.nii.gz
INFO:interface:stdout 2015-03-22T17:24:07.782477:WARNING: neither warpTransform nor deformationVolume are defined, so warpTransform is set as identity.
INFO:interface:stdout 2015-03-22T17:24:07.782477:=====================================================
INFO:interface:stdout 2015-03-22T17:24:07.782477:Input Volume:     /scratch/TESTS/BS/DWIWorkflow_Nipype/7_repeatTest6InFloat/19568/Outputs/MD.nrrd
INFO:interface:stdout 2015-03-22T17:24:07.782477:Reference Volume: /Shared/sinapse/CACHE/20141001_PREDICTHD_long_Results/PHD_024/1155/19568/TissueClassify/fswm_extended_neuro2012_20_merge_seg.nii.gz
INFO:interface:stdout 2015-03-22T17:24:07.782477:Output Volume:    MD_res.nrrd
INFO:interface:stdout 2015-03-22T17:24:07.782477:Pixel Type:       float
INFO:interface:stdout 2015-03-22T17:24:07.782477:Interpolation:    Linear
INFO:interface:stdout 2015-03-22T17:24:07.782477:Background Value: 0
INFO:interface:stdout 2015-03-22T17:24:07.782477:Warp By Transform: Identity
INFO:interface:stdout 2015-03-22T17:24:07.782477:=====================================================
INFO:workflow:Executing node _ResampleRISs2 in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/ResampleRISs/mapflow/_ResampleRISs2
INFO:workflow:Running:  BRAINSResample  --inputVolume /scratch/TESTS/BS/DWIWorkflow_Nipype/7_repeatTest6InFloat/19568/Outputs/RD.nrrd --interpolationMode Linear --outputVolume RD_res.nrrd --pixelType float --referenceVolume /Shared/sinapse/CACHE/20141001_PREDICTHD_long_Results/PHD_024/1155/19568/TissueClassify/fswm_extended_neuro2012_20_merge_seg.nii.gz
INFO:interface:stdout 2015-03-22T17:24:08.490293:WARNING: neither warpTransform nor deformationVolume are defined, so warpTransform is set as identity.
INFO:interface:stdout 2015-03-22T17:24:08.490293:=====================================================
INFO:interface:stdout 2015-03-22T17:24:08.490293:Input Volume:     /scratch/TESTS/BS/DWIWorkflow_Nipype/7_repeatTest6InFloat/19568/Outputs/RD.nrrd
INFO:interface:stdout 2015-03-22T17:24:08.490293:Reference Volume: /Shared/sinapse/CACHE/20141001_PREDICTHD_long_Results/PHD_024/1155/19568/TissueClassify/fswm_extended_neuro2012_20_merge_seg.nii.gz
INFO:interface:stdout 2015-03-22T17:24:08.490293:Output Volume:    RD_res.nrrd
INFO:interface:stdout 2015-03-22T17:24:08.490293:Pixel Type:       float
INFO:interface:stdout 2015-03-22T17:24:08.490293:Interpolation:    Linear
INFO:interface:stdout 2015-03-22T17:24:08.490293:Background Value: 0
INFO:interface:stdout 2015-03-22T17:24:08.490293:Warp By Transform: Identity
INFO:interface:stdout 2015-03-22T17:24:08.490293:=====================================================
INFO:workflow:Executing node _ResampleRISs3 in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/ResampleRISs/mapflow/_ResampleRISs3
INFO:workflow:Running:  BRAINSResample  --inputVolume /scratch/TESTS/BS/DWIWorkflow_Nipype/7_repeatTest6InFloat/19568/Outputs/frobenius_norm_output.nrrd --interpolationMode Linear --outputVolume FrobeniusNorm_res.nrrd --pixelType float --referenceVolume /Shared/sinapse/CACHE/20141001_PREDICTHD_long_Results/PHD_024/1155/19568/TissueClassify/fswm_extended_neuro2012_20_merge_seg.nii.gz
INFO:interface:stdout 2015-03-22T17:24:09.391768:WARNING: neither warpTransform nor deformationVolume are defined, so warpTransform is set as identity.
INFO:interface:stdout 2015-03-22T17:24:09.391768:=====================================================
INFO:interface:stdout 2015-03-22T17:24:09.391768:Input Volume:     /scratch/TESTS/BS/DWIWorkflow_Nipype/7_repeatTest6InFloat/19568/Outputs/frobenius_norm_output.nrrd
INFO:interface:stdout 2015-03-22T17:24:09.391768:Reference Volume: /Shared/sinapse/CACHE/20141001_PREDICTHD_long_Results/PHD_024/1155/19568/TissueClassify/fswm_extended_neuro2012_20_merge_seg.nii.gz
INFO:interface:stdout 2015-03-22T17:24:09.391768:Output Volume:    FrobeniusNorm_res.nrrd
INFO:interface:stdout 2015-03-22T17:24:09.391768:Pixel Type:       float
INFO:interface:stdout 2015-03-22T17:24:09.391768:Interpolation:    Linear
INFO:interface:stdout 2015-03-22T17:24:09.391768:Background Value: 0
INFO:interface:stdout 2015-03-22T17:24:09.395214:Warp By Transform: Identity
INFO:interface:stdout 2015-03-22T17:24:09.395214:=====================================================
INFO:workflow:Executing node _ResampleRISs4 in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/ResampleRISs/mapflow/_ResampleRISs4
INFO:workflow:Running:  BRAINSResample  --inputVolume /scratch/TESTS/BS/DWIWorkflow_Nipype/7_repeatTest6InFloat/19568/Outputs/lambda1_output.nrrd --interpolationMode Linear --outputVolume Lambda1_res.nrrd --pixelType float --referenceVolume /Shared/sinapse/CACHE/20141001_PREDICTHD_long_Results/PHD_024/1155/19568/TissueClassify/fswm_extended_neuro2012_20_merge_seg.nii.gz
INFO:interface:stdout 2015-03-22T17:24:10.091891:WARNING: neither warpTransform nor deformationVolume are defined, so warpTransform is set as identity.
INFO:interface:stdout 2015-03-22T17:24:10.091891:=====================================================
INFO:interface:stdout 2015-03-22T17:24:10.091891:Input Volume:     /scratch/TESTS/BS/DWIWorkflow_Nipype/7_repeatTest6InFloat/19568/Outputs/lambda1_output.nrrd
INFO:interface:stdout 2015-03-22T17:24:10.091891:Reference Volume: /Shared/sinapse/CACHE/20141001_PREDICTHD_long_Results/PHD_024/1155/19568/TissueClassify/fswm_extended_neuro2012_20_merge_seg.nii.gz
INFO:interface:stdout 2015-03-22T17:24:10.091891:Output Volume:    Lambda1_res.nrrd
INFO:interface:stdout 2015-03-22T17:24:10.091891:Pixel Type:       float
INFO:interface:stdout 2015-03-22T17:24:10.091891:Interpolation:    Linear
INFO:interface:stdout 2015-03-22T17:24:10.091891:Background Value: 0
INFO:interface:stdout 2015-03-22T17:24:10.091891:Warp By Transform: Identity
INFO:interface:stdout 2015-03-22T17:24:10.091891:=====================================================
INFO:workflow:Executing node _ResampleRISs5 in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/ResampleRISs/mapflow/_ResampleRISs5
INFO:workflow:Running:  BRAINSResample  --inputVolume /scratch/TESTS/BS/DWIWorkflow_Nipype/7_repeatTest6InFloat/19568/Outputs/lambda2_output.nrrd --interpolationMode Linear --outputVolume Lambda2_res.nrrd --pixelType float --referenceVolume /Shared/sinapse/CACHE/20141001_PREDICTHD_long_Results/PHD_024/1155/19568/TissueClassify/fswm_extended_neuro2012_20_merge_seg.nii.gz
INFO:interface:stdout 2015-03-22T17:24:10.797074:WARNING: neither warpTransform nor deformationVolume are defined, so warpTransform is set as identity.
INFO:interface:stdout 2015-03-22T17:24:10.797074:=====================================================
INFO:interface:stdout 2015-03-22T17:24:10.797074:Input Volume:     /scratch/TESTS/BS/DWIWorkflow_Nipype/7_repeatTest6InFloat/19568/Outputs/lambda2_output.nrrd
INFO:interface:stdout 2015-03-22T17:24:10.797074:Reference Volume: /Shared/sinapse/CACHE/20141001_PREDICTHD_long_Results/PHD_024/1155/19568/TissueClassify/fswm_extended_neuro2012_20_merge_seg.nii.gz
INFO:interface:stdout 2015-03-22T17:24:10.797074:Output Volume:    Lambda2_res.nrrd
INFO:interface:stdout 2015-03-22T17:24:10.797074:Pixel Type:       float
INFO:interface:stdout 2015-03-22T17:24:10.797074:Interpolation:    Linear
INFO:interface:stdout 2015-03-22T17:24:10.797074:Background Value: 0
INFO:interface:stdout 2015-03-22T17:24:10.797074:Warp By Transform: Identity
INFO:interface:stdout 2015-03-22T17:24:10.797074:=====================================================
INFO:workflow:Executing node _ResampleRISs6 in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/ResampleRISs/mapflow/_ResampleRISs6
INFO:workflow:Running:  BRAINSResample  --inputVolume /scratch/TESTS/BS/DWIWorkflow_Nipype/7_repeatTest6InFloat/19568/Outputs/lambda3_output.nrrd --interpolationMode Linear --outputVolume Lambda3_res.nrrd --pixelType float --referenceVolume /Shared/sinapse/CACHE/20141001_PREDICTHD_long_Results/PHD_024/1155/19568/TissueClassify/fswm_extended_neuro2012_20_merge_seg.nii.gz
INFO:interface:stdout 2015-03-22T17:24:11.577005:WARNING: neither warpTransform nor deformationVolume are defined, so warpTransform is set as identity.
INFO:interface:stdout 2015-03-22T17:24:11.577005:=====================================================
INFO:interface:stdout 2015-03-22T17:24:11.577005:Input Volume:     /scratch/TESTS/BS/DWIWorkflow_Nipype/7_repeatTest6InFloat/19568/Outputs/lambda3_output.nrrd
INFO:interface:stdout 2015-03-22T17:24:11.577005:Reference Volume: /Shared/sinapse/CACHE/20141001_PREDICTHD_long_Results/PHD_024/1155/19568/TissueClassify/fswm_extended_neuro2012_20_merge_seg.nii.gz
INFO:interface:stdout 2015-03-22T17:24:11.577005:Output Volume:    Lambda3_res.nrrd
INFO:interface:stdout 2015-03-22T17:24:11.577005:Pixel Type:       float
INFO:interface:stdout 2015-03-22T17:24:11.577005:Interpolation:    Linear
INFO:interface:stdout 2015-03-22T17:24:11.577005:Background Value: 0
INFO:interface:stdout 2015-03-22T17:24:11.577005:Warp By Transform: Identity
INFO:interface:stdout 2015-03-22T17:24:11.577005:=====================================================
INFO:workflow:Executing node ComputeStatistics in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/ComputeStatistics
INFO:workflow:Executing node _ComputeStatistics0 in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/ComputeStatistics/mapflow/_ComputeStatistics0
INFO:workflow:Executing node _ComputeStatistics1 in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/ComputeStatistics/mapflow/_ComputeStatistics1
INFO:workflow:Executing node _ComputeStatistics2 in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/ComputeStatistics/mapflow/_ComputeStatistics2
INFO:workflow:Executing node _ComputeStatistics3 in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/ComputeStatistics/mapflow/_ComputeStatistics3
INFO:workflow:Executing node _ComputeStatistics4 in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/ComputeStatistics/mapflow/_ComputeStatistics4
INFO:workflow:Executing node _ComputeStatistics5 in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/ComputeStatistics/mapflow/_ComputeStatistics5
INFO:workflow:Executing node _ComputeStatistics6 in dir: /scratch/TESTS/IpythonNotebook/4_measureWF/MeasurementWF/ComputeStatistics/mapflow/_ComputeStatistics6
ERROR:workflow:['Node ComputeStatistics failed to run on host dendrite.psychiatry.uiowa.edu.']
INFO:workflow:Saving crash info to /Volumes/scratch/Notebooks/SimpleITK-Notebook-Answers/crash-20150322-172417-aghayoor-ComputeStatistics.pklz
INFO:workflow:Traceback (most recent call last):
  File "/Volumes/scratch/Notebooks/sitkpy/lib/python2.7/site-packages/nipype/pipeline/plugins/linear.py", line 38, in run
    node.run(updatehash=updatehash)
  File "/Volumes/scratch/Notebooks/sitkpy/lib/python2.7/site-packages/nipype/pipeline/engine.py", line 1424, in run
    self._run_interface()
  File "/Volumes/scratch/Notebooks/sitkpy/lib/python2.7/site-packages/nipype/pipeline/engine.py", line 2329, in _run_interface
    updatehash=updatehash))
  File "/Volumes/scratch/Notebooks/sitkpy/lib/python2.7/site-packages/nipype/pipeline/engine.py", line 2234, in _collate_results
    (self.name, '\n'.join(msg)))
Exception: Subnodes of node: ComputeStatistics failed:
Subnode 0 failed
Error:
float division by zero
Interface Function failed to run. 
Subnode 1 failed
Error:
float division by zero
Interface Function failed to run. 
Subnode 2 failed
Error:
float division by zero
Interface Function failed to run. 
Subnode 3 failed
Error:
float division by zero
Interface Function failed to run. 
Subnode 4 failed
Error:
float division by zero
Interface Function failed to run. 
Subnode 5 failed
Error:
float division by zero
Interface Function failed to run. 
Subnode 6 failed
Error:
float division by zero
Interface Function failed to run. 

INFO:workflow:***********************************
ERROR:workflow:could not run node: MeasurementWF.ComputeStatistics
INFO:workflow:crashfile: /Volumes/scratch/Notebooks/SimpleITK-Notebook-Answers/crash-20150322-172417-aghayoor-ComputeStatistics.pklz
INFO:workflow:***********************************
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-58-aed983f98518> in <module>()
     80 
     81 MeasurementWF.write_graph()
---> 82 MeasurementWF.run()

/Volumes/scratch/Notebooks/sitkpy/lib/python2.7/site-packages/nipype/pipeline/engine.pyc in run(self, plugin, plugin_args, updatehash)
    698         if str2bool(self.config['execution']['create_report']):
    699             self._write_report_info(self.base_dir, self.name, execgraph)
--> 700         runner.run(execgraph, updatehash=updatehash, config=self.config)
    701         datestr = datetime.utcnow().strftime('%Y%m%dT%H%M%S')
    702         if str2bool(self.config['execution']['write_provenance']):

/Volumes/scratch/Notebooks/sitkpy/lib/python2.7/site-packages/nipype/pipeline/plugins/linear.pyc in run(self, graph, config, updatehash)
     54                 if self._status_callback:
     55                     self._status_callback(node, 'exception')
---> 56         report_nodes_not_run(notrun)
     57 

/Volumes/scratch/Notebooks/sitkpy/lib/python2.7/site-packages/nipype/pipeline/plugins/base.pyc in report_nodes_not_run(notrun)
     90                 logger.debug(subnode._id)
     91         logger.info("***********************************")
---> 92         raise RuntimeError(('Workflow did not execute cleanly. '
     93                             'Check log for details'))
     94 

RuntimeError: Workflow did not execute cleanly. Check log for details

In [ ]: