deformedFacesFile = '{}/meshes/{}'.format(spacesFolder,meshConfig['faces']) if deformedVerticesFile != verticesFile: V = LoadVertices.fromParent(self).setInput(deformedVerticesFile).requestOutput('vertices') if deformedFacesFile != facesFile: F = LoadFaces.fromParent(self).setInput(deformedFacesFile).requestOutput('faces') if labelnames: with open(labelnames) as fp: labelnames = json.load(fp) generateX3D = GenerateX3D.fromParent(self).setInput( vertices = V, faces = F, facelabels = faceLabels, label2rgb = label2rgb, label2name = labelnames, label2value = label2value, colormap = colormap ) return FancyDict( x3dfile = generateX3D.requestOutput('x3dfile'), x3dviewer = generateX3D.requestOutput('x3dviewer'), x3d_files = generateX3D.requestOutput('x3dviewer_files') ) #endclass if __name__ == '__main__': report = JR2.rpc_report_class() if '--jsonrpc2' in sys.argv else JR2.report_class() mainTask = RenderSurface.fromCommandLine() ans = mainTask.run() report.success(mainTask.myOutput.kwargs)
# Rembrandt Bakker, December 2014 import argparse, sys, os import os.path as op import re, json import numpy import jsonrpc2 report = jsonrpc2.report_class() def argument_parser(): """ Define the argument parser and return the parser object. """ parser = argparse.ArgumentParser( description='description', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('-m','--moving', type=str, help="Moving (nifti) volume", required=True) parser.add_argument('-f','--fixed', type=str, help="Fixed (nifti) volume", required=True) parser.add_argument('-v','--via', type=str, default=None, help="Via intermediate (nifti) volume", required=False) parser.add_argument('-o','--outdir', type=str, help="Output directory", required=True) parser.add_argument('-p','--program', type=str, default="elastix", help="Name of registration software package (default: elastix)", required=False) parser.add_argument('-par','--paramfile', type=str, help="Parameter file", required=True) parser.add_argument('--jsonrpc2', action='store_true', help="return output as json-rpc 2.0", required=False) return parser def parse_arguments(raw=None): global report try: """ Apply the argument parser. """ args = argument_parser().parse_args(raw) if args.jsonrpc2:
deformedVerticesFile).requestOutput('vertices') if deformedFacesFile != facesFile: F = LoadFaces.fromParent(self).setInput( deformedFacesFile).requestOutput('faces') if labelnames: with open(labelnames) as fp: labelnames = json.load(fp) generateX3D = GenerateX3D.fromParent(self).setInput( vertices=V, faces=F, facelabels=faceLabels, label2rgb=label2rgb, label2name=labelnames, label2value=label2value, colormap=colormap) return FancyDict( x3dfile=generateX3D.requestOutput('x3dfile'), x3dviewer=generateX3D.requestOutput('x3dviewer'), x3d_files=generateX3D.requestOutput('x3dviewer_files')) #endclass if __name__ == '__main__': report = JR2.rpc_report_class( ) if '--jsonrpc2' in sys.argv else JR2.report_class() mainTask = RenderSurface.fromCommandLine() ans = mainTask.run() report.success(mainTask.myOutput.kwargs)