Esempio n. 1
0
def run_particle_tools(config, data, outputdir, ids):
    import sys,os
    pathPython = sys.executable
    pathShapeWorksScript = os.path.dirname(os.path.abspath(__file__)) + "/shapeworks.py"
    pathShapeWorksRun = config["ShapeWorksRunPath"]
    pathImageMath = config["ImageMathPath"]
    pathShapeWorksGroom = config["ShapeWorksGroomPath"]
    pathBinaryToDistanceMap = config["BinaryToDistanceMapPath"]

    workdir = "%s/Processing/2.shapeworks" % (outputdir)

    # generate binary distance map for each label map
    # cmd = "%s %s %s/inputimage.txt %s/inputsurfacemodels.txt -c %s/outputCorrespondence.txt -w %s/outputWarped.txt --workingDir %s --pathShapeWorksRun %s --pathShapeWorksGroom %s --pathImageMath %s --pathBinaryToDistanceMap %s" % (pathPython, pathShapeWorksScript, workdir, workdir, workdir, workdir, workdir, pathShapeWorksRun, pathShapeWorksGroom, pathImageMath, pathBinaryToDistanceMap)

    outputCorrespondence = "{workdir}/outputCorrespondence.txt"
    outputCorrespondence = outputCorrespondence.format(**locals())  
    if (not system.is_file_exist(outputCorrespondence,opts.overwrite)):

        cmd = "{pathPython} {pathShapeWorksScript} {workdir}/inputimage.txt " +\
                "{workdir}/inputsurfacemodels.txt " + \
                "-c {workdir}/outputCorrespondence.txt " +\
                "-w {workdir}/outputWarped.txt " +\
                "--workingDir {workdir}" 
            
        cmd = cmd.format(**locals())         
        system.run_process(cmd,verbose=True)
Esempio n. 2
0
def run_particle_tools(config, data, outputdir, ids):
    import sys,os
    pathPython = sys.executable
    pathShapeWorksScript = os.path.dirname(os.path.abspath(__file__)) + "/shapeworks.py"
    pathShapeWorksRun = config["ShapeWorksRunPath"]
    pathImageMath = config["ImageMathPath"]
    pathShapeWorksGroom = config["ShapeWorksGroomPath"]
    pathBinaryToDistanceMap = config["BinaryToDistanceMapPath"]

    workdir = "%s/Processing/2.shapeworks" % (outputdir)

    # generate binary distance map for each label map
    # cmd = "%s %s %s/inputimage.txt %s/inputsurfacemodels.txt -c %s/outputCorrespondence.txt -w %s/outputWarped.txt --workingDir %s --pathShapeWorksRun %s --pathShapeWorksGroom %s --pathImageMath %s --pathBinaryToDistanceMap %s" % (pathPython, pathShapeWorksScript, workdir, workdir, workdir, workdir, workdir, pathShapeWorksRun, pathShapeWorksGroom, pathImageMath, pathBinaryToDistanceMap)

    outputCorrespondence = "{workdir}/outputCorrespondence.txt"
    outputCorrespondence = outputCorrespondence.format(**locals())  
    if (not system.is_file_exist(outputCorrespondence,opts.overwrite)):

        cmd = "{pathPython} {pathShapeWorksScript} {workdir}/inputimage.txt " +\
                "{workdir}/inputsurfacemodels.txt " + \
                "-c {workdir}/outputCorrespondence.txt " +\
                "-w {workdir}/outputWarped.txt " +\
                "--workingDir {workdir}" 
            
        cmd = cmd.format(**locals())         
        system.run_process(cmd,verbose=True)
Esempio n. 3
0
def paratospharm(opts, config, data, outputDir):
    workdir = "%s/Processing/1.MeasurementandSPHARM" % (outputDir)
    pathParaToSPHARM = config["ParaToSPHARMMeshCLPPath"]

    idlist = [id for id,l,g in data]
    parafiles = ["%s/%s.para.vtk"%(workdir,id) for id,l,g in data]
    surffiles = ["%s/%s.surf.vtk"%(workdir,id) for id,l,g in data]
    lowresfiles = ["%s/%s.ip.SPHARM.vtk"%(workdir,id) for id,l,g in data]
    highresfiles = ["%s/%s.subj.SPHARM.vtk"%(workdir,id) for id,l,g in data]
    lowresparams = ["%s/%s.ip.Param.vtk"%(workdir,id) for id,l,g in data]
    highresparams = ["%s/%s.subj.Param.vtk"%(workdir,id) for id,l,g in data]
    dataset = zip(parafiles, surffiles, lowresfiles, lowresparams, highresfiles, highresparams)

    def file_exists(f):
        return not opts.overwrite and os.path.isfile(f) and os.stat(f).st_size > 0

    for idx,(pf,sf,lm,lp,hm,hp) in enumerate(dataset):
        if not file_exists(lm):
            if idx == 0:
                cmd = "%s %s %s --subdivLevel 10 --spharmDegree 20  %s/%s.ip. --paraOut" % (pathParaToSPHARM, pf, sf, workdir, idlist[idx])
            else:
                cmd = "%s %s %s --subdivLevel 10 --spharmDegree 20  %s/%s.ip. --flipTemplateOn --flipTemplate %s/%s.ip.SPHARM.coef --paraOut" % (pathParaToSPHARM, pf, sf, workdir, idlist[idx], workdir, idlist[idx-1])
            system.run_process(cmd,verbose=opts.verbose)

        if not file_exists(hm):
            if idx == 0:
                cmd = "%s %s %s --subdivLevel 50 --spharmDegree 20  %s/%s.subj. --paraOut" % (pathParaToSPHARM, pf, sf, workdir, idlist[idx])
            else:
                cmd = "%s %s %s --subdivLevel 50 --spharmDegree 20  %s/%s.subj. --flipTemplateOn --flipTemplate %s/%s.subj.SPHARM.coef --paraOut" % (pathParaToSPHARM, pf, sf, workdir, idlist[idx], workdir, idlist[idx-1])
            system.run_process(cmd,verbose=opts.verbose)
Esempio n. 4
0
def resample_segmentations(config,data,outputdir):
    workdir = "%s/Processing/1.MeasurementandSPHARM" % (outputDir)
    reference_image = "%s/%s.segpost.nii.gz" % (workdir,data[0][0])

    pathResampleVolume = config["ResampleVolume2Path"]
    for id,l,g in data:
        segpost_image = "%s/%s.segpost.nii.gz" % (workdir,id)
        labelMapNCResampled = "%s/%s.labelMapNCsegmentation.nrrd" % (workdir,id)
        cmd = "%s %s %s -R %s -i nn" % (pathResampleVolume, \
                                        segpost_image, labelMapNCResampled, reference_image)
        system.run_process(cmd,verbose=True)
Esempio n. 5
0
def resample_segmentations(config, data, outputdir):
    workdir = "%s/Processing/1.MeasurementandSPHARM" % (outputDir)
    reference_image = "%s/%s.segpost.nii.gz" % (workdir, data[0][0])

    pathResampleVolume = config["ResampleVolume2Path"]
    for id, l, g in data:
        segpost_image = "%s/%s.segpost.nii.gz" % (workdir, id)
        labelMapNCResampled = "%s/%s.labelMapNCsegmentation.nrrd" % (workdir,
                                                                     id)
        cmd = "%s %s %s -R %s -i nn" % (pathResampleVolume, \
                                        segpost_image, labelMapNCResampled, reference_image)
        system.run_process(cmd, verbose=True)
Esempio n. 6
0
def resample_segmentations(opts,config,data,outputdir):
    workdir = "%s/Processing/1.MeasurementandSPHARM" % (outputdir)
    refid = data[0][0]
    reference_image = "{workdir}/{refid}.segpost.nii.gz".format(**locals())

    pathResampleVolume = config["ResampleVolume2Path"]
    for id,l,g in data:
        segpost_image = "{workdir}/{id}.segpost.nii.gz".format(**locals())
        labelMapNCResampled = "{workdir}/{id}.labelMapNCsegmentation.nrrd".format(**locals())
        cmd = "{pathResampleVolume} {segpost_image} {labelMapNCResampled} -R {reference_image} -i nn"
        if system.is_file_newer(labelMapNCResampled, segpost_image, opts.overwrite):
            cmd = cmd.format(**locals())
            system.run_process(cmd,verbose=True)
Esempio n. 7
0
def resample_segmentations(opts,config,data,outputdir):
    workdir = "%s/Processing/1.MeasurementandSPHARM" % (outputdir)
    refid = data[0][0]
    reference_image = "{workdir}/{refid}.segpost.nii.gz".format(**locals())

    pathResampleVolume = config["ResampleVolume2Path"]
    for id,l,g in data:
        segpost_image = "{workdir}/{id}.segpost.nii.gz".format(**locals())
        labelMapNCResampled = "{workdir}/{id}.labelMapNCsegmentation.nrrd".format(**locals())
        cmd = "{pathResampleVolume} {segpost_image} {labelMapNCResampled} -R {reference_image} -i nn"
        if system.is_file_newer(labelMapNCResampled, segpost_image, opts.overwrite):
            cmd = cmd.format(**locals())
            system.run_process(cmd,verbose=True)
Esempio n. 8
0
def paratospharm(opts, config, data, outputDir):
    workdir = "%s/Processing/1.MeasurementandSPHARM" % (outputDir)
    pathParaToSPHARM = config["ParaToSPHARMMeshCLPPath"]

    idlist = [id for id, l, g in data]
    parafiles = ["%s/%s.para.vtk" % (workdir, id) for id, l, g in data]
    surffiles = ["%s/%s.surf.vtk" % (workdir, id) for id, l, g in data]
    lowresfiles = ["%s/%s.ip.SPHARM.vtk" % (workdir, id) for id, l, g in data]
    highresfiles = [
        "%s/%s.subj.SPHARM.vtk" % (workdir, id) for id, l, g in data
    ]
    lowresparams = ["%s/%s.ip.Param.vtk" % (workdir, id) for id, l, g in data]
    highresparams = [
        "%s/%s.subj.Param.vtk" % (workdir, id) for id, l, g in data
    ]
    dataset = zip(parafiles, surffiles, lowresfiles, lowresparams,
                  highresfiles, highresparams)

    for idx, (pf, sf, lm, lp, hm, hp) in enumerate(dataset):
        # check if the parafile is newer than lm-output
        if system.is_file_newer(lm, pf, opts.overwrite):
            if idx == 0:
                id = idlist[idx]
                cmd = "{pathParaToSPHARM} {pf} {sf} --subdivLevel 10 --spharmDegree 20 " +\
                        " {workdir}/{id}.ip. --paraOut"
            else:
                id = idlist[idx]
                refid = idlist[0]
                cmd = "{pathParaToSPHARM} {pf} {sf} --subdivLevel 10 --spharmDegree 20  " +\
                        "{workdir}/{id}.ip. --flipTemplateOn " +\
                        "--flipTemplate {workdir}/{refid}.ip.SPHARM.coef --paraOut"
            cmd = cmd.format(**locals())
            system.run_process(cmd, verbose=opts.verbose)

    for idx, (pf, sf, lm, lp, hm, hp) in enumerate(dataset):
        # check if the parafile is newer than hm-output
        if system.is_file_newer(hm, pf, opts.overwrite):
            if idx == 0:
                id = idlist[idx]
                cmd = "{pathParaToSPHARM} {pf} {sf} --subdivLevel 50 --spharmDegree 20 " +\
                        "{workdir}/{id}.subj. --paraOut"
            else:
                id = idlist[idx]
                refid = idlist[0]
                cmd = "{pathParaToSPHARM} {pf} {sf} --subdivLevel 50 --spharmDegree 20 " +\
                        "{workdir}/{id}.subj. --flipTemplateOn " +\
                        "--flipTemplate {workdir}/{refid}.subj.SPHARM.coef --paraOut"
            cmd = cmd.format(**locals())
            system.run_process(cmd, verbose=opts.verbose)
Esempio n. 9
0
def run_particle_tools(config, data, outputdir, ids):
    pathPython = config["PythonPath"]
    pathShapeWorksScript = config["ShapeWorksPythonScriptPath"]
    pathShapeWorksRun = config["ShapeWorksRunPath"]
    pathImageMath = config["ImageMathPath"]
    pathShapeWorksGroom = config["ShapeWorksGroomPath"]
    pathBinaryToDistanceMap = config["BinaryToDistanceMapPath"]

    workdir = "%s/Processing/2.shapeworks" % (outputdir)

    # generate binary distance map for each label map
    # cmd = "%s %s %s/inputimage.txt %s/inputsurfacemodels.txt -c %s/outputCorrespondence.txt -w %s/outputWarped.txt --workingDir %s --pathShapeWorksRun %s --pathShapeWorksGroom %s --pathImageMath %s --pathBinaryToDistanceMap %s" % (pathPython, pathShapeWorksScript, workdir, workdir, workdir, workdir, workdir, pathShapeWorksRun, pathShapeWorksGroom, pathImageMath, pathBinaryToDistanceMap)
    cmd = "%s %s %s/inputimage.txt %s/inputsurfacemodels.txt " + \
            "-c %s/outputCorrespondence.txt -w %s/outputWarped.txt " +\
            "--workingDir %s" % (pathPython, pathShapeWorksScript, \
            workdir, workdir, workdir, workdir, workdir)
    system.run_process(cmd,verbose=True)
Esempio n. 10
0
def run_particle_tools(config, data, outputdir, ids):
    pathPython = config["PythonPath"]
    pathShapeWorksScript = config["ShapeWorksPythonScriptPath"]
    pathShapeWorksRun = config["ShapeWorksRunPath"]
    pathImageMath = config["ImageMathPath"]
    pathShapeWorksGroom = config["ShapeWorksGroomPath"]
    pathBinaryToDistanceMap = config["BinaryToDistanceMapPath"]

    workdir = "%s/Processing/2.shapeworks" % (outputdir)

    # generate binary distance map for each label map
    # cmd = "%s %s %s/inputimage.txt %s/inputsurfacemodels.txt -c %s/outputCorrespondence.txt -w %s/outputWarped.txt --workingDir %s --pathShapeWorksRun %s --pathShapeWorksGroom %s --pathImageMath %s --pathBinaryToDistanceMap %s" % (pathPython, pathShapeWorksScript, workdir, workdir, workdir, workdir, workdir, pathShapeWorksRun, pathShapeWorksGroom, pathImageMath, pathBinaryToDistanceMap)
    cmd = "%s %s %s/inputimage.txt %s/inputsurfacemodels.txt " + \
            "-c %s/outputCorrespondence.txt -w %s/outputWarped.txt " +\
            "--workingDir %s" % (pathPython, pathShapeWorksScript, \
            workdir, workdir, workdir, workdir, workdir)
    system.run_process(cmd, verbose=True)
Esempio n. 11
0
def paratospharm(opts, config, data, outputDir):
    workdir = "%s/Processing/1.MeasurementandSPHARM" % (outputDir)
    pathParaToSPHARM = config["ParaToSPHARMMeshCLPPath"]

    idlist = [id for id,l,g in data]
    parafiles = ["%s/%s.para.vtk"%(workdir,id) for id,l,g in data]
    surffiles = ["%s/%s.surf.vtk"%(workdir,id) for id,l,g in data]
    lowresfiles = ["%s/%s.ip.SPHARM.vtk"%(workdir,id) for id,l,g in data]
    highresfiles = ["%s/%s.subj.SPHARM.vtk"%(workdir,id) for id,l,g in data]
    lowresparams = ["%s/%s.ip.Param.vtk"%(workdir,id) for id,l,g in data]
    highresparams = ["%s/%s.subj.Param.vtk"%(workdir,id) for id,l,g in data]
    dataset = zip(parafiles, surffiles, lowresfiles, lowresparams, highresfiles, highresparams)

    for idx,(pf,sf,lm,lp,hm,hp) in enumerate(dataset):
        # check if the parafile is newer than lm-output
        if system.is_file_newer(lm, pf, opts.overwrite):
            if idx == 0:
                id = idlist[idx]
                cmd = "{pathParaToSPHARM} {pf} {sf} --subdivLevel 10 --spharmDegree 20 " +\
                        " {workdir}/{id}.ip. --paraOut"
            else:
                id = idlist[idx]
                refid = idlist[0]
                cmd = "{pathParaToSPHARM} {pf} {sf} --subdivLevel 10 --spharmDegree 20  " +\
                        "{workdir}/{id}.ip. --flipTemplateOn " +\
                        "--flipTemplate {workdir}/{refid}.ip.SPHARM.coef --paraOut"
            cmd = cmd.format(**locals())
            system.run_process(cmd,verbose=opts.verbose)


    for idx,(pf,sf,lm,lp,hm,hp) in enumerate(dataset):
        # check if the parafile is newer than hm-output
        if system.is_file_newer(hm, pf, opts.overwrite):
            if idx == 0:
                id = idlist[idx]
                cmd = "{pathParaToSPHARM} {pf} {sf} --subdivLevel 50 --spharmDegree 20 " +\
                        "{workdir}/{id}.subj. --paraOut"
            else:
                id = idlist[idx]
                refid = idlist[0]
                cmd = "{pathParaToSPHARM} {pf} {sf} --subdivLevel 50 --spharmDegree 20 " +\
                        "{workdir}/{id}.subj. --flipTemplateOn " +\
                        "--flipTemplate %s/%s.subj.SPHARM.coef --paraOut"
            cmd = cmd.format(**locals())
            system.run_process(cmd,verbose=opts.verbose)
Esempio n. 12
0
def compute_thickness(config, data, outputdir, ids, idl, idh):
    pathTool = config["measureThicknessFilterPath"]
    for (id, labelmap, group) in data:
        workdir = "%s/Processing/1.MeasurementandSPHARM/%s" % (outputdir, id)
        measurementoutput = "%s/Processing/1.MeasurementandSPHARM/%s_measurementoutput.nrrd" % (outputdir, id)

        # temporary
        #    workdir = "%s/Processing/1.MeasurementandSPHARM/%s_2" % (outputdir, id)
        labelmap = "%s/Processing/1.MeasurementandSPHARM/%s.boundaryMap.mha" % (outputdir, id)
        #    measurementoutput = "%s/Processing/1.MeasurementandSPHARM/%s.thickness.mha" % (outputdir, id)

        if (not os.path.exists(workdir)):
            os.makedirs(workdir)
        if (not os.path.isfile(measurementoutput)):
            cmd = "%s --mr --sbt --workdir %s --ids %s --idl %s --idh %s --ttrns 500 %s %s" % (pathTool, workdir, ids, idl, idh, labelmap, measurementoutput)
            print cmd
            system.run_process(cmd,verbose=True)
        else:
            print "Skipping", measurementoutput
Esempio n. 13
0
def paratospharm(opts, config, data, outputDir):
    workdir = "%s/Processing/1.MeasurementandSPHARM" % (outputDir)
    pathParaToSPHARM = config["ParaToSPHARMMeshCLPPath"]

    idlist = [id for id, l, g in data]
    parafiles = ["%s/%s.para.vtk" % (workdir, id) for id, l, g in data]
    surffiles = ["%s/%s.surf.vtk" % (workdir, id) for id, l, g in data]
    lowresfiles = ["%s/%s.ip.SPHARM.vtk" % (workdir, id) for id, l, g in data]
    highresfiles = [
        "%s/%s.subj.SPHARM.vtk" % (workdir, id) for id, l, g in data
    ]
    lowresparams = ["%s/%s.ip.Param.vtk" % (workdir, id) for id, l, g in data]
    highresparams = [
        "%s/%s.subj.Param.vtk" % (workdir, id) for id, l, g in data
    ]
    dataset = zip(parafiles, surffiles, lowresfiles, lowresparams,
                  highresfiles, highresparams)

    def file_exists(f):
        return not opts.overwrite and os.path.isfile(
            f) and os.stat(f).st_size > 0

    for idx, (pf, sf, lm, lp, hm, hp) in enumerate(dataset):
        if not file_exists(lm):
            if idx == 0:
                cmd = "%s %s %s --subdivLevel 10 --spharmDegree 20  %s/%s.ip. --paraOut" % (
                    pathParaToSPHARM, pf, sf, workdir, idlist[idx])
            else:
                cmd = "%s %s %s --subdivLevel 10 --spharmDegree 20  %s/%s.ip. --flipTemplateOn --flipTemplate %s/%s.ip.SPHARM.coef --paraOut" % (
                    pathParaToSPHARM, pf, sf, workdir, idlist[idx], workdir,
                    idlist[idx - 1])
            system.run_process(cmd, verbose=opts.verbose)

        if not file_exists(hm):
            if idx == 0:
                cmd = "%s %s %s --subdivLevel 50 --spharmDegree 20  %s/%s.subj. --paraOut" % (
                    pathParaToSPHARM, pf, sf, workdir, idlist[idx])
            else:
                cmd = "%s %s %s --subdivLevel 50 --spharmDegree 20  %s/%s.subj. --flipTemplateOn --flipTemplate %s/%s.subj.SPHARM.coef --paraOut" % (
                    pathParaToSPHARM, pf, sf, workdir, idlist[idx], workdir,
                    idlist[idx - 1])
            system.run_process(cmd, verbose=opts.verbose)
Esempio n. 14
0
def genparamesh(opts, config, data, outputDir):
    pathGenParaMesh = config["GenParaMeshCLPPath"]
    pathImageMath = config["ImageMathPath"]
    pathSegPostProcess = config["SegPostProcessCLPPath"]
    workdir = "{outputDir}/Processing/1.MeasurementandSPHARM".format(
        **locals())

    for (id, labelmap, group) in data:
        eulerName = "{workdir}/{id}.euler.txt".format(**locals())
        paraFile = "{workdir}/{id}.para.vtk".format(**locals())
        surfFile = "{workdir}/{id}.surf.vtk".format(**locals())
        surfaceLabel = "{workdir}/{id}.seg.nii.gz".format(**locals())
        segpostLabel = "{workdir}/{id}.segpost.nii.gz".format(**locals())

        if (not system.is_file_exist(surfaceLabel, opts.overwrite)):
            ids = opts.ids
            cmd = "{pathImageMath} {labelmap} -extractLabel {ids} -outfile {surfaceLabel}"
            cmd = cmd.format(**locals())
            system.run_process(cmd, verbose=opts.verbose)

        if (not system.is_file_exist(segpostLabel, opts.overwrite)):
            cmd = "{pathSegPostProcess} {surfaceLabel} {segpostLabel}"
            cmd = cmd.format(**locals())
            system.run_process(cmd, verbose=opts.verbose)

        if (not system.is_file_exist(paraFile, opts.overwrite)):
            num_iters = opts.genparamesh_iter
            cmd = "{pathGenParaMesh} --EulerFile --outEulerName {eulerName} {segpostLabel} " +\
                    "--iter {num_iters} --label 1 {paraFile} {surfFile}"
            cmd = cmd.format(**locals())
            system.run_process(cmd, verbose=opts.verbose)
Esempio n. 15
0
def genparamesh(opts, config, data, outputDir):
    pathGenParaMesh = config["GenParaMeshCLPPath"]
    pathImageMath = config["ImageMathPath"]
    pathSegPostProcess = "SegPostProcess" #config["SegPostProcess"]
    workdir = "%s/Processing/1.MeasurementandSPHARM" % (outputDir)

    # check if executables exist
    find_executables([pathGenParaMesh, pathImageMath, pathSegPostProcess])

    def file_exists(f):
        return not opts.overwrite and os.path.isfile(f) and os.stat(f).st_size > 0

    for (id, labelmap, group) in data:
        eulerName = "%s/%s.euler.txt" % (workdir, id)
        paraFile = "%s/%s.para.vtk" % (workdir, id)
        surfFile = "%s/%s.surf.vtk" % (workdir, id)
        surfaceLabel = "%s/%s.seg.nii.gz" % (workdir, id)
        segpostLabel = "%s/%s.segpost.nii.gz" % (workdir, id)

        if (not file_exists(surfaceLabel)):
            cmd = "%s %s -extractLabel %s -outfile %s" \
                  % (pathImageMath, labelmap, opts.ids, surfaceLabel)
            system.run_process(cmd,verbose=opts.verbose)

        if (not file_exists(segpostLabel)):
            cmd = "%s %s -o %s" \
                  % (pathSegPostProcess, surfaceLabel, segpostLabel)
            system.run_process(cmd,verbose=opts.verbose)

        if (not file_exists(paraFile)):
            num_iters = opts.genparamesh_iter
            cmd = "%s --EulerFile --outEulerName %s %s --iter %d --label %s %s %s" \
                  % (pathGenParaMesh, eulerName, segpostLabel, num_iters, 1, paraFile, surfFile)
            system.run_process(cmd,verbose=opts.verbose)
Esempio n. 16
0
def genparamesh(opts, config, data, outputDir):
    pathGenParaMesh = config["GenParaMeshCLPPath"]
    pathImageMath = config["ImageMathPath"]
    pathSegPostProcess = config["SegPostProcessCLPPath"]
    workdir = "{outputDir}/Processing/1.MeasurementandSPHARM".format(**locals())

    for (id, labelmap, group) in data:
        eulerName = "{workdir}/{id}.euler.txt".format(**locals())
        paraFile = "{workdir}/{id}.para.vtk".format(**locals())
        surfFile = "{workdir}/{id}.surf.vtk".format(**locals())
        surfaceLabel = "{workdir}/{id}.seg.nii.gz".format(**locals())
        segpostLabel = "{workdir}/{id}.segpost.nii.gz".format(**locals())

        if (not system.is_file_exist(surfaceLabel,opts.overwrite)):
            ids = opts.ids
            cmd = "{pathImageMath} {labelmap} -extractLabel {ids} -outfile {surfaceLabel}"
            cmd = cmd.format(**locals())
            system.run_process(cmd,verbose=opts.verbose)

        if (not system.is_file_exist(segpostLabel,opts.overwrite)):
            cmd = "{pathSegPostProcess} {surfaceLabel} {segpostLabel}"
            cmd = cmd.format(**locals())
            system.run_process(cmd,verbose=opts.verbose)

        if (not system.is_file_exist(paraFile,opts.overwrite)):
            num_iters = opts.genparamesh_iter
            cmd = "{pathGenParaMesh} --EulerFile --outEulerName {eulerName} {segpostLabel} " +\
                    "--iter {num_iters} --label 1 {paraFile} {surfFile}"
            cmd = cmd.format(**locals())
            system.run_process(cmd,verbose=opts.verbose)
Esempio n. 17
0
def genparamesh(opts, config, data, outputDir):
    pathGenParaMesh = config["GenParaMeshCLPPath"]
    pathImageMath = config["ImageMathPath"]
    pathSegPostProcess = "SegPostProcess"  #config["SegPostProcess"]
    workdir = "%s/Processing/1.MeasurementandSPHARM" % (outputDir)

    # check if executables exist
    find_executables([pathGenParaMesh, pathImageMath, pathSegPostProcess])

    def file_exists(f):
        return not opts.overwrite and os.path.isfile(
            f) and os.stat(f).st_size > 0

    for (id, labelmap, group) in data:
        eulerName = "%s/%s.euler.txt" % (workdir, id)
        paraFile = "%s/%s.para.vtk" % (workdir, id)
        surfFile = "%s/%s.surf.vtk" % (workdir, id)
        surfaceLabel = "%s/%s.seg.nii.gz" % (workdir, id)
        segpostLabel = "%s/%s.segpost.nii.gz" % (workdir, id)

        if (not file_exists(surfaceLabel)):
            cmd = "%s %s -extractLabel %s -outfile %s" \
                  % (pathImageMath, labelmap, opts.ids, surfaceLabel)
            system.run_process(cmd, verbose=opts.verbose)

        if (not file_exists(segpostLabel)):
            cmd = "%s %s -o %s" \
                  % (pathSegPostProcess, surfaceLabel, segpostLabel)
            system.run_process(cmd, verbose=opts.verbose)

        if (not file_exists(paraFile)):
            num_iters = opts.genparamesh_iter
            cmd = "%s --EulerFile --outEulerName %s %s --iter %d --label %s %s %s" \
                  % (pathGenParaMesh, eulerName, segpostLabel, num_iters, 1, paraFile, surfFile)
            system.run_process(cmd, verbose=opts.verbose)
Esempio n. 18
0
def compute_thickness(config, data, outputdir, ids, idl, idh):
    pathTool = config["measureThicknessFilterPath"]
    for (id, labelmap, group) in data:
        workdir = "%s/Processing/1.MeasurementandSPHARM/%s" % (outputdir, id)
        measurementoutput = "%s/Processing/1.MeasurementandSPHARM/%s_measurementoutput.nrrd" % (
            outputdir, id)

        # temporary
        #    workdir = "%s/Processing/1.MeasurementandSPHARM/%s_2" % (outputdir, id)
        labelmap = "%s/Processing/1.MeasurementandSPHARM/%s.boundaryMap.mha" % (
            outputdir, id)
        #    measurementoutput = "%s/Processing/1.MeasurementandSPHARM/%s.thickness.mha" % (outputdir, id)

        if (not os.path.exists(workdir)):
            os.makedirs(workdir)
        if (not os.path.isfile(measurementoutput)):
            cmd = "%s --mr --sbt --workdir %s --ids %s --idl %s --idh %s --ttrns 500 %s %s" % (
                pathTool, workdir, ids, idl, idh, labelmap, measurementoutput)
            print cmd
            system.run_process(cmd, verbose=True)
        else:
            print "Skipping", measurementoutput
Esempio n. 19
0
def compute_thickness(opts, config, data, outputdir, ids, idl, idh):
    pathThicknessTool = config["measureThicknessFilterPath"]
    for (id, labelmap, group) in data:
        labelmap = "{outputdir}/Processing/1.MeasurementandSPHARM/{id}.boundaryMap.mha".format(**locals())
        # temporary
        #    workdir = "%s/Processing/1.MeasurementandSPHARM/%s_2" % (outputdir, id)
        #    measurementoutput = "%s/Processing/1.MeasurementandSPHARM/%s.thickness.mha" % (outputdir, id)

        workdir = "{outputdir}/Processing/1.MeasurementandSPHARM/{id}".format(**locals())
        measurementoutput = "{outputdir}/Processing/1.MeasurementandSPHARM/" +\
                        "{id}_measurementoutput.nrrd"
        measurementoutput = measurementoutput.format(**locals())

        if (not os.path.exists(workdir)):
            os.makedirs(workdir)

        if system.is_file_newer(measurementoutput, labelmap, opts.overwrite) or \
                system.is_file_newer(measurementoutput, "{workdir}/laplacianCache.nii.gz".format(**locals()), opts.overwrite):
            cmd = "{pathThicknessTool} --mr --sbt --ids {ids} --idl {idl} --idh {idh} --ttrns 500 " +\
                "--workdir {workdir} --cachedLaplacianOutput laplacianCache.nii.gz {labelmap} {measurementoutput}"
            cmd = cmd.format(**locals())
            system.run_process(cmd,verbose=True)
Esempio n. 20
0
def compute_thickness(opts, config, data, outputdir, ids, idl, idh, idn):
    pathThicknessTool = config["measureThicknessFilterPath"]
    for (id, labelmap, group) in data:
        labelmap = "{outputdir}/Processing/1.MeasurementandSPHARM/{id}.boundaryMap.mha".format(**locals())
        # temporary
        #    workdir = "%s/Processing/1.MeasurementandSPHARM/%s_2" % (outputdir, id)
        #    measurementoutput = "%s/Processing/1.MeasurementandSPHARM/%s.thickness.mha" % (outputdir, id)

        workdir = "{outputdir}/Processing/1.MeasurementandSPHARM/{id}".format(**locals())
        measurementoutput = "{outputdir}/Processing/1.MeasurementandSPHARM/" +\
                        "{id}_measurementoutput.nrrd"
        measurementoutput = measurementoutput.format(**locals())

        if (not os.path.exists(workdir)):
            os.makedirs(workdir)

        if system.is_file_newer(measurementoutput, labelmap, opts.overwrite) or \
                system.is_file_newer(measurementoutput, "{workdir}/laplacianCache.nii.gz".format(**locals()), opts.overwrite):
            cmd = "{pathThicknessTool} --mr --sbt --ids {ids} --idl {idl} --idh {idh} --idn {idn} --ttrns 500 " +\
                "--workdir {workdir} --cachedLaplacianOutput laplacianCache.nii.gz {labelmap} {measurementoutput}"
            cmd = cmd.format(**locals())
            system.run_process(cmd,verbose=True)
Esempio n. 21
0
def perform_analysis(opts, config, csvdata, outputDir, corr_opt="initial_dense"):
    ids = [i for i,l,g in csvdata]
    groups = [g for i,l,g in csvdata]

    meshDir = "{outputDir}/Processing/1.MeasurementandSPHARM".format(**locals())
    shapeworksDir = "{outputDir}/Processing/2.shapeworks".format(**locals())
    sampleDir = "{outputDir}/Processing/3.sampling".format(**locals())
    statDir = "{outputDir}/Statistics".format(**locals())

    sample_thickness(opts,config,csvdata,outputDir,corr_opt)

    # collect_attributes()
    # compute_statistics()
    # aggregate sampling files into a single file
    groupSet = set(groups)
    datafiles = []
    tag = ""
    for group in groupSet:
        # setup output filename template
        if (corr_opt == "initial_dense"):
            tag = "_initialDenseSampling"
            datafilename = "%s/data_initialDenseSampling_%s.txt" % (statDir, group)
            dataregionfilename = "%s/data_region_initialDenseSampling_%s.txt" % (statDir, group)
            outfilename = "%s/list_initialDenseSampling_%s.txt" % (statDir, group)
        elif (corr_opt == "correspondence"):
            tag = ""
            datafilename = "%s/data_%s.txt" % (statDir, group)
            dataregionfilename = "%s/data_region_%s.txt" % (statDir, group)
            outfilename = "%s/list_%s.txt" % (statDir, group)
        elif (corr_opt == "dense_correspondence"):
            tag = "_dense"
            datafilename = "%s/data_dense_%s.txt" % (statDir, group)
            dataregionfilename = "%s/data_region_dense_%s.txt" % (statDir, group)
            outfilename = "%s/list_dense_%s.txt" % (statDir, group)
        elif (corr_opt == "spharm_sampling"):
            tag = "_spharm"
            datafilename = "%s/data_spharm_%s.txt" % (statDir, group)
            dataregionfilename = "%s/data_region_spharm_%s.txt" % (statDir, group)
            outfilename = "%s/list_spharm_%s.txt" % (statDir, group)


        # process and write the aggregated data
        outfile = open(outfilename, 'w')
        for (id, g) in zip(ids, groups):
            if (g != group):
                continue
            if (corr_opt == "initial_dense"):
                samplingTxt = "%s/%s.smoothInitialDenseSampling.txt" % (sampleDir, id)
            elif (corr_opt == "correspondence"):
                samplingTxt = "%s/%s.smoothSampling.txt" % (sampleDir, id)
            elif (corr_opt == "dense_correspondence"):
                samplingTxt = "%s/%s.smoothDenseSampling.txt" % (sampleDir, id)
            elif (corr_opt == "spharm_sampling"):
                samplingTxt = "%s/%s.smoothSpharmSampling.txt" % (sampleDir, id)
            if (os.path.isfile(samplingTxt)):
                outfile.write(samplingTxt)
                outfile.write("\n")
            else:
                print "can't find", samplingTxt
        outfile.close()

        # concatenate those attribute files into a file
        concatColumnsToFile(outfilename, datafilename)
        datafiles.append((group, datafilename))

    # perform statistical analysis
    rscriptExePath = config["RscriptPath"]
    rscriptPath = os.path.dirname(os.path.abspath(__file__)) + "/rodentThicknessStats.r"
    if (corr_opt == "initial_dense"):
        outputfile = "%s/stats.initialDenseSampling.txt" % statDir
        outputVTK = "%s/stats.initialDenseSampling.vtk" % (statDir)
        inputVTK = "%s/%s.subj.SPHARM.vtk" % (meshDir, ids[0])
    elif (corr_opt == "correspondence"):
        outputfile = "%s/stats.correspondence.txt" % statDir
        outputVTK = "%s/stats.correspondence.vtk" % (statDir)
        inputVTK = "%s/%s.correspondence.vtk" % (shapeworksDir, ids[0])
    elif (corr_opt == "dense_correspondence"):
        outputfile = "%s/stats.denseCorrespondence.txt" % statDir
        outputVTK = "%s/stats.denseCorrespondence.vtk" % (statDir)
        inputVTK = "%s/%s.dense_correspondence.vtk" % (shapeworksDir, ids[0])
    elif (corr_opt == "spharm_sampling"):
        outputfile = "%s/stats.spharmCorrespondence.txt" % statDir
        outputVTK = "%s/stats.spharmCorrespondence.vtk" % (statDir)
        inputVTK = "%s/%s.subj.SPHARM.vtk" % (meshDir, ids[0])

    #pythonScriptPath = config["vtkPointAttributesPythonScriptPath"]

    pathKmesh = config["kmeshPath"]
    datafilelist = ""
    datagroups = ""
    for (group, file) in datafiles:
        datafilelist = datafilelist + " " + file
        datagroups = datagroups + " " + group

        # compute per-group statistics
        cmd = "%s -computeVectorStats -scalarName %s -importVectors %s %s %s/%s_thickness.vtk" % (pathKmesh, group + "_Thickness", inputVTK, file, statDir, group)
        system.run_process(cmd,verbose=True)


    if (len(datafiles) > 1):
        runCmd = "%s %s %s %s %s" % (rscriptExePath, rscriptPath, datafilelist, outputfile, datagroups)
        system.run_process(runCmd,verbose=True)
        #visCmd = "%s %s %s %s -i %s -t" % (pythonPath, pythonScriptPath, inputVTK, outputVTK, outputfile)
        visCmd = "%s -use-header %s %s -importCSV %s" % (pathKmesh, inputVTK, outputVTK, outputfile)
        system.run_process(visCmd,verbose=True)

        # connected components for p-value
        print "computing connected components with t.pvalue..."
        runCmd = "%s -connectScalars %s -scalarName t.pvalue %s -thresholdMin 0 -thresholdMax 0.05" % (pathKmesh, outputVTK, outputVTK)
        system.run_process(runCmd,verbose=True)

        print "export scalars..."
        runCmd = "%s -exportScalars -scalarName RegionIds %s %s/regionIds.txt" % (pathKmesh, outputVTK, statDir)
        system.run_process(runCmd,verbose=True)

        # create a combined data file with regions
        regionIdFile = "%s/regionIds.txt" % (statDir)
        if os.path.exists(regionIdFile):
            for (group, file) in datafiles:
                dataregionfilename = "%s/data_region%s_%s.txt" % (statDir, tag, group)
                concatColumnsToFile([regionIdFile, "%s/data%s_%s.txt" % (statDir, tag, group)], dataregionfilename, inputIsList = True)
                # perform splitting
                performSplit([dataregionfilename], "%s/data_%s_region_" % (statDir, group) + "%02d.txt")

            # boxplot
            draw_boxplot = True
            if draw_boxplot:
                groupList = list(groupSet)
                try:
                    print sys.path
                    import boxplot
                    gr1 = groupList[0]
                    gr2 = groupList[1]
                    boxplot.draw_boxplot(groupList[0], groupList[1], \
                        "{statDir}/data_{gr1}_region_*.txt".format(**locals()), \
                        "{statDir}/data_{gr2}_region_*.txt".format(**locals()), \
                        "{statDir}/{gr1}_{gr2}_regions.pdf".format(**locals()))
                except BaseException as e:
                    print system.bcolors.WARNING + e.message + system.bcolors.ENDC
                    pass
Esempio n. 22
0
def performAnalysis(cvsdata, config, outputDir, opt="initial_dense"):
    ids = []
    groups = []
    for (id, labelmap, group) in cvsdata:
        ids.append(id)
        groups.append(group)

    meshDir = "%s/Processing/1.MeasurementandSPHARM" % (outputDir)
    shapeworksDir = "%s/Processing/2.shapeworks" % (outputDir)
    sampleDir = "%s/Processing/3.meshintensity" % (outputDir)
    statDir = "%s/Statistical" % (outputDir)
    pathKmesh = config["kmeshPath"]

    if (opt == "initial_dense"):
        samplingCmd = config[
            "MeshPointIntensitySamplingPath"] + " --workDir %s --inputAsPhysicalCoord --inputPointFlip --distanceVector %s -i nn -a %s -m %s --smoothedAttributeOutput %s --originalMeshOutput %s %s %s"
    else:
        samplingCmd = config[
            "MeshPointIntensitySamplingPath"] + " --workDir %s --inputAsPhysicalCoord --distanceVector %s -i nn -a %s -m %s --smoothedAttributeOutput %s --originalMeshOutput %s %s %s"

    # depending on options, choose different meshes
    # loop over ids
    for id in ids:
        distanceVector = "%s/%s.distanceVector.nrrd" % (sampleDir, id)
        inputMeasurement = "%s/%s_measurementoutput.nrrd" % (meshDir, id)
        #    inputMeasurement = "%s/%s.thickness.mha" % (meshDir, id)
        if (opt == "initial_dense"):
            samplingTxt = "%s/%s.initialDenseSampling.txt" % (sampleDir, id)
            smoothSamplingTxt = "%s/%s.smoothInitialDenseSampling.txt" % (
                sampleDir, id)
            samplingMeshOutput = "%s/%s.initialDenseSampling.vtk" % (sampleDir,
                                                                     id)
            originalMeshOutput = "%s/%s.initialDenseOriginal.vtk" % (sampleDir,
                                                                     id)
            inputMesh = "%s/%s.subj.SPHARM.vtk" % (meshDir, id)
        elif (opt == "correspondence"):
            samplingTxt = "%s/%s.sampling.txt" % (sampleDir, id)
            smoothSamplingTxt = "%s/%s.smoothSampling.txt" % (sampleDir, id)
            samplingMeshOutput = "%s/%s.sampling.vtk" % (sampleDir, id)
            originalMeshOutput = "%s/%s.original.vtk" % (sampleDir, id)
            inputMesh = "%s/%s.correspondence.vtk" % (shapeworksDir, id)
        elif (opt == "dense_correspondence"):
            samplingTxt = "%s/%s.denseSampling.txt" % (sampleDir, id)
            smoothSamplingTxt = "%s/%s.smoothDenseSampling.txt" % (sampleDir,
                                                                   id)
            samplingMeshOutput = "%s/%s.denseSampling.vtk" % (sampleDir, id)
            originalMeshOutput = "%s/%s.denseOriginal.vtk" % (sampleDir, id)
            inputMesh = "%s/%s.dense_correspondence.vtk" % (shapeworksDir, id)
        elif (opt == "spharm_sampling"):
            samplingTxt = "%s/%s.spharmSampling.txt" % (sampleDir, id)
            smoothSamplingTxt = "%s/%s.smoothSpharmSampling.txt" % (sampleDir,
                                                                    id)
            samplingMeshOutput = "%s/%s.spharmSampling.vtk" % (sampleDir, id)
            originalMeshOutput = "%s/%s.spharmOriginal.vtk" % (sampleDir, id)
            inputMesh = "%s/%s.subj.SPHARM.vtk" % (meshDir, id)

        # execute sampling
        # exeCmd = samplingCmd % (outputDir, distanceVector, samplingTxt, samplingMeshOutput, smoothSamplingTxt, originalMeshOutput, inputMeasurement, inputMesh)
        # new sampling command
        useStreamLine = True and opt == "spharm_sampling"
        if (not useStreamLine):
            exeCmd = "%s -sampleImage %s %s %s -outputScalarName Thickness -zrotate" % (
                pathKmesh, inputMeasurement, inputMesh, samplingMeshOutput)
            system.run_process(exeCmd, verbose=True)

            exeCmd = "%s -smoothScalars %s %s -scalarName Thickness -outputScalarName smoothThickness -iter 3" % (
                pathKmesh, samplingMeshOutput, samplingMeshOutput)
            system.run_process(exeCmd, verbose=True)

            exeCmd = "%s -exportScalars %s %s -scalarName Thickness " % (
                pathKmesh, samplingMeshOutput, samplingTxt)
            system.run_process(exeCmd, verbose=True)

            exeCmd = "%s -exportScalars %s %s -scalarName smoothThickness " % (
                pathKmesh, samplingMeshOutput, smoothSamplingTxt)
            system.run_process(exeCmd, verbose=True)
        else:
            gradientFile = "%s/Processing/1.MeasurementandSPHARM/%s/laplacianGradient.nrrd" % (
                outputDir, id)
            gradientVTIFile = "%s/Processing/1.MeasurementandSPHARM/%s/laplacianGradient.vti" % (
                outputDir, id)
            streamLineFile = "%s/Processing/1.MeasurementandSPHARM/%s/stream_lines.vtp" % (
                outputDir, id)

            # vti image creation
            exeCmd = "%s -vti %s %s -attrDim 3" % (pathKmesh, gradientFile,
                                                   gradientVTIFile)
            system.run_process(exeCmd, verbose=True)

            # RK45 integration
            exeCmd = "%s -traceStream %s %s %s %s -zrotate -traceDirection backward" % (
                pathKmesh, gradientVTIFile, inputMesh, streamLineFile,
                samplingMeshOutput)
            system.run_process(exeCmd, verbose=True)

            # scalar export
            exeCmd = "%s -exportScalars %s %s -scalarName Length " % (
                pathKmesh, samplingMeshOutput, smoothSamplingTxt)
            system.run_process(exeCmd, verbose=True)

    # aggregate sampling files into a single file
    groupSet = set(groups)
    datafiles = []
    tag = ""
    for group in groupSet:
        # setup output filename template
        if (opt == "initial_dense"):
            tag = "_initialDenseSampling"
            datafilename = "%s/data_initialDenseSampling_%s.txt" % (statDir,
                                                                    group)
            dataregionfilename = "%s/data_region_initialDenseSampling_%s.txt" % (
                statDir, group)
            outfilename = "%s/list_initialDenseSampling_%s.txt" % (statDir,
                                                                   group)
        elif (opt == "correspondence"):
            tag = ""
            datafilename = "%s/data_%s.txt" % (statDir, group)
            dataregionfilename = "%s/data_region_%s.txt" % (statDir, group)
            outfilename = "%s/list_%s.txt" % (statDir, group)
        elif (opt == "dense_correspondence"):
            tag = "_dense"
            datafilename = "%s/data_dense_%s.txt" % (statDir, group)
            dataregionfilename = "%s/data_region_dense_%s.txt" % (statDir,
                                                                  group)
            outfilename = "%s/list_dense_%s.txt" % (statDir, group)
        elif (opt == "spharm_sampling"):
            tag = "_spharm"
            datafilename = "%s/data_spharm_%s.txt" % (statDir, group)
            dataregionfilename = "%s/data_region_spharm_%s.txt" % (statDir,
                                                                   group)
            outfilename = "%s/list_spharm_%s.txt" % (statDir, group)

        # process and write the aggregated data
        outfile = open(outfilename, 'w')
        for (id, g) in zip(ids, groups):
            if (g != group):
                continue
            if (opt == "initial_dense"):
                samplingTxt = "%s/%s.smoothInitialDenseSampling.txt" % (
                    sampleDir, id)
            elif (opt == "correspondence"):
                samplingTxt = "%s/%s.smoothSampling.txt" % (sampleDir, id)
            elif (opt == "dense_correspondence"):
                samplingTxt = "%s/%s.smoothDenseSampling.txt" % (sampleDir, id)
            elif (opt == "spharm_sampling"):
                samplingTxt = "%s/%s.smoothSpharmSampling.txt" % (sampleDir,
                                                                  id)
            if (os.path.isfile(samplingTxt)):
                outfile.write(samplingTxt)
                outfile.write("\n")
            else:
                print "can't find", samplingTxt
        outfile.close()

        # concatenate those attribute files into a file
        concatColumnsToFile(outfilename, datafilename)
        datafiles.append((group, datafilename))

    # perform statistical analysis
    rscriptExePath = config["RScriptPath"]
    rscriptPath = config["RScriptRodentThicknessPath"]
    if (opt == "initial_dense"):
        outputfile = "%s/stats.initialDenseSampling.txt" % statDir
        outputVTK = "%s/stats.initialDenseSampling.vtk" % (statDir)
        inputVTK = "%s/%s.subj.SPHARM.vtk" % (meshDir, ids[0])
    elif (opt == "correspondence"):
        outputfile = "%s/stats.correspondence.txt" % statDir
        outputVTK = "%s/stats.correspondence.vtk" % (statDir)
        inputVTK = "%s/%s.correspondence.vtk" % (shapeworksDir, ids[0])
    elif (opt == "dense_correspondence"):
        outputfile = "%s/stats.denseCorrespondence.txt" % statDir
        outputVTK = "%s/stats.denseCorrespondence.vtk" % (statDir)
        inputVTK = "%s/%s.dense_correspondence.vtk" % (shapeworksDir, ids[0])
    elif (opt == "spharm_sampling"):
        outputfile = "%s/stats.spharmCorrespondence.txt" % statDir
        outputVTK = "%s/stats.spharmCorrespondence.vtk" % (statDir)
        inputVTK = "%s/%s.subj.SPHARM.vtk" % (meshDir, ids[0])

    pythonPath = config["PythonPath"]
    pythonScriptPath = config["vtkPointAttributesPythonScriptPath"]

    datafilelist = ""
    datagroups = ""
    for (group, file) in datafiles:
        datafilelist = datafilelist + " " + file
        datagroups = datagroups + " " + group

        # compute per-group statistics
        cmd = "%s -computeVectorStats -scalarName %s -importVectors %s %s %s/%s_thickness.vtk" % (
            pathKmesh, group + "_Thickness", inputVTK, file, statDir, group)
        print cmd
        system.run_process(cmd, verbose=True)

    if (len(datafiles) > 1):
        runCmd = "%s %s %s %s %s" % (rscriptExePath, rscriptPath, datafilelist,
                                     outputfile, datagroups)
        system.run_process(runCmd, verbose=True)
        visCmd = "%s %s %s %s -i %s -t" % (pythonPath, pythonScriptPath,
                                           inputVTK, outputVTK, outputfile)
        system.run_process(visCmd, verbose=True)

        # connected components for p-value
        print "computing connected components with t.pvalue..."
        runCmd = "%s -connectScalars %s -scalarName t.pvalue %s -thresholdMin 0 -thresholdMax 0.05" % (
            pathKmesh, outputVTK, outputVTK)
        system.run_process(runCmd, verbose=True)

        print "export scalars..."
        runCmd = "%s -exportScalars -scalarName RegionIds %s %s/regionIds.txt" % (
            pathKmesh, outputVTK, statDir)
        system.run_process(runCmd, verbose=True)

        # create a combined data file with regions
        regionIdFile = "%s/regionIds.txt" % (statDir)
        if os.path.exists(regionIdFile):
            for (group, file) in datafiles:
                dataregionfilename = "%s/data_region%s_%s.txt" % (statDir, tag,
                                                                  group)
                concatColumnsToFile(
                    [regionIdFile,
                     "%s/data%s_%s.txt" % (statDir, tag, group)],
                    dataregionfilename,
                    inputIsList=True)
                # perform splitting
                performSplit([dataregionfilename], "%s/data_%s_region_" %
                             (statDir, group) + "%02d.txt")

            # boxplot
            groupList = list(groupSet)
            runCmd = "%s %s '%s' '%s' %s/%s_%s_regions.pdf --label1 %s --label2 %s" % (
                pythonPath,
                pythonScriptPath.replace(
                    "vtkPointAttributes.py",
                    "boxplot.py"), "%s/data_%s_region_*.txt" %
                (statDir, groupList[0]), "%s/data_%s_region_*.txt" %
                (statDir, groupList[1]), statDir, groupList[0], groupList[1],
                groupList[0], groupList[1])
            print runCmd
            system.run_process(runCmd, verbose=True)
Esempio n. 23
0
def sample_thickness(opts,config,csvdata,outputDir,corr_opt):
    meshDir = "{outputDir}/Processing/1.MeasurementandSPHARM".format(**locals())
    shapeworksDir = "{outputDir}/Processing/2.shapeworks".format(**locals())
    sampleDir = "{outputDir}/Processing/3.sampling".format(**locals())
    statDir = "{outputDir}/Statistics".format(**locals())
    pathKmesh = config["kmeshPath"]

    if (corr_opt == "initial_dense"):
        extra_args = "--inputPointFlip"
    else:
        extra_args = ""

    # depending on options, choose different meshes
    # loop over ids
    for id in [i for i,l,g in csvdata]:
        distanceVector = "{sampleDir}/{id}.distanceVector.nrrd".format(**locals())
        inputMeasurement = "{meshDir}/{id}_measurementoutput.nrrd".format(**locals())
        #    inputMeasurement = "%s/%s.thickness.mha" % (meshDir, id)
        if (corr_opt == "initial_dense"):
            samplingTxt = "%s/%s.initialDenseSampling.txt" % (sampleDir, id)
            smoothSamplingTxt = "%s/%s.smoothInitialDenseSampling.txt" % (sampleDir, id)
            samplingMeshOutput = "%s/%s.initialDenseSampling.vtk" % (sampleDir, id)
            originalMeshOutput = "%s/%s.initialDenseOriginal.vtk" % (sampleDir, id)
            inputMesh = "%s/%s.subj.SPHARM.vtk" % (meshDir, id)
        elif (corr_opt == "correspondence"):
            samplingTxt = "%s/%s.sampling.txt" % (sampleDir, id)
            smoothSamplingTxt = "%s/%s.smoothSampling.txt" % (sampleDir, id)
            samplingMeshOutput = "%s/%s.sampling.vtk" % (sampleDir, id)
            originalMeshOutput = "%s/%s.original.vtk" % (sampleDir, id)
            inputMesh = "%s/%s.correspondence.vtk" % (shapeworksDir, id)
        elif (corr_opt == "dense_correspondence"):
            samplingTxt = "%s/%s.denseSampling.txt" % (sampleDir, id)
            smoothSamplingTxt = "%s/%s.smoothDenseSampling.txt" % (sampleDir, id)
            samplingMeshOutput = "%s/%s.denseSampling.vtk" % (sampleDir, id)
            originalMeshOutput = "%s/%s.denseOriginal.vtk" % (sampleDir, id)
            inputMesh = "%s/%s.dense_correspondence.vtk" % (shapeworksDir, id)
        elif (corr_opt == "spharm_sampling"):
            samplingTxt = "%s/%s.spharmSampling.txt" % (sampleDir, id)
            smoothSamplingTxt = "%s/%s.smoothSpharmSampling.txt" % (sampleDir, id)
            samplingMeshOutput = "%s/%s.spharmSampling.vtk" % (sampleDir, id)
            originalMeshOutput = "%s/%s.spharmOriginal.vtk" % (sampleDir, id)
            inputMesh = "%s/%s.subj.SPHARM.vtk" % (meshDir, id)


        #samplingCmd = "{MeshPointIntensitySamplingPath} --workDir {workdir} --inputAsPhysicalCoord {extra_args} --distanceVector {distanceVector} -i nn -a {samplingTxt} -m {samplingMeshOutput} --smoothedAttributeOutput {smoothSamplingTxt} --originalMeshOutput {originalMeshOutput} {inputMeasurement} {inputMesh}"
        #exeCmd = samplingCmd.format(**locals())
        # exeCmd = samplingCmd % (outputDir, distanceVector, samplingTxt, samplingMeshOutput, smoothSamplingTxt, originalMeshOutput, inputMeasurement, inputMesh)
        #system.run_process(exeCmd,verbose=True)

        if system.is_file_newer(smoothSamplingTxt, inputMeasurement, opts.overwrite) or \
                system.is_file_newer(smoothSamplingTxt, samplingTxt, opts.overwrite) or \
                system.is_file_newer(smoothSamplingTxt, samplingMeshOutput, opts.overwrite):
            useStreamLine = corr_opt == "spharm_sampling"
            if (not useStreamLine):
                exeCmd = "{pathKmesh} -sampleImage {inputMeasurement} {inputMesh} {samplingMeshOutput} " +\
                            "-outputScalarName Thickness -zrotate"
                exeCmd = exeCmd.format(**locals())
                system.run_process(exeCmd,verbose=True)

                exeCmd = "{pathKmesh} -smoothScalars {samplingMeshOutput} {samplingMeshOutput} " +\
                            "-scalarName Thickness -outputScalarName smoothThickness -iter 3"
                exeCmd = exeCmd.format(**locals())
                system.run_process(exeCmd,verbose=True)

                exeCmd = "{pathKmesh} -exportScalars {samplingMeshOutput} {samplingTxt} -scalarName Thickness"
                exeCmd = exeCmd.format(**locals())
                system.run_process(exeCmd,verbose=True)

                exeCmd = "{pathKmesh} -exportScalars {samplingMeshOutput} {smoothSamplingTxt} " +\
                            "-scalarName smoothThickness "
                exeCmd = exeCmd.format(**locals())
                system.run_process(exeCmd,verbose=True)
            else:
                gradientFile = "{outputDir}/Processing/1.MeasurementandSPHARM/" +\
                        "{id}/laplacianGradient.nrrd".format(**locals())
                gradientVTIFile = "{outputDir}/Processing/1.MeasurementandSPHARM/" +\
                        "{id}/laplacianGradient.vti".format(**locals())
                streamLineFile = "{outputDir}/Processing/1.MeasurementandSPHARM/" +\
                        "{id}/stream_lines.vtp".format(**locals())

                # vti image creation
                exeCmd = "{pathKmesh} -vti {gradientFile} {gradientVTIFile} -attrDim 3"
                exeCmd = exeCmd.format(**locals())
                system.run_process(exeCmd,verbose=True)

                # RK45 integration
                exeCmd = "{pathKmesh} -zrotate -traceDirection backward -traceStream " +\
                    "{gradientVTIFile} {inputMesh} {streamLineFile} {samplingMeshOutput}"
                exeCmd = exeCmd.format(**locals())
                system.run_process(exeCmd,verbose=True)

                # scalar export
                exeCmd = "{pathKmesh} -scalarName Length -exportScalars " +\
                    "{samplingMeshOutput} {smoothSamplingTxt}"
                exeCmd = exeCmd.format(**locals())
                system.run_process(exeCmd,verbose=True)
Esempio n. 24
0
def regenerate_segmentations(data, config, outputdir):
    pathKmesh = config["kmeshPath"]
    pathKcalc = config["kcalcPath"]
    workdir = "{outputdir}/Processing/1.MeasurementandSPHARM".format(
        **locals())

    # before executing the boundary correction
    # check if none of input is not generated.
    testLabelMapsFail = False in [os.path.exists(x) for (t, x, g) in data]
    if testLabelMapsFail:
        raise RuntimeError("There are missing label maps")

    surfaceInputList = [
        "{workdir}/{id}.subj.SPHARM.vtk".format(**locals())
        for (id, l, g) in data
    ]
    testSurfaceInputsFail = False in [
        os.path.exists(x) for x in surfaceInputList
    ]
    if testSurfaceInputsFail:
        raise RuntimeError(
            "There are missing surface inputs. Check SPHARM results!")

    if opts.nop1 is False:
        for idx, (id, labelMap, group) in enumerate(data):
            labelOutput = "{workdir}/{id}.zerocortex.nrrd".format(**locals())
            surfaceInput = "{workdir}/{id}.subj.SPHARM.vtk".format(**locals())
            #surfaceInput = "{workdir}/{id}.surf.vtk".format(**locals())
            surfaceLabels = "{workdir}/{id}.labels.vtp".format(**locals())

            if system.is_file_newer(labelOutput, labelMap, opts.overwrite):
                cmd = "{pathKcalc} -e 'A==3?0:A' -o {labelOutput} {labelMap}"
                cmd = cmd.format(**locals())
                if system.run_process(cmd, verbose=True) != 0:
                    raise RuntimeError("fail to modify labelmap")

            if system.is_file_newer(surfaceLabels, surfaceInput, opts.overwrite) or \
                    system.is_file_newer(surfaceLabels, labelOutput, opts.overwrite):
                cmd = "{pathKmesh} -sampleImage -zrotate -outputScalarName labels " + \
                        "{labelOutput} {surfaceInput} {surfaceLabels}"
                cmd = cmd.format(**locals())
                if system.run_process(cmd, verbose=True) != 0:
                    raise RuntimError("fail to run kmesh")

    # compute the average of labels scalar values to smooth out
    if opts.nop2 is False:
        cmd = "{pathKmesh} -averageScalars -threshold 1.8 " + \
              "-scalarName labels -outputScalarName meanLabels"
        cmd = cmd.format(**locals())
        for (tag, labelmap, group) in data:
            surfaceMeshWithLabels = "{workdir}/{tag}.labels.vtp".format(
                **locals())
            cmd += " " + surfaceMeshWithLabels
        system.run_process(cmd, verbose=True)

    if opts.nop3 is False:
        for idx, (tag, labelMap, group) in enumerate(data):
            labelOutput = "{workdir}/{tag}.zerocortex.nrrd".format(**locals())
            surfaceLabels = "{workdir}/{tag}.labels.vtp".format(**locals())
            voronoiImage = "{workdir}/{tag}.voronoi.mha".format(**locals())
            surfaceImage = "{workdir}/{tag}.solution.mha".format(**locals())
            boundaryMap = "{workdir}/{tag}.boundaryMap.mha".format(**locals())

            if system.is_file_newer(labelOutput, voronoiImage, opts.overwrite) or \
                    system.is_file_newer(surfaceLabels, voronoiImage, opts.overwrite):
                cmd = "{pathKmesh} -voronoiImage -zrotate -scalarName meanLabels " +\
                    "{labelOutput} {surfaceLabels} -o {voronoiImage}"
                cmd = cmd.format(**locals())
                system.run_process(cmd, verbose=True)

            if system.is_file_newer(labelOutput, voronoiImage, opts.overwrite) or \
                    system.is_file_newer(surfaceLabels, voronoiImage, opts.overwrite):
                cmd = "{pathKmesh} -scanConversion -zrotate " +\
                    "{surfaceLabels} {labelOutput} {surfaceImage}"
                cmd = cmd.format(**locals())
                system.run_process(cmd, verbose=True)

            if system.is_file_newer(voronoiImage, boundaryMap, opts.overwrite) or \
                    system.is_file_newer(surfaceImage, boundaryMap, opts.overwrite):
                cmd = "{pathKcalc} -e 'B>0?3:A' -o {boundaryMap} " +\
                    "{voronoiImage} {surfaceImage}"
                cmd = cmd.format(**locals())
                system.run_process(cmd, verbose=True)
Esempio n. 25
0
import system
import sys
import logging

system.setup_logger(logfilename="test.log")
retcode = system.run_process("/devel/linux/SPHARM-PDM/spharm-pdm-build-joowhi/bin/GenParaMeshCLP %s %s %s" % (sys.argv[1], sys.argv[2], sys.argv[3]), verbose=True)
print "Return Code = ", retcode
Esempio n. 26
0
def regenerate_segmentations(data, config, outputdir):
    pathKmesh = config["kmeshPath"]
    pathKcalc = config["kcalcPath"]
    workdir = "%s/Processing/1.MeasurementandSPHARM" % (outputdir)

    # before executing the boundary correction
    # check if none of input is not generated.
    labelMapList = [labelMap for (tag, labelMap, group) in data]
    testLabelMapsFail = False in [os.path.exists(x) for x in labelMapList]
    if testLabelMapsFail:
        raise RuntimeError("There are missing label maps")

    surfaceInputList = [
        "%s/%s.subj.SPHARM.vtk" % (workdir, tag)
        for (tag, labelMap, group) in data
    ]
    testSurfaceInputsFail = False in [
        os.path.exists(x) for x in surfaceInputList
    ]
    if testSurfaceInputsFail:
        raise RuntimeError(
            "There are missing surface inputs. Check SPHARM results!")

    for (idx, item) in enumerate(data):
        tag = item[0]
        labelMap = item[1]
        group = item[2]

        labelOutput = workdir + "/" + tag + "/labelmap_zeroSolution.nrrd"
        surfaceInput = workdir + "/" + tag + ".subj.SPHARM.vtk"
        surfaceLabels = workdir + "/" + tag + ".labels.vtp"
        voronoiImage = workdir + "/" + tag + ".voronoi.mha"
        surfaceImage = workdir + "/" + tag + ".solution.mha"
        boundaryMap = workdir + "/" + tag + ".boundaryMap.mha"

        cmd = "%s -e 'A==3?0:A' -o %s %s" % (pathKcalc, labelOutput, labelMap)
        system.run_process(cmd, verbose=True)

        cmd = "%s -sampleImage -zrotate %s %s %s -outputScalarName labels" % (
            pathKmesh, labelOutput, surfaceInput, surfaceLabels)
        system.run_process(cmd, verbose=True)

    cmd = "%s -averageScalars -threshold 1.8 -scalarName labels -outputScalarName meanLabels" % (
        pathKmesh)
    for (tag, labelmap, group) in data:
        cmd += " " + workdir + "/" + tag + ".labels.vtp"
    print cmd
    system.run_process(cmd, verbose=True)

    for (idx, item) in enumerate(data):
        tag = item[0]
        labelMap = item[1]
        group = item[2]

        labelOutput = workdir + "/" + tag + "/labelmap_zeroSolution.nrrd"
        surfaceInput = workdir + "/" + tag + ".subj.SPHARM.vtk"
        surfaceLabels = workdir + "/" + tag + ".labels.vtp"
        voronoiImage = workdir + "/" + tag + ".voronoi.mha"
        surfaceImage = workdir + "/" + tag + ".solution.mha"
        boundaryMap = workdir + "/" + tag + ".boundaryMap.mha"

        cmd = "%s -voronoiImage -zrotate %s %s %s -scalarName meanLabels" % (
            pathKmesh, labelOutput, surfaceLabels, voronoiImage)
        print cmd
        system.run_process(cmd, verbose=True)

        cmd = "%s -scanConversion -zrotate %s %s %s" % (
            pathKmesh, surfaceLabels, labelOutput, surfaceImage)
        print cmd
        system.run_process(cmd, verbose=True)

        cmd = "%s -e 'B>0?3:A' -o %s %s %s" % (pathKcalc, boundaryMap,
                                               voronoiImage, surfaceImage)
        print cmd
        system.run_process(cmd, verbose=True)
Esempio n. 27
0
def perform_analysis(opts,
                     config,
                     csvdata,
                     outputDir,
                     corr_opt="initial_dense"):
    ids = [i for i, l, g in csvdata]
    groups = [g for i, l, g in csvdata]

    meshDir = "{outputDir}/Processing/1.MeasurementandSPHARM".format(
        **locals())
    shapeworksDir = "{outputDir}/Processing/2.shapeworks".format(**locals())
    sampleDir = "{outputDir}/Processing/3.sampling".format(**locals())
    statDir = "{outputDir}/Statistics".format(**locals())

    sample_thickness(opts, config, csvdata, outputDir, corr_opt)

    # collect_attributes()
    # compute_statistics()
    # aggregate sampling files into a single file
    groupSet = set(groups)
    datafiles = []
    tag = ""
    for group in groupSet:
        # setup output filename template
        if (corr_opt == "initial_dense"):
            tag = "_initialDenseSampling"
            datafilename = "%s/data_initialDenseSampling_%s.txt" % (statDir,
                                                                    group)
            dataregionfilename = "%s/data_region_initialDenseSampling_%s.txt" % (
                statDir, group)
            outfilename = "%s/list_initialDenseSampling_%s.txt" % (statDir,
                                                                   group)
        elif (corr_opt == "correspondence"):
            tag = ""
            datafilename = "%s/data_%s.txt" % (statDir, group)
            dataregionfilename = "%s/data_region_%s.txt" % (statDir, group)
            outfilename = "%s/list_%s.txt" % (statDir, group)
        elif (corr_opt == "dense_correspondence"):
            tag = "_dense"
            datafilename = "%s/data_dense_%s.txt" % (statDir, group)
            dataregionfilename = "%s/data_region_dense_%s.txt" % (statDir,
                                                                  group)
            outfilename = "%s/list_dense_%s.txt" % (statDir, group)
        elif (corr_opt == "spharm_sampling"):
            tag = "_spharm"
            datafilename = "%s/data_spharm_%s.txt" % (statDir, group)
            dataregionfilename = "%s/data_region_spharm_%s.txt" % (statDir,
                                                                   group)
            outfilename = "%s/list_spharm_%s.txt" % (statDir, group)

        # process and write the aggregated data
        outfile = open(outfilename, 'w')
        for (id, g) in zip(ids, groups):
            if (g != group):
                continue
            if (corr_opt == "initial_dense"):
                samplingTxt = "%s/%s.smoothInitialDenseSampling.txt" % (
                    sampleDir, id)
            elif (corr_opt == "correspondence"):
                samplingTxt = "%s/%s.smoothSampling.txt" % (sampleDir, id)
            elif (corr_opt == "dense_correspondence"):
                samplingTxt = "%s/%s.smoothDenseSampling.txt" % (sampleDir, id)
            elif (corr_opt == "spharm_sampling"):
                samplingTxt = "%s/%s.smoothSpharmSampling.txt" % (sampleDir,
                                                                  id)
            if (os.path.isfile(samplingTxt)):
                outfile.write(samplingTxt)
                outfile.write("\n")
            else:
                print "can't find", samplingTxt
        outfile.close()

        # concatenate those attribute files into a file
        concatColumnsToFile(outfilename, datafilename)
        datafiles.append((group, datafilename))

    # perform statistical analysis
    rscriptExePath = config["RscriptPath"]
    rscriptPath = os.path.dirname(
        os.path.abspath(__file__)) + "/rodentThicknessStats.r"
    if (corr_opt == "initial_dense"):
        outputfile = "%s/stats.initialDenseSampling.txt" % statDir
        outputVTK = "%s/stats.initialDenseSampling.vtk" % (statDir)
        inputVTK = "%s/%s.subj.SPHARM.vtk" % (meshDir, ids[0])
    elif (corr_opt == "correspondence"):
        outputfile = "%s/stats.correspondence.txt" % statDir
        outputVTK = "%s/stats.correspondence.vtk" % (statDir)
        inputVTK = "%s/%s.correspondence.vtk" % (shapeworksDir, ids[0])
    elif (corr_opt == "dense_correspondence"):
        outputfile = "%s/stats.denseCorrespondence.txt" % statDir
        outputVTK = "%s/stats.denseCorrespondence.vtk" % (statDir)
        inputVTK = "%s/%s.dense_correspondence.vtk" % (shapeworksDir, ids[0])
    elif (corr_opt == "spharm_sampling"):
        outputfile = "%s/stats.spharmCorrespondence.txt" % statDir
        outputVTK = "%s/stats.spharmCorrespondence.vtk" % (statDir)
        inputVTK = "%s/%s.subj.SPHARM.vtk" % (meshDir, ids[0])

    #pythonScriptPath = config["vtkPointAttributesPythonScriptPath"]

    pathKmesh = config["kmeshPath"]
    datafilelist = ""
    datagroups = ""
    for (group, file) in datafiles:
        datafilelist = datafilelist + " " + file
        datagroups = datagroups + " " + group

        # compute per-group statistics
        cmd = "%s -computeVectorStats -scalarName %s -importVectors %s %s %s/%s_thickness.vtk" % (
            pathKmesh, group + "_Thickness", inputVTK, file, statDir, group)
        system.run_process(cmd, verbose=True)

    if (len(datafiles) > 1):
        runCmd = "%s %s %s %s %s" % (rscriptExePath, rscriptPath, datafilelist,
                                     outputfile, datagroups)
        system.run_process(runCmd, verbose=True)
        #visCmd = "%s %s %s %s -i %s -t" % (pythonPath, pythonScriptPath, inputVTK, outputVTK, outputfile)
        visCmd = "%s -use-header %s %s -importCSV %s" % (pathKmesh, inputVTK,
                                                         outputVTK, outputfile)
        system.run_process(visCmd, verbose=True)

        # connected components for p-value
        print "computing connected components with t.pvalue..."
        runCmd = "%s -connectScalars %s -scalarName t.pvalue %s -thresholdMin 0 -thresholdMax 0.05" % (
            pathKmesh, outputVTK, outputVTK)
        system.run_process(runCmd, verbose=True)

        print "export scalars..."
        runCmd = "%s -exportScalars -scalarName RegionIds %s %s/regionIds.txt" % (
            pathKmesh, outputVTK, statDir)
        system.run_process(runCmd, verbose=True)

        # create a combined data file with regions
        regionIdFile = "%s/regionIds.txt" % (statDir)
        if os.path.exists(regionIdFile):
            for (group, file) in datafiles:
                dataregionfilename = "%s/data_region%s_%s.txt" % (statDir, tag,
                                                                  group)
                concatColumnsToFile(
                    [regionIdFile,
                     "%s/data%s_%s.txt" % (statDir, tag, group)],
                    dataregionfilename,
                    inputIsList=True)
                # perform splitting
                performSplit([dataregionfilename], "%s/data_%s_region_" %
                             (statDir, group) + "%02d.txt")

            # boxplot
            draw_boxplot = True
            if draw_boxplot:
                groupList = list(groupSet)
                try:
                    print sys.path
                    import boxplot
                    gr1 = groupList[0]
                    gr2 = groupList[1]
                    boxplot.draw_boxplot(groupList[0], groupList[1], \
                        "{statDir}/data_{gr1}_region_*.txt".format(**locals()), \
                        "{statDir}/data_{gr2}_region_*.txt".format(**locals()), \
                        "{statDir}/{gr1}_{gr2}_regions.pdf".format(**locals()))
                except BaseException as e:
                    print system.bcolors.WARNING + e.message + system.bcolors.ENDC
                    pass
Esempio n. 28
0
def sample_thickness(opts, config, csvdata, outputDir, corr_opt):
    meshDir = "{outputDir}/Processing/1.MeasurementandSPHARM".format(
        **locals())
    shapeworksDir = "{outputDir}/Processing/2.shapeworks".format(**locals())
    sampleDir = "{outputDir}/Processing/3.sampling".format(**locals())
    statDir = "{outputDir}/Statistics".format(**locals())
    pathKmesh = config["kmeshPath"]

    if (corr_opt == "initial_dense"):
        extra_args = "--inputPointFlip"
    else:
        extra_args = ""

    # depending on options, choose different meshes
    # loop over ids
    for id in [i for i, l, g in csvdata]:
        distanceVector = "{sampleDir}/{id}.distanceVector.nrrd".format(
            **locals())
        inputMeasurement = "{meshDir}/{id}_measurementoutput.nrrd".format(
            **locals())
        #    inputMeasurement = "%s/%s.thickness.mha" % (meshDir, id)
        if (corr_opt == "initial_dense"):
            samplingTxt = "%s/%s.initialDenseSampling.txt" % (sampleDir, id)
            smoothSamplingTxt = "%s/%s.smoothInitialDenseSampling.txt" % (
                sampleDir, id)
            samplingMeshOutput = "%s/%s.initialDenseSampling.vtk" % (sampleDir,
                                                                     id)
            originalMeshOutput = "%s/%s.initialDenseOriginal.vtk" % (sampleDir,
                                                                     id)
            inputMesh = "%s/%s.subj.SPHARM.vtk" % (meshDir, id)
        elif (corr_opt == "correspondence"):
            samplingTxt = "%s/%s.sampling.txt" % (sampleDir, id)
            smoothSamplingTxt = "%s/%s.smoothSampling.txt" % (sampleDir, id)
            samplingMeshOutput = "%s/%s.sampling.vtk" % (sampleDir, id)
            originalMeshOutput = "%s/%s.original.vtk" % (sampleDir, id)
            inputMesh = "%s/%s.correspondence.vtk" % (shapeworksDir, id)
        elif (corr_opt == "dense_correspondence"):
            samplingTxt = "%s/%s.denseSampling.txt" % (sampleDir, id)
            smoothSamplingTxt = "%s/%s.smoothDenseSampling.txt" % (sampleDir,
                                                                   id)
            samplingMeshOutput = "%s/%s.denseSampling.vtk" % (sampleDir, id)
            originalMeshOutput = "%s/%s.denseOriginal.vtk" % (sampleDir, id)
            inputMesh = "%s/%s.dense_correspondence.vtk" % (shapeworksDir, id)
        elif (corr_opt == "spharm_sampling"):
            samplingTxt = "%s/%s.spharmSampling.txt" % (sampleDir, id)
            smoothSamplingTxt = "%s/%s.smoothSpharmSampling.txt" % (sampleDir,
                                                                    id)
            samplingMeshOutput = "%s/%s.spharmSampling.vtk" % (sampleDir, id)
            originalMeshOutput = "%s/%s.spharmOriginal.vtk" % (sampleDir, id)
            inputMesh = "%s/%s.subj.SPHARM.vtk" % (meshDir, id)

        #samplingCmd = "{MeshPointIntensitySamplingPath} --workDir {workdir} --inputAsPhysicalCoord {extra_args} --distanceVector {distanceVector} -i nn -a {samplingTxt} -m {samplingMeshOutput} --smoothedAttributeOutput {smoothSamplingTxt} --originalMeshOutput {originalMeshOutput} {inputMeasurement} {inputMesh}"
        #exeCmd = samplingCmd.format(**locals())
        # exeCmd = samplingCmd % (outputDir, distanceVector, samplingTxt, samplingMeshOutput, smoothSamplingTxt, originalMeshOutput, inputMeasurement, inputMesh)
        #system.run_process(exeCmd,verbose=True)

        if system.is_file_newer(smoothSamplingTxt, inputMeasurement, opts.overwrite) or \
                system.is_file_newer(smoothSamplingTxt, samplingTxt, opts.overwrite) or \
                system.is_file_newer(smoothSamplingTxt, samplingMeshOutput, opts.overwrite):
            useStreamLine = corr_opt == "spharm_sampling"
            if (not useStreamLine):
                exeCmd = "{pathKmesh} -sampleImage {inputMeasurement} {inputMesh} {samplingMeshOutput} " +\
                            "-outputScalarName Thickness -zrotate"
                exeCmd = exeCmd.format(**locals())
                system.run_process(exeCmd, verbose=True)

                exeCmd = "{pathKmesh} -smoothScalars {samplingMeshOutput} {samplingMeshOutput} " +\
                            "-scalarName Thickness -outputScalarName smoothThickness -iter 3"
                exeCmd = exeCmd.format(**locals())
                system.run_process(exeCmd, verbose=True)

                exeCmd = "{pathKmesh} -exportScalars {samplingMeshOutput} {samplingTxt} -scalarName Thickness"
                exeCmd = exeCmd.format(**locals())
                system.run_process(exeCmd, verbose=True)

                exeCmd = "{pathKmesh} -exportScalars {samplingMeshOutput} {smoothSamplingTxt} " +\
                            "-scalarName smoothThickness "
                exeCmd = exeCmd.format(**locals())
                system.run_process(exeCmd, verbose=True)
            else:
                gradientFile = "{outputDir}/Processing/1.MeasurementandSPHARM/" +\
                        "{id}/laplacianGradient.nrrd".format(**locals())
                gradientVTIFile = "{outputDir}/Processing/1.MeasurementandSPHARM/" +\
                        "{id}/laplacianGradient.vti".format(**locals())
                streamLineFile = "{outputDir}/Processing/1.MeasurementandSPHARM/" +\
                        "{id}/stream_lines.vtp".format(**locals())

                # vti image creation
                exeCmd = "{pathKmesh} -vti {gradientFile} {gradientVTIFile} -attrDim 3"
                exeCmd = exeCmd.format(**locals())
                system.run_process(exeCmd, verbose=True)

                # RK45 integration
                exeCmd = "{pathKmesh} -zrotate -traceDirection backward -traceStream " +\
                    "{gradientVTIFile} {inputMesh} {streamLineFile} {samplingMeshOutput}"
                exeCmd = exeCmd.format(**locals())
                system.run_process(exeCmd, verbose=True)

                # scalar export
                exeCmd = "{pathKmesh} -scalarName Length -exportScalars " +\
                    "{samplingMeshOutput} {smoothSamplingTxt}"
                exeCmd = exeCmd.format(**locals())
                system.run_process(exeCmd, verbose=True)
Esempio n. 29
0
def regenerate_segmentations(data, config, outputdir):
    pathKmesh = config["kmeshPath"]
    pathKcalc = config["kcalcPath"]
    workdir = "%s/Processing/1.MeasurementandSPHARM" % (outputdir)


    # before executing the boundary correction
    # check if none of input is not generated.
    labelMapList = [labelMap for (tag, labelMap, group) in data]
    testLabelMapsFail = False in [os.path.exists(x) for x in labelMapList]
    if testLabelMapsFail:
        raise RuntimeError("There are missing label maps")

    surfaceInputList = ["%s/%s.subj.SPHARM.vtk" % (workdir, tag) for (tag,labelMap,group) in data]
    testSurfaceInputsFail = False in [os.path.exists(x) for x in surfaceInputList]
    if testSurfaceInputsFail:
        raise RuntimeError("There are missing surface inputs. Check SPHARM results!")

    for (idx, item) in enumerate(data):
        tag = item[0]
        labelMap = item[1]
        group = item[2]

        labelOutput = workdir + "/" + tag + "/labelmap_zeroSolution.nrrd"
        surfaceInput = workdir + "/" + tag + ".subj.SPHARM.vtk"
        surfaceLabels = workdir + "/" + tag + ".labels.vtp"
        voronoiImage = workdir + "/" + tag + ".voronoi.mha"
        surfaceImage = workdir + "/" + tag + ".solution.mha"
        boundaryMap = workdir + "/" + tag + ".boundaryMap.mha"

        cmd = "%s -e 'A==3?0:A' -o %s %s" % (pathKcalc, labelOutput, labelMap)
        system.run_process(cmd,verbose=True)

        cmd = "%s -sampleImage -zrotate %s %s %s -outputScalarName labels" % (pathKmesh, labelOutput, surfaceInput, surfaceLabels)
        system.run_process(cmd,verbose=True)

    cmd = "%s -averageScalars -threshold 1.8 -scalarName labels -outputScalarName meanLabels" % (pathKmesh)
    for (tag, labelmap, group) in data:
        cmd += " " + workdir + "/" + tag + ".labels.vtp"
    print cmd
    system.run_process(cmd,verbose=True)

    for (idx, item) in enumerate(data):
        tag = item[0]
        labelMap = item[1]
        group = item[2]

        labelOutput = workdir + "/" + tag + "/labelmap_zeroSolution.nrrd"
        surfaceInput = workdir + "/" + tag + ".subj.SPHARM.vtk"
        surfaceLabels = workdir + "/" + tag + ".labels.vtp"
        voronoiImage = workdir + "/" + tag + ".voronoi.mha"
        surfaceImage = workdir + "/" + tag + ".solution.mha"
        boundaryMap = workdir + "/" + tag + ".boundaryMap.mha"

        cmd = "%s -voronoiImage -zrotate %s %s %s -scalarName meanLabels" % (pathKmesh, labelOutput, surfaceLabels, voronoiImage)
        print cmd
        system.run_process(cmd,verbose=True)

        cmd = "%s -scanConversion -zrotate %s %s %s" % (pathKmesh, surfaceLabels, labelOutput, surfaceImage)
        print cmd
        system.run_process(cmd,verbose=True)

        cmd = "%s -e 'B>0?3:A' -o %s %s %s" % (pathKcalc, boundaryMap, voronoiImage, surfaceImage)
        print cmd
        system.run_process(cmd,verbose=True)
Esempio n. 30
0
def regenerate_segmentations(data, config, outputdir):
    pathKmesh = config["kmeshPath"]
    pathKcalc = config["kcalcPath"]
    workdir = "{outputdir}/Processing/1.MeasurementandSPHARM".format(**locals())

    # before executing the boundary correction
    # check if none of input is not generated.
    testLabelMapsFail = False in [os.path.exists(x) for (t,x,g) in data]
    if testLabelMapsFail:
        raise RuntimeError("There are missing label maps")

    surfaceInputList = ["{workdir}/{id}.subj.SPHARM.vtk".format(**locals()) for (id,l,g) in data]
    testSurfaceInputsFail = False in [os.path.exists(x) for x in surfaceInputList]
    if testSurfaceInputsFail:
        raise RuntimeError("There are missing surface inputs. Check SPHARM results!")

    if opts.nop1 is False:
        for idx, (id,labelMap,group) in enumerate(data):
            labelOutput = "{workdir}/{id}.zerocortex.nrrd".format(**locals())
            surfaceInput = "{workdir}/{id}.subj.SPHARM.vtk".format(**locals())
            #surfaceInput = "{workdir}/{id}.surf.vtk".format(**locals())
            surfaceLabels = "{workdir}/{id}.labels.vtp".format(**locals())

            if system.is_file_newer(labelOutput, labelMap, opts.overwrite):
                cmd = "{pathKcalc} -e 'A==3?0:A' -o {labelOutput} {labelMap}"
                cmd = cmd.format(**locals())
                if system.run_process(cmd,verbose=True) != 0:
                    raise RuntimeError("fail to modify labelmap")

            if system.is_file_newer(surfaceLabels, surfaceInput, opts.overwrite) or \
                    system.is_file_newer(surfaceLabels, labelOutput, opts.overwrite):
                cmd = "{pathKmesh} -sampleImage -zrotate -outputScalarName labels " + \
                        "{labelOutput} {surfaceInput} {surfaceLabels}"
                cmd = cmd.format(**locals())
                if system.run_process(cmd,verbose=True) != 0:
                    raise RuntimError("fail to run kmesh") 

    # compute the average of labels scalar values to smooth out
    if opts.nop2 is False:
        cmd = "{pathKmesh} -averageScalars -threshold 1.8 " + \
              "-scalarName labels -outputScalarName meanLabels"
        cmd = cmd.format(**locals())
        for (tag, labelmap, group) in data:
            surfaceMeshWithLabels = "{workdir}/{tag}.labels.vtp".format(**locals())
            cmd += " " + surfaceMeshWithLabels
        system.run_process(cmd,verbose=True)

    if opts.nop3 is False:
        for idx,(tag,labelMap,group) in enumerate(data):
            labelOutput = "{workdir}/{tag}.zerocortex.nrrd".format(**locals())
            surfaceLabels = "{workdir}/{tag}.labels.vtp".format(**locals())
            voronoiImage = "{workdir}/{tag}.voronoi.mha".format(**locals())
            surfaceImage = "{workdir}/{tag}.solution.mha".format(**locals())
            boundaryMap = "{workdir}/{tag}.boundaryMap.mha".format(**locals())

            if system.is_file_newer(labelOutput, voronoiImage, opts.overwrite) or \
                    system.is_file_newer(surfaceLabels, voronoiImage, opts.overwrite):
                cmd = "{pathKmesh} -voronoiImage -zrotate -scalarName meanLabels " +\
                    "{labelOutput} {surfaceLabels} -o {voronoiImage}"
                cmd = cmd.format(**locals())
                system.run_process(cmd,verbose=True)

            if system.is_file_newer(labelOutput, voronoiImage, opts.overwrite) or \
                    system.is_file_newer(surfaceLabels, voronoiImage, opts.overwrite):
                cmd = "{pathKmesh} -scanConversion -zrotate " +\
                    "{surfaceLabels} {labelOutput} {surfaceImage}"
                cmd = cmd.format(**locals())
                system.run_process(cmd,verbose=True)

            if system.is_file_newer(voronoiImage, boundaryMap, opts.overwrite) or \
                    system.is_file_newer(surfaceImage, boundaryMap, opts.overwrite):
                cmd = "{pathKcalc} -e 'B>0?3:A' -o {boundaryMap} " +\
                    "{voronoiImage} {surfaceImage}"
                cmd = cmd.format(**locals())
                system.run_process(cmd,verbose=True)
Esempio n. 31
0
def performAnalysis(cvsdata, config, outputDir, opt="initial_dense"):
    ids = []
    groups = []
    for (id, labelmap, group) in cvsdata:
        ids.append(id)
        groups.append(group)

    meshDir = "%s/Processing/1.MeasurementandSPHARM" % (outputDir)
    shapeworksDir = "%s/Processing/2.shapeworks" % (outputDir)
    sampleDir = "%s/Processing/3.meshintensity" % (outputDir)
    statDir = "%s/Statistical" % (outputDir)
    pathKmesh = config["kmeshPath"]

    if (opt == "initial_dense"):
        samplingCmd = config["MeshPointIntensitySamplingPath"] + " --workDir %s --inputAsPhysicalCoord --inputPointFlip --distanceVector %s -i nn -a %s -m %s --smoothedAttributeOutput %s --originalMeshOutput %s %s %s"
    else:
        samplingCmd = config["MeshPointIntensitySamplingPath"] + " --workDir %s --inputAsPhysicalCoord --distanceVector %s -i nn -a %s -m %s --smoothedAttributeOutput %s --originalMeshOutput %s %s %s"



    # depending on options, choose different meshes
    # loop over ids
    for id in ids:
        distanceVector = "%s/%s.distanceVector.nrrd" % (sampleDir, id)
        inputMeasurement = "%s/%s_measurementoutput.nrrd" % (meshDir, id)
        #    inputMeasurement = "%s/%s.thickness.mha" % (meshDir, id)
        if (opt == "initial_dense"):
            samplingTxt = "%s/%s.initialDenseSampling.txt" % (sampleDir, id)
            smoothSamplingTxt = "%s/%s.smoothInitialDenseSampling.txt" % (sampleDir, id)
            samplingMeshOutput = "%s/%s.initialDenseSampling.vtk" % (sampleDir, id)
            originalMeshOutput = "%s/%s.initialDenseOriginal.vtk" % (sampleDir, id)
            inputMesh = "%s/%s.subj.SPHARM.vtk" % (meshDir, id)
        elif (opt == "correspondence"):
            samplingTxt = "%s/%s.sampling.txt" % (sampleDir, id)
            smoothSamplingTxt = "%s/%s.smoothSampling.txt" % (sampleDir, id)
            samplingMeshOutput = "%s/%s.sampling.vtk" % (sampleDir, id)
            originalMeshOutput = "%s/%s.original.vtk" % (sampleDir, id)
            inputMesh = "%s/%s.correspondence.vtk" % (shapeworksDir, id)
        elif (opt == "dense_correspondence"):
            samplingTxt = "%s/%s.denseSampling.txt" % (sampleDir, id)
            smoothSamplingTxt = "%s/%s.smoothDenseSampling.txt" % (sampleDir, id)
            samplingMeshOutput = "%s/%s.denseSampling.vtk" % (sampleDir, id)
            originalMeshOutput = "%s/%s.denseOriginal.vtk" % (sampleDir, id)
            inputMesh = "%s/%s.dense_correspondence.vtk" % (shapeworksDir, id)
        elif (opt == "spharm_sampling"):
            samplingTxt = "%s/%s.spharmSampling.txt" % (sampleDir, id)
            smoothSamplingTxt = "%s/%s.smoothSpharmSampling.txt" % (sampleDir, id)
            samplingMeshOutput = "%s/%s.spharmSampling.vtk" % (sampleDir, id)
            originalMeshOutput = "%s/%s.spharmOriginal.vtk" % (sampleDir, id)
            inputMesh = "%s/%s.subj.SPHARM.vtk" % (meshDir, id)

        # execute sampling
        # exeCmd = samplingCmd % (outputDir, distanceVector, samplingTxt, samplingMeshOutput, smoothSamplingTxt, originalMeshOutput, inputMeasurement, inputMesh)
        # new sampling command
        useStreamLine = True and opt == "spharm_sampling"
        if (not useStreamLine):
            exeCmd = "%s -sampleImage %s %s %s -outputScalarName Thickness -zrotate" % (pathKmesh, inputMeasurement, inputMesh, samplingMeshOutput)
            system.run_process(exeCmd,verbose=True)

            exeCmd = "%s -smoothScalars %s %s -scalarName Thickness -outputScalarName smoothThickness -iter 3" % (pathKmesh, samplingMeshOutput, samplingMeshOutput)
            system.run_process(exeCmd,verbose=True)

            exeCmd = "%s -exportScalars %s %s -scalarName Thickness " % (pathKmesh, samplingMeshOutput, samplingTxt)
            system.run_process(exeCmd,verbose=True)

            exeCmd = "%s -exportScalars %s %s -scalarName smoothThickness " % (pathKmesh, samplingMeshOutput, smoothSamplingTxt)
            system.run_process(exeCmd,verbose=True)
        else:
            gradientFile = "%s/Processing/1.MeasurementandSPHARM/%s/laplacianGradient.nrrd" % (outputDir, id)
            gradientVTIFile = "%s/Processing/1.MeasurementandSPHARM/%s/laplacianGradient.vti" % (outputDir, id)
            streamLineFile = "%s/Processing/1.MeasurementandSPHARM/%s/stream_lines.vtp" % (outputDir, id)

            # vti image creation
            exeCmd = "%s -vti %s %s -attrDim 3" % (pathKmesh, gradientFile, gradientVTIFile)
            system.run_process(exeCmd,verbose=True)

            # RK45 integration
            exeCmd = "%s -traceStream %s %s %s %s -zrotate -traceDirection backward" % (pathKmesh, gradientVTIFile, inputMesh, streamLineFile, samplingMeshOutput)
            system.run_process(exeCmd,verbose=True)

            # scalar export
            exeCmd = "%s -exportScalars %s %s -scalarName Length " % (pathKmesh, samplingMeshOutput, smoothSamplingTxt)
            system.run_process(exeCmd,verbose=True)



    # aggregate sampling files into a single file
    groupSet = set(groups)
    datafiles = []
    tag = ""
    for group in groupSet:
        # setup output filename template
        if (opt == "initial_dense"):
            tag = "_initialDenseSampling"
            datafilename = "%s/data_initialDenseSampling_%s.txt" % (statDir, group)
            dataregionfilename = "%s/data_region_initialDenseSampling_%s.txt" % (statDir, group)
            outfilename = "%s/list_initialDenseSampling_%s.txt" % (statDir, group)
        elif (opt == "correspondence"):
            tag = ""
            datafilename = "%s/data_%s.txt" % (statDir, group)
            dataregionfilename = "%s/data_region_%s.txt" % (statDir, group)
            outfilename = "%s/list_%s.txt" % (statDir, group)
        elif (opt == "dense_correspondence"):
            tag = "_dense"
            datafilename = "%s/data_dense_%s.txt" % (statDir, group)
            dataregionfilename = "%s/data_region_dense_%s.txt" % (statDir, group)
            outfilename = "%s/list_dense_%s.txt" % (statDir, group)
        elif (opt == "spharm_sampling"):
            tag = "_spharm"
            datafilename = "%s/data_spharm_%s.txt" % (statDir, group)
            dataregionfilename = "%s/data_region_spharm_%s.txt" % (statDir, group)
            outfilename = "%s/list_spharm_%s.txt" % (statDir, group)


        # process and write the aggregated data
        outfile = open(outfilename, 'w')
        for (id, g) in zip(ids, groups):
            if (g != group):
                continue
            if (opt == "initial_dense"):
                samplingTxt = "%s/%s.smoothInitialDenseSampling.txt" % (sampleDir, id)
            elif (opt == "correspondence"):
                samplingTxt = "%s/%s.smoothSampling.txt" % (sampleDir, id)
            elif (opt == "dense_correspondence"):
                samplingTxt = "%s/%s.smoothDenseSampling.txt" % (sampleDir, id)
            elif (opt == "spharm_sampling"):
                samplingTxt = "%s/%s.smoothSpharmSampling.txt" % (sampleDir, id)
            if (os.path.isfile(samplingTxt)):
                outfile.write(samplingTxt)
                outfile.write("\n")
            else:
                print "can't find", samplingTxt
        outfile.close()

        # concatenate those attribute files into a file
        concatColumnsToFile(outfilename, datafilename)
        datafiles.append((group, datafilename))

    # perform statistical analysis
    rscriptExePath = config["RScriptPath"]
    rscriptPath = config["RScriptRodentThicknessPath"]
    if (opt == "initial_dense"):
        outputfile = "%s/stats.initialDenseSampling.txt" % statDir
        outputVTK = "%s/stats.initialDenseSampling.vtk" % (statDir)
        inputVTK = "%s/%s.subj.SPHARM.vtk" % (meshDir, ids[0])
    elif (opt == "correspondence"):
        outputfile = "%s/stats.correspondence.txt" % statDir
        outputVTK = "%s/stats.correspondence.vtk" % (statDir)
        inputVTK = "%s/%s.correspondence.vtk" % (shapeworksDir, ids[0])
    elif (opt == "dense_correspondence"):
        outputfile = "%s/stats.denseCorrespondence.txt" % statDir
        outputVTK = "%s/stats.denseCorrespondence.vtk" % (statDir)
        inputVTK = "%s/%s.dense_correspondence.vtk" % (shapeworksDir, ids[0])
    elif (opt == "spharm_sampling"):
        outputfile = "%s/stats.spharmCorrespondence.txt" % statDir
        outputVTK = "%s/stats.spharmCorrespondence.vtk" % (statDir)
        inputVTK = "%s/%s.subj.SPHARM.vtk" % (meshDir, ids[0])

    pythonPath = config["PythonPath"]
    pythonScriptPath = config["vtkPointAttributesPythonScriptPath"]

    datafilelist = ""
    datagroups = ""
    for (group, file) in datafiles:
        datafilelist = datafilelist + " " + file
        datagroups = datagroups + " " + group

        # compute per-group statistics
        cmd = "%s -computeVectorStats -scalarName %s -importVectors %s %s %s/%s_thickness.vtk" % (pathKmesh, group + "_Thickness", inputVTK, file, statDir, group)
        print cmd
        system.run_process(cmd,verbose=True)


    if (len(datafiles) > 1):
        runCmd = "%s %s %s %s %s" % (rscriptExePath, rscriptPath, datafilelist, outputfile, datagroups)
        system.run_process(runCmd,verbose=True)
        visCmd = "%s %s %s %s -i %s -t" % (pythonPath, pythonScriptPath, inputVTK, outputVTK, outputfile)
        system.run_process(visCmd,verbose=True)

        # connected components for p-value
        print "computing connected components with t.pvalue..."
        runCmd = "%s -connectScalars %s -scalarName t.pvalue %s -thresholdMin 0 -thresholdMax 0.05" % (pathKmesh, outputVTK, outputVTK)
        system.run_process(runCmd,verbose=True)

        print "export scalars..."
        runCmd = "%s -exportScalars -scalarName RegionIds %s %s/regionIds.txt" % (pathKmesh, outputVTK, statDir)
        system.run_process(runCmd,verbose=True)

        # create a combined data file with regions
        regionIdFile = "%s/regionIds.txt" % (statDir)
        if os.path.exists(regionIdFile):
            for (group, file) in datafiles:
                dataregionfilename = "%s/data_region%s_%s.txt" % (statDir, tag, group)
                concatColumnsToFile([regionIdFile, "%s/data%s_%s.txt" % (statDir, tag, group)], dataregionfilename, inputIsList = True)
                # perform splitting
                performSplit([dataregionfilename], "%s/data_%s_region_" % (statDir, group) + "%02d.txt")

            # boxplot
            groupList = list(groupSet)
            runCmd = "%s %s '%s' '%s' %s/%s_%s_regions.pdf --label1 %s --label2 %s" % (pythonPath, pythonScriptPath.replace("vtkPointAttributes.py", "boxplot.py"), "%s/data_%s_region_*.txt" % (statDir, groupList[0]), "%s/data_%s_region_*.txt" % (statDir, groupList[1]), statDir, groupList[0], groupList[1], groupList[0], groupList[1])
            print runCmd
            system.run_process(runCmd,verbose=True)
Esempio n. 32
0
import system
import sys
import logging

system.setup_logger(logfilename="test.log")
retcode = system.run_process(
    "/devel/linux/SPHARM-PDM/spharm-pdm-build-joowhi/bin/GenParaMeshCLP %s %s %s"
    % (sys.argv[1], sys.argv[2], sys.argv[3]),
    verbose=True)
print "Return Code = ", retcode