Esempio n. 1
0
def main():
    """
    Entry point for command line tool
    """
    try:
        parser = AslOptionParser(usage="asl_mask -i <asl_image> [options...]",
                                 version=__version__)
        parser.add_option("--calib",
                          "-c",
                          help="Calibration image",
                          default=None)
        parser.add_option(
            "--use-pwi",
            help=
            "Use the perfusion weighted average rather than the timeseries mean",
            action="store_true",
            default=False)
        parser.add_category(image.AslImageOptions())
        parser.add_category(struc.StructuralImageOptions())
        parser.add_category(GenericOptions())

        options, _ = parser.parse_args(sys.argv)
        options.mask = None  # No point in using command line tool if you already have a mask!
        wsp = Workspace(**vars(options))

        if not options.asldata:
            sys.stderr.write("Input file not specified\n")
            parser.print_help()
            sys.exit(1)

        wsp.asldata = AslImage(wsp.asldata,
                               **parser.filter(vars(options), "image"))
        wsp.asldata.summary()

        wsp.generate_mask()

        if wsp.output is None:
            wsp.output = wsp.asldata.name + "_mask"
        wsp.rois.mask.save(wsp.output)

    except ValueError as exc:
        sys.stderr.write("ERROR: " + str(exc) + "\n")
        sys.exit(1)
Esempio n. 2
0
def main():
    """
    Entry point for oxasl_calib command line program
    """

    debug = False
    try:
        parser = AslOptionParser(
            usage=
            "oxasl_calib -i <perfusion image> -c <calibration image> --calib-method <voxelwise|refregion> -o <output filename> [options]"
        )
        parser.add_category(CalibOptions())
        parser.add_category(GenericOptions(output_type="file"))
        options, _ = parser.parse_args(sys.argv)

        if not options.perf:
            sys.stderr.write("Perfusion input file not specified\n")
            parser.print_help()
            sys.exit(1)

        if not options.calib:
            sys.stderr.write("Calibration input file not specified\n")
            parser.print_help()
            sys.exit(1)

        wsp = Workspace(**vars(options))

        summary(wsp.perf)
        summary(wsp.calib)

        if wsp.output is None:
            wsp.output = "%s_calib" % wsp.perf.name

        calibrated_img = calibrate(wsp, wsp.perf)
        summary(calibrated_img)
        calibrated_img.save(wsp.output)

    except ValueError as exc:
        sys.stderr.write("ERROR: " + str(exc) + "\n")
        if debug:
            traceback.print_exc()
        sys.exit(1)