#!/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: ddm_mla_test
Author: Gabriela Tavares, gtavares@caltech.edu

Performs a test to check the validity of the maximum likelihood algorithm (MLA)
for the drift-diffusion model (DDM). Artificial data is generated using
specific parameters for the model. These parameters are then recovered through
a maximum likelihood estimation procedure, using a grid search over the 2 free
parameters of the model.
"""

from __future__ import absolute_import

import argparse

from addm_toolbox import ddm_mla_test


parser = argparse.ArgumentParser()
parser.add_argument(u"--d", type=float, default=0.006,
                    help=u"DDM parameter for generating artificial data.")
parser.add_argument(u"--sigma", type=float, default=0.08,
                    help=u"DDM parameter for generating artificial data.")
parser.add_argument(u"--range-d", nargs=u"+", type=float,
                    default=[0.005, 0.006, 0.007],
                    help=u"Search range for parameter d.")
parser.add_argument(u"--range-sigma", nargs=u"+", type=float,
                    default=[0.065, 0.08, 0.095],
                    help=u"Search range for parameter sigma.")
parser.add_argument(u"--trials-file-name", type=str, default=None,
                    help=u"Path of trial conditions file.")
parser.add_argument(u"--num-trials", type=int, default=10,
                    help=u"Number of artificial data trials to be "
                    "generated per trial condition.")
parser.add_argument(u"--num-simulations", type=int, default=10,
                    help=u"Number of simulations to be generated per "
                    "trial condition, to be used in the RT histograms.")
parser.add_argument(u"--bin-step", type=int, default=100,
                    help=u"Size of the bin step to be used in the RT "
                    "histograms.")
parser.add_argument(u"--max-rt", type=int, default=8000,
                    help=u"Maximum RT to be used in the RT histograms.")
parser.add_argument(u"--num-threads", type=int, default=9,
                    help=u"Size of the thread pool.")
parser.add_argument(u"--verbose", default=False, action=u"store_true",
                    help=u"Increase output verbosity.")

args = parser.parse_args()
ddm_mla_test.main(args.d, args.sigma, args.range_d, args.range_sigma,
                  args.trials_file_name, args.num_trials, args.num_simulations,
                   args.bin_step, args.max_rt, args.num_threads, args.verbose)
