ADDM.cpp
Loading...
Searching...
No Matches
util.h File Reference
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <BS_thread_pool.hpp>
#include <nlohmann/json.hpp>
#include "addm.h"
#include "ddm.h"
Include dependency graph for util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  expEntry
 Single entry in the experimental data CSV file. More...
 
struct  fixEntry
 Single entry in the fixations CSV file. More...
 

Typedefs

using json = nlohmann::json
 

Functions

std::map< int, std::vector< aDDMTrial > > loadDataFromSingleCSV (std::string filename)
 Load experimental data from a single CSV file. Format expected is:
 
std::map< int, std::vector< aDDMTrial > > loadDataFromCSV (std::string expDataFilename, std::string fixDataFilename)
 Load experimental data from two CSV files: an experimental data file and a fixations file. Format expected for experimental data file:
 
FixationData getEmpiricalDistributions (std::map< int, std::vector< aDDMTrial > > data, int timeStep=10, int maxFixTime=3000, int numFixDists=3, std::vector< float > valueDiffs={-3,-2,-1, 0, 1, 2, 3}, std::vector< int > subjectIDs={}, bool useOddTrials=true, bool useEvenTrials=true, bool useCisTrials=true, bool useTransTrials=true)
 Create empirical distributions fro the data ot be used when generating model simulations.
 
template<class T >
void pmat (std::vector< std::vector< T > > mat, std::string name)
 Print a matrix stored in nested-vector format. Utility function for debugging purposes.
 

Variables

vector< string > validComputeMethods
 

Typedef Documentation

◆ json

using json = nlohmann::json

Function Documentation

◆ getEmpiricalDistributions()

FixationData getEmpiricalDistributions ( std::map< int, std::vector< aDDMTrial > > data,
int timeStep = 10,
int maxFixTime = 3000,
int numFixDists = 3,
std::vector< float > valueDiffs = {-3,-2,-1, 0, 1, 2, 3},
std::vector< int > subjectIDs = {},
bool useOddTrials = true,
bool useEvenTrials = true,
bool useCisTrials = true,
bool useTransTrials = true )

Create empirical distributions fro the data ot be used when generating model simulations.

Parameters
dataA mapping of subject IDs to vectors of each subject's corresponding aDDMTrials.
timeStepMinimum duration of a fixation to be considered in milliseconds.
maxFixTimeMaximum duration of a fixation to be considered, in milliseconds.
numFixDistsInteger indicating the number of fixation types to use in the fixation distributions. I.e. if set to 3, then three separate fixation typyes will be used, corresponding to the first, second, and third fixation in each trial.
valueDiffsList of integers corresponding to the available value differences between item.
subjectIDsList of subject IDs to consider in the empirical data. If left empty, all subjectIDs will be used.
useOddTrialsBoolean indicating whether or not to use odd trials when creating the distributions.
useEvenTrialsBoolean indicating whether or not to use even trials when creating the distributions.
useCisTrialsBoolean indiciating whether or not to use cis trials when creating the distributions. Cis trials are defined as trials in which both items have either positive or negative values.
useTransTrialsBoolean indicating whether or not to use trans trials when creating the distributions. Trans trials are defined as trials in which one item has a positive value and one item has a negative value.
Returns
FixationData object serving as a record of empirical fixation distributions.

◆ loadDataFromCSV()

std::map< int, std::vector< aDDMTrial > > loadDataFromCSV ( std::string expDataFilename,
std::string fixDataFilename )

Load experimental data from two CSV files: an experimental data file and a fixations file. Format expected for experimental data file:

parcode, trial, rt, choice, valueLeft, valueRight

Format expected for fixations file:

parcode, trial, fixItem, fixTime

Parameters
expDataFilenameName of the experimental data trial.
fixDataFilenameName of the fixations file.
Returns
std::map<int, std::vector<aDDMTrial>> mapping subject IDs to each subject's corresponding aDDMTrials.

◆ loadDataFromSingleCSV()

std::map< int, std::vector< aDDMTrial > > loadDataFromSingleCSV ( std::string filename)

Load experimental data from a single CSV file. Format expected is:

trial, choice, rt, valueLeft, valueRight, fixItem, fixTime

Parameters
filenameName of the CSV file.
Returns
std::map<int, std::vector<aDDMTrial>> mapping subject IDs to each subject's corresponding aDDMTrials.

◆ pmat()

template<class T >
void pmat ( std::vector< std::vector< T > > mat,
std::string name )

Print a matrix stored in nested-vector format. Utility function for debugging purposes.

Template Parameters
Tnumerical type (double, float, int, etc...)
Parameters
matNested vector to print.
nameName to print as a header for the matrix.

Variable Documentation

◆ validComputeMethods

vector<string> validComputeMethods
extern