#!/usr/bin/python
"""
Export neuroimaging results created with FSL feat following NIDM-Results
specification. The path to feat directory must be passed as first argument.

@author: Camille Maumet <c.m.j.maumet@warwick.ac.uk>
@copyright: University of Warwick 2013-2014
"""

from nidmfsl.fsl_exporter.fsl_exporter import FSLtoNIDMExporter
import argparse

if __name__ == "__main__":
    # Arguments and description
    parser = argparse.ArgumentParser(
        description='NIDM-Results exporter for FSL Feat.')
    parser.add_argument('feat_dir', help='Path to feat directory.')
    parser.add_argument(
        'numsubjects',
        help='Number of subjects per group.',
        nargs="*")
    parser.add_argument(
        "group_name",
        help='Label for each group.',
        nargs="*")
    parser.add_argument(
        "-o", "--output_name",
        help='Name of the output. A \".nidm.zip\" or \".nidm\" (when -d is use\
d) suffix will be appended.')
    parser.add_argument(
        "-d", "--directory-output",
        help='Produces a .nidm directory rather than a .nidm.zip file.',
        action='store_true')
    args = parser.parse_args()

    # Parse feat dir and export to NIDM
    fslnidm = FSLtoNIDMExporter(
        version="1.1.0", feat_dir=args.feat_dir,
        out_dirname=args.output_name, dir_output=(not args.directory_output),
        num_subjects=args.numsubjects, group_names=args.group_names)
    fslnidm.parse()
    output_path = fslnidm.export()

    print 'NIDM export available at '+output_path
