def main(args=None): parser = get_parser() arguments = parser.parse(sys.argv[1:]) input_filename = arguments["-i"] image_input = Image(input_filename) image_output = image_input.invert() if '-o' in arguments: image_output.setFileName(arguments['-o']) image_output.save(type='minimize')
# Start program #======================================================================================================================= if __name__ == "__main__": # initialize parameters param = param() # call main function # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Utility function for labels.') parser.add_option(name="-i", type_value="file", description="Image to invert.", mandatory=True, example="my_image.nii.gz") parser.add_option(name="-o", type_value="file_output", description="output image.", mandatory=False, example="output_image.nii.gz", default_value="inverted_image.nii.gz") arguments = parser.parse(sys.argv[1:]) input_filename = arguments["-i"] image_input = Image(input_filename) image_output = image_input.invert() if "-o" in arguments: image_output.setFileName(arguments["-o"]) image_output.save(type='minimize')