#!/usr/bin/env python

"""
Copyright (C) 2017, California Institute of Technology

This file is part of addm_toolbox.

addm_toolbox is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

addm_toolbox is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with addm_toolbox. If not, see <http://www.gnu.org/licenses/>.

---

Script: addm_pta_test
Author: Gabriela Tavares, gtavares@caltech.edu

Test to check the validity of the aDDM parameter estimation. Artificial data is
generated using specific parameters for the model. Fixations are sampled from
the data pooled from all subjects (or from a subset of subjects, when
provided). The parameters used for data generation are then recovered through a
maximum a posteriori estimation procedure.
"""

from __future__ import absolute_import

import argparse

from addm_toolbox import addm_pta_test


parser = argparse.ArgumentParser()
parser.add_argument("--d", type=float, default=0.006,
                    help="aDDM parameter for generating artificial data.")
parser.add_argument("--sigma", type=float, default=0.08,
                    help="aDDM parameter for generating artificial data.")
parser.add_argument("--theta", type=float, default=0.5,
                    help="aDDM parameter for generating artificial data.")
parser.add_argument("--range-d", nargs="+", type=float,
                    default=[0.005, 0.006, 0.007],
                    help="Search range for parameter d.")
parser.add_argument("--range-sigma", nargs="+", type=float,
                    default=[0.065, 0.08, 0.095],
                    help="Search range for parameter sigma.")
parser.add_argument("--range-theta", nargs="+", type=float,
                    default=[0.4, 0.5, 0.6],
                    help="Search range for parameter theta.")
parser.add_argument(u"--trials-file-name", type=str, default=None,
                    help=u"Path of trial conditions file.")
parser.add_argument("--expdata-file-name", type=str, default=None,
                    help="Path of experimental data file.")
parser.add_argument("--fixations-file-name", type=str, default=None,
                    help="Path of fixations file.")
parser.add_argument("--trials-per-condition", type=int, default=800,
                    help="Number of artificial data trials to be "
                    "generated per trial condition.")
parser.add_argument("--subject-ids", nargs="+", type=str, default=[],
                    help="List of subject ids. If not provided, all "
                    "existing subjects will be used.")
parser.add_argument("--num-threads", type=int, default=9,
                    help="Size of the thread pool.")
parser.add_argument("--verbose", default=False, action="store_true",
                    help="Increase output verbosity.")

args = parser.parse_args()
addm_pta_test.main(args.d, args.sigma, args.theta, args.range_d,
                   args.range_sigma, args.range_theta, args.trials_file_name,
                   args.expdata_file_name, args.fixations_file_name,
                   args.trials_per_condition, args.subject_ids,
                   args.num_threads, args.verbose)
