# Check opacity
if args.opacity > 1 or args.opacity < 0:
    os.sys.exit('Opaicty must be between zeor and one. Given {o}. Exiting...'.format(o=args.opacity))

# Read both images
inputReader = vtk.vtkImageReader2Factory.CreateImageReader2(args.inputImage)
if inputReader is None:
    if args.inputImage.lower().endswith('.nii'):
        inputReader = vtk.vtkNIFTIImageReader()
    elif args.inputImage.lower().endswith('.dcm'):
        inputReader = vtk.vtkDICOMImageReader()
    elif vtkboneImported and args.inputImage.lower().endswith('.aim'):
        inputReader = vtkbone.vtkboneAIMReader()
        inputReader.DataOnCellsOff()
    elif vtkbonelabImported and args.inputImage.lower().endswith('.aim'):
        inputReader = vtkbonelab.vtkbonelabAIMReader()
        inputReader.DataOnCellsOff()
    else:
        os.sys.exit('Unable to find a reader for \"{fileName}\". Exiting...'.format(fileName=args.inputImage))
inputReader.SetFileName(args.inputImage)
print('Loading {}...'.format(args.inputImage))
inputReader.Update()

segReader = vtk.vtkImageReader2Factory.CreateImageReader2(args.inputSegmentation)
if segReader is None:
    if args.inputSegmentation.lower().endswith('.nii'):
        segReader = vtk.vtkNIFTIImageReader()
    elif args.inputSegmentation.lower().endswith('.dcm'):
        segReader = vtk.vtkDICOMImageReader()
    elif vtkboneImported and args.inputSegmentation.lower().endswith('.aim'):
        segReader = vtkbone.vtkboneAIMReader()
示例#2
0
    os.sys.exit(
        'Number of threads must be one or greater. Given {n}. Exiting...'.
        format(n=args.nThreads))

# Read in inputs
reader1 = vtk.vtkImageReader2Factory.CreateImageReader2(args.inputImage1)
if reader1 is None:
    if args.inputImage1.lower().endswith('.nii'):
        reader1 = vtk.vtkNIFTIImageReader()
    elif args.inputImage1.lower().endswith('.dcm'):
        reader1 = vtk.vtkDICOMImageReader()
    elif vtkboneImported and args.inputImage1.lower().endswith('.aim'):
        reader1 = vtkbone.vtkboneAIMReader()
        reader1.DataOnCellsOff()
    elif vtkbonelabImported and args.inputImage1.lower().endswith('.aim'):
        reader1 = vtkbonelab.vtkbonelabAIMReader()
        reader1.DataOnCellsOff()
    else:
        os.sys.exit(
            'Unable to find a reader for \"{fileName}\". Exiting...'.format(
                fileName=args.inputImage1))
reader1.SetFileName(args.inputImage1)
print('Loading {}...'.format(args.inputImage1))
reader1.Update()

reader2 = vtk.vtkImageReader2Factory.CreateImageReader2(args.inputImage1)
if reader2 is None:
    if args.inputImage2.lower().endswith('.nii'):
        reader2 = vtk.vtkNIFTIImageReader()
    elif args.inputImage2.lower().endswith('.dcm'):
        reader2 = vtk.vtkDICOMImageReader()
示例#3
0
# Imports
import argparse
import vtk
import re
import os
try:
    import vtkbone
    reader = vtkbone.vtkboneAIMReader()
except ImportError:
    try:
        import vtkn88
        reader = vtkn88.vtkn88AIMReader()
    except ImportError:
        try:
            import vtkbonelab
            reader = vtkbonelab.vtkbonelabAIMReader()
        except ImportError:
            os.sys.exit(
                'Unable to import vtkbone, vtkn88, or vtkbonelab. Exiting...')

# Argument parser
parser = argparse.ArgumentParser(
    description='Subget medical data',
    formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('inputImage', help='The input AIM (*.aim) image)')
parser.add_argument('outputImage', help='The output NIfTI (*.nii) image)')
parser.add_argument('-f',
                    '--force',
                    action='store_true',
                    help='Set to overwrite output without asking')
args = parser.parse_args()