#!/usr/bin/env python
# -*- coding: utf-8 -*-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
# @Author: oesteban
# @Date:   2015-10-08 13:07:21
# @Last Modified by:   oesteban
# @Last Modified time: 2015-10-08 14:53:20

if __name__ == "__main__":
    import argparse
    import os.path as op
    from qap.viz.reports import workflow_report

    parser = argparse.ArgumentParser()
    req = parser.add_argument_group("Required Inputs")
    req.add_argument('-i', '--input_csv', type=str, required=True,
                     help='filepath to csv file generated by qap')

    req.add_argument(
        '-m', '--qap_mode', type=str, help='report type',
        choices=['qap_anatomical_spatial', 'qap_functional_temporal',
                 'qap_functional_spatial'], required=True)

    args = parser.parse_args()

    in_csv = args.input_csv
    out_dir = op.dirname(in_csv)
    qap_type = args.qap_mode

    reports = workflow_report(in_csv, qap_type, run_name,
                              out_dir=out_dir)

    for k, v in reports.iteritems():
        if v['success']:
            logger.info('Written report (%s) in %s' % (k, v['path']))
