def parse_arguments(raw=None): global report try: """ Apply the argument parser. """ args = argument_parser().parse_args(raw) if args.jsonrpc2: report = jsonrpc2.rpc_report_class() """ Basic argument checking """ if not op.exists(args.nifti_src): raise Exception('Nifti file "{}" not found.'.format( args.nifti_src)) if args.slicedir.isdigit(): args.dim = args.slicedir if args.slicedir < 0 or args.slicedir > 3: raise Exception('Invalid slice dimension "{}".'.format( args.slicedir)) else: dir2dim = {'x': 0, 'y': 1, 'z': 2} if args.slicedir in dir2dim: args.dim = dir2dim[args.slicedir] else: raise Exception('Invalid slice direction "{}".'.format( args.slicedir)) return args except: report.fail(__file__)
def parse_arguments(raw=None): global report try: """ Apply the argument parser. """ args = argument_parser().parse_args(raw) if args.jsonrpc2: report = jsonrpc2.rpc_report_class() try: fromto = map(int, args.range.split(',')) except: try: fromto = json.loads(args.range) except: report.error('Cannot parse range "' + args.range + '"') if len(fromto) <= 2: fromto.append(1) args.input_range = range(fromto[0], fromto[1] + 1, fromto[2]) """ Basic argument checking """ for r in args.input_range: fname = args.inp % (r) if not op.exists(fname): raise Exception('Image file "{}" not found.'.format(fname)) return args except: report.fail(__file__)
def parse_arguments(raw=None): global report try: """ Apply the argument parser. """ args = argument_parser().parse_args(raw) if args.jsonrpc2: report = jsonrpc2.rpc_report_class() """ Basic argument checking """ if not op.exists(args.nifti_in): raise Exception('Nifti file "{}" not found.'.format(args.nifti_in)) try: args.filter = json.loads(args.filter) if len(args.filter)%2 != 1: report.error('invalid filter {}; length must be odd.'.format(args.filter)) report.fail(__file__) except ValueError: tmp = re.split('[, ]+',args.filter) args.filter = [float(s) for s in tmp] try: args.ignore = json.loads(args.bg) except: raise return args except: report.fail(__file__)
def parse_arguments(raw=None): """ Apply the argument parser. """ args = argument_parser().parse_args(raw) if args.jsonrpc2: global report report = jsonrpc2.rpc_report_class() """ Basic argument checking """ if not op.exists(args.png_src): report.error('PNG folder "{}" not found.'.format(args.png_src)) report.fail(__file__) return args
def parse_arguments(raw=None): """ Apply the argument parser. """ args = argument_parser().parse_args(raw) if args.jsonrpc2: global report report = jsonrpc2.rpc_report_class() """ Basic argument checking """ args.useFilePattern = False if not op.exists(args.png_src): print 'PNG folder or pattern "{}" not found.'.format(args.png_src) exit(1) return args
def parse_arguments(raw=None): global report try: """ Apply the argument parser. """ args = argument_parser().parse_args(raw) if args.jsonrpc2: report = jsonrpc2.rpc_report_class() """ Basic argument checking """ if not op.exists(args.inp): raise Exception('Nifti file "{}" not found.'.format(args.inp)) return args except: report.fail(__file__)
def parse_arguments(raw=None): global report try: """ Apply the argument parser. """ args = argument_parser().parse_args(raw) if args.jsonrpc2: report = jsonrpc2.rpc_report_class() """ Basic argument checking """ if not op.exists(args.inp): raise Exception('Nifti file "{}" not found.'.format(args.inp)) if not args.out: args.out = re.sub('\.nii($)|\.nii(\.gz$)', '_downsampled.nii.gz', args.inp) return args except: report.fail(__file__)
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)
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)