#!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 __future__ import division, print_function, absolute_import
import os
import argparse
from nidmresults.graph import *
from nidmresults import __version__

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description='NIDM-Results reader.')
    parser.add_argument('nidm_pack', help='Path to NIDM-Results pack.')
    parser.add_argument(
        '--version', action='version',
        version='{version}'.format(version=__version__))

    args = parser.parse_args()

    nidm_pack = args.nidm_pack
    if not os.path.isfile(nidm_pack):
        raise Exception("Unknown file: "+str(nidm_pack))

    nidm_graph = Graph(nidm_zip=nidm_pack)
    nidm_graph.parse()

    nidm_graph.get_peaks()
    for peak in nidm_graph.peaks:
        print(peak)

    nidm_graph.get_statistic_maps()
    for stat_map in nidm_graph.stat_maps:
        print(stat_map)
