def main(argv=None):
    parser = get_parser()
    arguments = parser.parse_args(argv if argv else ['--help'])
    verbose = arguments.v
    set_global_loglevel(verbose=verbose)

    printv('Load data...', verbose)
    nii_mt = Image(arguments.mt)
    nii_pd = Image(arguments.pd)
    nii_t1 = Image(arguments.t1)
    if arguments.b1map is None:
        nii_b1map = None
    else:
        nii_b1map = Image(arguments.b1map)

    if arguments.trmt is None:
        arguments.trmt = fetch_metadata(
            get_json_file_name(arguments.mt, check_exist=True),
            'RepetitionTime')
    if arguments.trpd is None:
        arguments.trpd = fetch_metadata(
            get_json_file_name(arguments.pd, check_exist=True),
            'RepetitionTime')
    if arguments.trt1 is None:
        arguments.trt1 = fetch_metadata(
            get_json_file_name(arguments.t1, check_exist=True),
            'RepetitionTime')
    if arguments.famt is None:
        arguments.famt = fetch_metadata(
            get_json_file_name(arguments.mt, check_exist=True), 'FlipAngle')
    if arguments.fapd is None:
        arguments.fapd = fetch_metadata(
            get_json_file_name(arguments.pd, check_exist=True), 'FlipAngle')
    if arguments.fat1 is None:
        arguments.fat1 = fetch_metadata(
            get_json_file_name(arguments.t1, check_exist=True), 'FlipAngle')

    # compute MTsat
    nii_mtsat, nii_t1map = compute_mtsat(nii_mt,
                                         nii_pd,
                                         nii_t1,
                                         arguments.trmt,
                                         arguments.trpd,
                                         arguments.trt1,
                                         arguments.famt,
                                         arguments.fapd,
                                         arguments.fat1,
                                         nii_b1map=nii_b1map)

    # Output MTsat and T1 maps
    printv('Generate output files...', verbose)
    nii_mtsat.save(arguments.omtsat)
    nii_t1map.save(arguments.ot1map)

    display_viewer_syntax([arguments.omtsat, arguments.ot1map],
                          colormaps=['gray', 'gray'],
                          minmax=['-10,10', '0, 3'],
                          opacities=['1', '1'],
                          verbose=verbose)
Пример #2
0
def test_compute_mtsat():
    img_mtsat, img_t1map = mt.compute_mtsat(nii_mt=make_sct_image(1500),
                                            nii_pd=make_sct_image(2000),
                                            nii_t1=make_sct_image(1500),
                                            tr_mt=30,
                                            tr_pd=30,
                                            tr_t1=15,
                                            fa_mt=9,
                                            fa_pd=9,
                                            fa_t1=15)
    assert img_mtsat.data[0] == pytest.approx(1.5327, 0.0001)
Пример #3
0
def main():
    parser = get_parser()
    args = parser.parse_args(args=None if sys.argv[1:] else ['--help'])
    verbose = args.v
    sct.init_sct(log_level=verbose, update=True)  # Update log level

    sct.printv('Load data...', verbose)
    nii_mt = Image(args.mt)
    nii_pd = Image(args.pd)
    nii_t1 = Image(args.t1)
    if args.b1map is None:
        nii_b1map = None
    else:
        nii_b1map = Image(args.b1map)

    # compute MTsat
    nii_mtsat, nii_t1map = compute_mtsat(nii_mt,
                                         nii_pd,
                                         nii_t1,
                                         args.trmt,
                                         args.trpd,
                                         args.trt1,
                                         args.famt,
                                         args.fapd,
                                         args.fat1,
                                         nii_b1map=nii_b1map)

    # Output MTsat and T1 maps
    # by default, output in the same directory as the input images
    sct.printv('Generate output files...', verbose)
    if args.omtsat is None:
        fname_mtsat = os.path.join(os.path.dirname(nii_mt.absolutepath),
                                   "mtsat.nii.gz")
    else:
        fname_mtsat = args.omtsat
    nii_mtsat.save(fname_mtsat)
    if args.ot1map is None:
        fname_t1map = os.path.join(os.path.dirname(nii_mt.absolutepath),
                                   "t1map.nii.gz")
    else:
        fname_t1map = args.ot1map
    nii_t1map.save(fname_t1map)

    sct.display_viewer_syntax([fname_mtsat, fname_t1map],
                              colormaps=['gray', 'gray'],
                              minmax=['-10,10', '0, 3'],
                              opacities=['1', '1'],
                              verbose=verbose)