├── LICENSE.txt ├── README.md ├── ROC_Toolbox_Manual_v1.1.1.pdf ├── constraint_funcs ├── criteria_constraint.m ├── dpsd_sym_constr.m └── msd_sym_constr.m ├── doc ├── LICENSE.txt ├── ROC_Toolbox_Manual_v1.0.0.docx ├── ROC_Toolbox_Manual_v1.1.1.docx └── license.doc ├── examples ├── BRM_paper_supp_material.m ├── tutorial1_data.mat ├── tutorial1_script.m ├── tutorial2_data.mat ├── tutorial2_script.m ├── tutorial3_data.csv └── tutorial3_script.m ├── fit_statistics ├── calc_aic_bic.m ├── calc_chi_squared.m ├── calc_g.m ├── calc_model_fit.m ├── calc_neg_log_likelihood.m ├── calc_r_squared.m ├── calc_ss_error.m └── calc_ss_total.m ├── in_alpha ├── calc_likelihood.m └── est_posterior_ex_script.m ├── input_checks ├── freq_size_check.m ├── model_check.m ├── par_name_check.m └── par_size_check.m ├── main ├── calc_pred_data.m ├── gen_pars.m ├── gen_sim_data.m ├── model_info.m ├── roc_import_data.m └── roc_solver.m ├── models ├── dpsd │ ├── dpsd_calc_pred_data.m │ ├── dpsd_gen_pars.m │ ├── dpsd_gen_sim_data.m │ └── dpsd_info.m ├── msd │ ├── msd_calc_pred_data.m │ ├── msd_gen_pars.m │ ├── msd_gen_sim_data.m │ └── msd_info.m └── uvsd │ ├── uvsd_calc_pred_data.m │ ├── uvsd_gen_pars.m │ ├── uvsd_gen_sim_data.m │ └── uvsd_info.m ├── redistributions ├── loadtxt │ ├── finputcheck.m │ ├── license.txt │ └── loadtxt.m └── sortcell │ ├── license.txt │ └── sortcell.m ├── roc_startup.m ├── roc_version.m ├── sdt_accuracy_bias ├── calc_acc_aprime.m ├── calc_acc_auc.m ├── calc_acc_az.m ├── calc_acc_da.m ├── calc_acc_dprime.m ├── calc_acc_dr.m ├── calc_bias_beta.m ├── calc_bias_c.m └── calc_rating_acc_bias.m └── utilities ├── bin_sim_data.m ├── bootstrap_freqs.m ├── calc_nTrials.m ├── cumulp2freq.m ├── freq2zscores.m ├── get_all_models.m ├── get_group_data.m ├── plot_roc_summary.m ├── remove_bad_zvalues.m └── summarize_model.m /LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/LICENSE.txt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # ROC Toolbox for Matlab 3 | 4 | ## Purpose 5 | 6 | This toolxbox is intended to fit models of memory and cognition using signal detection theory based on ratings (i.e., confidence-based response) data. There are three general classes of models included in the toolbox: 7 | 8 | * Unequal-variance signal detection model (`uvsd`) 9 | * Dual-process signal detection model (`dpsd`) 10 | * Mixture signal detection model (`msd`) 11 | 12 | These models can be fit to empirical data obtain parameter estimates for each model. The toolbox also includes code for parameter recovery similations. 13 | 14 | ## Installation 15 | 16 | Prerequisites & Included Redistributions: 17 | This toolbox has been developed in Matlab version 2011a and should be compatible with Matlab version 7.10.0.499 (R2009b) and up. You must have the Statistics and Optimization Toolboxes installed with Matlab for the ROC toolbox to function properly. 18 | 19 | The ROC Toolbox includes two code redistributions under the GNU license. The redistributions included in this toolbox are from functions available on the Mathworks File Exchange: (1) [loadtxt](https://www.mathworks.com/matlabcentral/fileexchange/27962-loadtxt) and [sortcell](https://www.mathworks.com/matlabcentral/fileexchange/13770-sorting-a-cell-array), which can be found on the File Exchange. These functions are necessary for using the `roc_import_data` function. 20 | 21 | Getting the toolbox and adding it to the Matlab path 22 | 1) Download a copy of the latest release of ROC Toolbox from: 23 | 24 | https://github.com/jdkoen/roc_toolbox/releases 25 | 26 | 2) Unzip the .zip file to the target directory 27 | 28 | 3) Use Matlab’s Set Path interface and add the unzipped directory using the “Add with subfolders” option. Make sure to save the updated path. 29 | 30 | Alternatively, you can add the following lines to your ‘startup.m’ file: 31 | 32 | ```matlab 33 | addpath('/path/to/roc_toolbox'); 34 | roc_startup; 35 | ``` 36 | 37 | These lines add the path to the ROC toolbox distribution to your Matlab environment, and runs a function named 'roc_startup.m' that will add the necessary directories to your path 38 | 39 | You can check to see if the ROC toolbox is in your path by running the following command 40 | 41 | ```matlab 42 | which roc_solver 43 | ``` 44 | 45 | To check the version of the ROC Toolbox you are using, run the following command 46 | 47 | ```matlab 48 | roc_version; 49 | ``` 50 | 51 | ## Tutorials and Documentation 52 | 53 | The documentation for the toolbox can accessed [here](ROC_Toolbox_Manual_v1.1.1.pdf). 54 | 55 | There are three tutorials provided with the toolbox: 56 | * [Tutorial 1 - Basic Usage](examples/tutorial1_script.m) 57 | * [Tutorial 2 - Advanced Usage](examples/tutorial2_script.m) 58 | * [Tutorial 3 - Importing and Extracting Group Data](examples/tutorial3_script.m) 59 | 60 | ## Citation 61 | 62 | If you find the toolbox useful, please cite the following paper: 63 | 64 | Koen, J. D., Barrett, F. S., Harlow, I. M., & Yonelinas, A. P. (2017). The ROC Toolbox: A toolbox for analyzing receiver-operating characteristics derived from confidence ratings. Behavior Research Methods, 49(4), 1399–1406. https://doi.org/10.3758/s13428-016-0796-z 65 | -------------------------------------------------------------------------------- /ROC_Toolbox_Manual_v1.1.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/ROC_Toolbox_Manual_v1.1.1.pdf -------------------------------------------------------------------------------- /constraint_funcs/criteria_constraint.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/constraint_funcs/criteria_constraint.m -------------------------------------------------------------------------------- /constraint_funcs/dpsd_sym_constr.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/constraint_funcs/dpsd_sym_constr.m -------------------------------------------------------------------------------- /constraint_funcs/msd_sym_constr.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/constraint_funcs/msd_sym_constr.m -------------------------------------------------------------------------------- /doc/LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/doc/LICENSE.txt -------------------------------------------------------------------------------- /doc/ROC_Toolbox_Manual_v1.0.0.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/doc/ROC_Toolbox_Manual_v1.0.0.docx -------------------------------------------------------------------------------- /doc/ROC_Toolbox_Manual_v1.1.1.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/doc/ROC_Toolbox_Manual_v1.1.1.docx -------------------------------------------------------------------------------- /doc/license.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/doc/license.doc -------------------------------------------------------------------------------- /examples/BRM_paper_supp_material.m: -------------------------------------------------------------------------------- 1 | 2 | % Enter the response frequency data. 3 | % Column 1 is Sure Old and Column 20 is Sure New. 4 | % Row 1 is Low Frequency Words and Row 2 is High Frequency words. 5 | targf = [77 18 13 8 4 3 5 4 8 7 4 5 3 7 1 5 5 7 11 5; 6 | 57 25 13 9 9 3 7 8 13 11 8 11 5 2 4 3 5 6 0 1]; 7 | luref = [3 2 8 4 4 3 1 4 11 8 15 15 6 7 6 11 14 28 33 17; 8 | 5 9 6 8 4 5 7 4 11 12 20 13 10 7 8 5 15 17 28 6]; 9 | 10 | % Define the model to fit to the data 11 | model = 'dpsd'; % Fit the DPSD model to the data 12 | parNames = {'Ro' 'F'}; % Fit the Ro and F (d') parameters of the DPSD model. Rn and vF are set to 0 and 1, respectively. 13 | [nConds,nBins] = size(targf); % Get the number of conditions (rows) and rating bins (columns) 14 | 15 | % Get the starting values (x0) and lower/upper bounds (LB and UB) of the 16 | % define model 17 | [x0,LB,UB] = gen_pars(model,nBins,nConds,parNames); 18 | 19 | % Define options for the ROC_SOLVER function 20 | fitStat = '-LL'; % Fit the model using MLE (by minimizing the negative log-likelihood) 21 | subID = 'S1'; % Define the subject ID 22 | condLabels = {'low frequency' 'high frequency'}; % Define the condition labels for the rows in targf and luref 23 | modelID = 'dpsd'; % Specifies a name or label for the model 24 | outpath = pwd; % Specify the directory to write the summary figure to 25 | bootIter = 1000; % Specify the number of non-parameter bootstrap iterations to estimate SE of the parameter estimates 26 | 27 | % Use ROC_SOLVER to fit the model to the data 28 | rocData = roc_solver(targf,luref,model,fitStat,x0,LB,UB, ... 29 | 'subID',subID,'condLabels',condLabels,'modelID',modelID,'saveFig',outpath, ... 30 | 'bootIter',bootIter); 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /examples/tutorial1_data.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/examples/tutorial1_data.mat -------------------------------------------------------------------------------- /examples/tutorial1_script.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/examples/tutorial1_script.m -------------------------------------------------------------------------------- /examples/tutorial2_data.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/examples/tutorial2_data.mat -------------------------------------------------------------------------------- /examples/tutorial2_script.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/examples/tutorial2_script.m -------------------------------------------------------------------------------- /examples/tutorial3_data.csv: -------------------------------------------------------------------------------- 1 | 101,group1,condition1,target,10,96 2 | 101,group1,condition1,target,9,15 3 | 101,group1,condition1,target,8,16 4 | 101,group1,condition1,target,7,17 5 | 101,group1,condition1,target,6,17 6 | 101,group1,condition1,target,5,21 7 | 101,group1,condition1,target,4,5 8 | 101,group1,condition1,target,3,9 9 | 101,group1,condition1,target,2,2 10 | 101,group1,condition1,target,1,2 11 | 101,group1,condition1,lure,10,9 12 | 101,group1,condition1,lure,9,13 13 | 101,group1,condition1,lure,8,23 14 | 101,group1,condition1,lure,7,29 15 | 101,group1,condition1,lure,6,22 16 | 101,group1,condition1,lure,5,26 17 | 101,group1,condition1,lure,4,29 18 | 101,group1,condition1,lure,3,25 19 | 101,group1,condition1,lure,2,9 20 | 101,group1,condition1,lure,1,15 21 | 101,group1,condition2,target,10,107 22 | 101,group1,condition2,target,9,23 23 | 101,group1,condition2,target,8,24 24 | 101,group1,condition2,target,7,18 25 | 101,group1,condition2,target,6,8 26 | 101,group1,condition2,target,5,8 27 | 101,group1,condition2,target,4,8 28 | 101,group1,condition2,target,3,1 29 | 101,group1,condition2,target,2,1 30 | 101,group1,condition2,target,1,2 31 | 101,group1,condition2,lure,10,11 32 | 101,group1,condition2,lure,9,13 33 | 101,group1,condition2,lure,8,16 34 | 101,group1,condition2,lure,7,34 35 | 101,group1,condition2,lure,6,27 36 | 101,group1,condition2,lure,5,36 37 | 101,group1,condition2,lure,4,22 38 | 101,group1,condition2,lure,3,16 39 | 101,group1,condition2,lure,2,15 40 | 101,group1,condition2,lure,1,10 41 | 102,group2,condition1,target,10,105 42 | 102,group2,condition1,target,9,11 43 | 102,group2,condition1,target,8,19 44 | 102,group2,condition1,target,7,17 45 | 102,group2,condition1,target,6,15 46 | 102,group2,condition1,target,5,16 47 | 102,group2,condition1,target,4,13 48 | 102,group2,condition1,target,3,1 49 | 102,group2,condition1,target,2,1 50 | 102,group2,condition1,target,1,2 51 | 102,group2,condition1,lure,10,13 52 | 102,group2,condition1,lure,9,9 53 | 102,group2,condition1,lure,8,17 54 | 102,group2,condition1,lure,7,30 55 | 102,group2,condition1,lure,6,25 56 | 102,group2,condition1,lure,5,29 57 | 102,group2,condition1,lure,4,29 58 | 102,group2,condition1,lure,3,20 59 | 102,group2,condition1,lure,2,16 60 | 102,group2,condition1,lure,1,12 61 | 102,group2,condition2,target,10,107 62 | 102,group2,condition2,target,9,27 63 | 102,group2,condition2,target,8,25 64 | 102,group2,condition2,target,7,18 65 | 102,group2,condition2,target,6,10 66 | 102,group2,condition2,target,5,9 67 | 102,group2,condition2,target,4,2 68 | 102,group2,condition2,target,3,0 69 | 102,group2,condition2,target,2,1 70 | 102,group2,condition2,target,1,1 71 | 102,group2,condition2,lure,10,9 72 | 102,group2,condition2,lure,9,13 73 | 102,group2,condition2,lure,8,19 74 | 102,group2,condition2,lure,7,32 75 | 102,group2,condition2,lure,6,25 76 | 102,group2,condition2,lure,5,27 77 | 102,group2,condition2,lure,4,23 78 | 102,group2,condition2,lure,3,24 79 | 102,group2,condition2,lure,2,11 80 | 102,group2,condition2,lure,1,17 81 | -------------------------------------------------------------------------------- /examples/tutorial3_script.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/examples/tutorial3_script.m -------------------------------------------------------------------------------- /fit_statistics/calc_aic_bic.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/fit_statistics/calc_aic_bic.m -------------------------------------------------------------------------------- /fit_statistics/calc_chi_squared.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/fit_statistics/calc_chi_squared.m -------------------------------------------------------------------------------- /fit_statistics/calc_g.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/fit_statistics/calc_g.m -------------------------------------------------------------------------------- /fit_statistics/calc_model_fit.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/fit_statistics/calc_model_fit.m -------------------------------------------------------------------------------- /fit_statistics/calc_neg_log_likelihood.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/fit_statistics/calc_neg_log_likelihood.m -------------------------------------------------------------------------------- /fit_statistics/calc_r_squared.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/fit_statistics/calc_r_squared.m -------------------------------------------------------------------------------- /fit_statistics/calc_ss_error.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/fit_statistics/calc_ss_error.m -------------------------------------------------------------------------------- /fit_statistics/calc_ss_total.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/fit_statistics/calc_ss_total.m -------------------------------------------------------------------------------- /in_alpha/calc_likelihood.m: -------------------------------------------------------------------------------- 1 | function likelihood = calc_likelihood(pars,model,targf,luref,scalar) 2 | % Input descriptions are same as most ROC Toolbox functions. 3 | % Scalar input defines a value to scale the likelihood by so Matlab 4 | % does not round to 0 (recommended 10^200 at minimum). 5 | 6 | % Get the predicted data 7 | predData = calc_pred_data(model,pars,sum(targf,2),sum(luref,2),'points'); 8 | targp = predData.target.proportions; 9 | lurep = predData.lure.proportions; 10 | 11 | % Compute likelihood 12 | targl = targp .^ targf; 13 | lurel = lurep .^ luref; 14 | likelihood = vertcat(scalar,targl(:),lurel(:)); 15 | likelihood = prod(likelihood); 16 | 17 | end -------------------------------------------------------------------------------- /in_alpha/est_posterior_ex_script.m: -------------------------------------------------------------------------------- 1 | %% Alpha Script: Estimate Posterior Distribution of Parameters Using Grid Search 2 | % The purpose of this script is to establish a framework to estimate the 3 | % posterior distribution of the parameter estimates given a set of priors. 4 | % This script fits the DPSD model to an example data set and, given a set 5 | % of priors for each parameters, computes the expected posterior 6 | % distribution. The posterior is computed as follows: 7 | % 8 | % p(theta|data) = p(data|theta) * p(theta) 9 | % 10 | % To be fully implemented into the ROC Toolbox, a method needs to be 11 | % develop that (1) allows users to easily define priors, (2) an input 12 | % framework that will automatically develop the function for the posterior 13 | % distribution (as defined above) given N priors, and (3) that can be 14 | % easily expanded to accommodate any experimental design (as the ROC 15 | % toolbox does currently with the MLE estimation). 16 | % 17 | % For ease of demonstrating how to do this, I assume the F and criterion 18 | % parameters from the MLE estimatation are 100% accurate (i.e., my prior 19 | % belief in these parameters are whatever MLE says they are). This is 20 | % circular, and is never recommended in a real analysis. This is to avoid 21 | % having a very large N-dimensional parameter space (in this example, there 22 | % are 14 parameters). 23 | % 24 | % If we can accomplish integrating the definition of priors into the code 25 | % then it should be fairly simple to estimate the posterior distribution 26 | % for each data set using MCMC estimation wiht the SLICESAMPLE.m function. 27 | % 28 | % To resolve the rounding issue when using SLICESAMPLE.m, the likelihood 29 | % pdf can be defined as a log-likelihood PDF (with the 'logpdf' instead of 30 | % 'pdf' flag). 31 | 32 | %% Define Example data (Same as supplemental material) 33 | % Column 1 is Sure Old and Column 20 is Sure New. 34 | % Row 1 is Low Frequency Words and Row 2 is High Frequency words. 35 | targf = [77 18 13 8 4 3 5 4 8 7 4 5 3 7 1 5 5 7 11 5; 36 | 57 25 13 9 9 3 7 8 13 11 8 11 5 2 4 3 5 6 0 1]; 37 | luref = [3 2 8 4 4 3 1 4 11 8 15 15 6 7 6 11 14 28 33 17; 38 | 5 9 6 8 4 5 7 4 11 12 20 13 10 7 8 5 15 17 28 6]; 39 | 40 | % For ease of this example, collapse data into 6 bins as done in Mickes et 41 | % al. (2007), Psych Bull Rev. 42 | targf = [sum(targf(:,1:4),2) sum(targf(:,5:7),2) sum(targf(:,8:10),2) ... 43 | sum(targf(:,11:13),2) sum(targf(:,14:16),2) sum(targf(:,17:end),2)]; 44 | luref = [sum(luref(:,1:4),2) sum(luref(:,5:7),2) sum(luref(:,8:10),2) ... 45 | sum(luref(:,11:13),2) sum(luref(:,14:16),2) sum(luref(:,17:end),2)]; 46 | 47 | %% Fit the DPSD model using MLE 48 | % Define the model to fit to the data 49 | model = 'dpsd'; % Fit the DPSD model to the data 50 | parNames = {'Ro' 'F'}; % Fit the Ro and F (d') parameters of the DPSD model. Rn and vF are set to 0 and 1, respectively. 51 | [nConds,nBins] = size(targf); % Get the number of conditions (rows) and rating bins (columns) 52 | 53 | % Get the starting values (x0) and lower/upper bounds (LB and UB) of the 54 | % define model 55 | [x0,LB,UB] = gen_pars(model,nBins,nConds,parNames); 56 | 57 | % Define options for the ROC_SOLVER function 58 | fitStat = '-LL'; % Fit the model using MLE (by minimizing the negative log-likelihood) 59 | subID = 'S1'; % Define the subject ID 60 | condLabels = {'low frequency' 'high frequency'}; % Define the condition labels for the rows in targf and luref 61 | modelID = 'dpsd'; % Specifies a name or label for the model 62 | 63 | % Use ROC_SOLVER to fit the model to the data 64 | rocData = roc_solver(targf,luref,model,fitStat,x0,LB,UB, ... 65 | 'subID',subID,'condLabels',condLabels,'modelID',modelID); 66 | 67 | %% Define Likelihood Function and Priors 68 | % Define likelihood function 69 | likelihood = @(pars) calc_likelihood(pars,model,targf,luref,10^290); 70 | 71 | % Define Priors (all are uninformative and are uniform distributions) 72 | priors.Ro1 = @(x) unifpdf(x); 73 | priors.Ro2 = @(x) unifpdf(x); 74 | 75 | % Define a function to handle constant (unchanging) parameters 76 | bf_pars = rocData.dpsd_model.optimization_info.bf_pars; 77 | pars = @(Ro) horzcat(Ro,bf_pars(:,2:end)); 78 | 79 | % Define the posterior distribution 80 | posterior = @(p) likelihood(pars(p(:,1))) * ... % This is the likelihood 81 | priors.Ro1(p(1,1)) * priors.Ro2(p(2,1)); % Priors on the two F parameters 82 | 83 | % Compute posterior at best parameter point 84 | bestPost = posterior(bf_pars(:,1)); 85 | fprintf('Posterior at best fitting parameters: %s\n',num2str(bestPost)); 86 | 87 | %% Do User-Defined Grid Search of the parameter space 88 | fprintf('Grid Estimation of Posterior...\n'); 89 | % Define ranges of parameters (make them close to best fitting parameters) 90 | grid.Ro1 = .0:.01:.6; 91 | grid.Ro2 = 0:.01:.6; 92 | 93 | % Initialize postData 94 | postData = zeros(structfun(@length,grid)'); 95 | 96 | % Create a 4 level for loop 97 | for i = 1:length(grid.Ro1) 98 | for j = 1:length(grid.Ro2) 99 | 100 | p = [ 101 | grid.Ro1(i); grid.Ro2(j) 102 | ]; 103 | postData(i,j) = posterior(p); 104 | 105 | end 106 | end 107 | 108 | % Make mesh plot 109 | figure; 110 | mesh(grid.Ro2,grid.Ro1,postData*10^200); % Scale it up again to make it visible 111 | xlim([0 .6]); xlabel('Ro: High Freq'); 112 | ylim([0 .6]); ylabel('Ro: Low Freq'); 113 | zlabel('Posterior'); 114 | view([40,30,60]) 115 | 116 | %% Estimate posterior using MCMC estimation 117 | % Define options 118 | fprintf('MCMC Estimation of Posterior...\n'); 119 | nSamples = 10000; 120 | burnin = 5000; 121 | 122 | % ReDefine the posterior distribution (to take row vectors 123 | posterior = @(p) likelihood(pars(p')) * ... % This is the likelihood 124 | priors.Ro1(p(1)) * priors.Ro2(p(2)); % Priors on the two F parameters 125 | 126 | trace = slicesample([.2 .2],nSamples,'pdf',posterior,'burnin',burnin,'width',.1); 127 | 128 | % Make trace plot 129 | figure; 130 | subplot(2,1,1) 131 | plot(trace(:,1)); ylabel('Ro: Low Freq'); ylim([0 .6]); 132 | subplot(2,1,2); 133 | plot(trace(:,2)); ylabel('Ro: High Freq'); ylim([0 .6]); 134 | xlabel('Sample'); 135 | 136 | % Make 3d hist 137 | figure; 138 | hist3(fliplr(trace)); 139 | xlim([0 .6]); xlabel('Ro: High Freq'); 140 | ylim([0 .6]); ylabel('Ro: Low Freq'); 141 | zlabel('Posterior (Count)'); 142 | view([40,30,60]) 143 | 144 | 145 | -------------------------------------------------------------------------------- /input_checks/freq_size_check.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/input_checks/freq_size_check.m -------------------------------------------------------------------------------- /input_checks/model_check.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/input_checks/model_check.m -------------------------------------------------------------------------------- /input_checks/par_name_check.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/input_checks/par_name_check.m -------------------------------------------------------------------------------- /input_checks/par_size_check.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/input_checks/par_size_check.m -------------------------------------------------------------------------------- /main/calc_pred_data.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/main/calc_pred_data.m -------------------------------------------------------------------------------- /main/gen_pars.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/main/gen_pars.m -------------------------------------------------------------------------------- /main/gen_sim_data.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/main/gen_sim_data.m -------------------------------------------------------------------------------- /main/model_info.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/main/model_info.m -------------------------------------------------------------------------------- /main/roc_import_data.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/main/roc_import_data.m -------------------------------------------------------------------------------- /main/roc_solver.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/main/roc_solver.m -------------------------------------------------------------------------------- /models/dpsd/dpsd_calc_pred_data.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/models/dpsd/dpsd_calc_pred_data.m -------------------------------------------------------------------------------- /models/dpsd/dpsd_gen_pars.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/models/dpsd/dpsd_gen_pars.m -------------------------------------------------------------------------------- /models/dpsd/dpsd_gen_sim_data.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/models/dpsd/dpsd_gen_sim_data.m -------------------------------------------------------------------------------- /models/dpsd/dpsd_info.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/models/dpsd/dpsd_info.m -------------------------------------------------------------------------------- /models/msd/msd_calc_pred_data.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/models/msd/msd_calc_pred_data.m -------------------------------------------------------------------------------- /models/msd/msd_gen_pars.m: -------------------------------------------------------------------------------- 1 | function [x0,LB,UB] = msd_gen_pars(nBins,nConds,parNames) 2 | % Usage: 3 | % x0 = msd_gen_pars(nBins,nConds,parNames) 4 | % [x0,LB,UB] = msd_gen_pars(nBins,nConds,parNames) 5 | % 6 | % MSD_GEN_PARS creates default starting and bouding paramters for the MSD 7 | % model. The output is three vectors. One contains the starting values of 8 | % the parameters (x0), one contains the lower bounds of the parameters 9 | % (LB), and the last contains the upper bounds of the parameters (UB). The 10 | % LB and UB variables are used with roc_solver to constrain the 11 | % starting parameters (x0). 12 | % 13 | % Format of Output: 14 | % The output of this function is a MxN row vector. The length of the 15 | % vector depends on the number of confidence bins used in the experiment. 16 | % The vector) output from this function correspond to: 17 | % [lambda_targ Dprime1_targ var1_targ Dprime2_targ var2_targ ... 18 | % lambda_lure Dprime1_lure var1_lure Dprime2_lure var2_lure ... 19 | % criterion] 20 | % 21 | % Note that the first criterion value in the vector is always -1.5. The 22 | % remaining values in the vector are the interval between successive 23 | % criterion points, as this is needed for parameter estimation reasons 24 | % (i.e., monotonically increasing criterion placements). Hence, the LB 25 | % for the successive values is 0 rather than -Inf. 26 | % 27 | % Required Input: 28 | % nBins - This is the number of confidence bins in the scale used in 29 | % the experiment. This input creates a total of n-1 criterion points 30 | % ranging between -1.5 and 1.5 using the following formula: 31 | % criterion_x0=[-1.5 ones(1,nBins-2)*(3/(nBins-2))]; 32 | % criterion_LB=[-Inf zeros(1,nBins-2)]; 33 | % criterion_UB=[Inf Inf inf(1,nBins-2)]; 34 | % 35 | % nConds - This corresponds to the number of experimental conditions 36 | % in the data that will be simultaneously fitted. For example, if there 37 | % is only one group of target items and one group of lure items, then 38 | % nConds should equal 1, If there are two classes of target and lure 39 | % items 40 | % 41 | % parNames - This is a cell array of strings identifying the parameters 42 | % to be estimated. To specify the parameters, enter the appropriate 43 | % strings listed below into a cell array vector: 44 | % 45 | % TARGET DISTRIBUTION PARAMETERS: 46 | % 47 | % 'lambda_targ' - This specifies the mixing parameter for target items in 48 | % the MSD model. If given,x0 is set to .8, LB is set to 0, and UB is set 49 | % to 1. If this input is not given, x0, LB, and UB are set to 1 (i.e., 50 | % the parameter is not estimated). 51 | % 52 | % 'Dprime1_targ' - This specifies the memory strength (d') parameter for 53 | % the target item distribution scaled by lambda_targ. If given, x0 is 54 | % 1.5, LB is set to 0, and UB is set to Inf. If this input is not given, 55 | % x0, LB, and UB are all set to 0. Note that Dprime1_targ is the increase 56 | % in strength relative to Dprime2_targ. This is for estimation purposes 57 | % to constrain Dprime1_targ >= Dprime2_targ. However, do note that the 58 | % data output by the ROC_SOLVER reflects Dprime1_targ + Dprime2_targ. 59 | % 60 | % 'var1_targ' - This specifies the variance of the distribution for 61 | % Dprime1_targ. If given, x0 is set to 1, LB is set to 0, and UB is set 62 | % to Inf. If not given, then x0, LB, and UB are all set to 1. 63 | % 64 | % 'Dprime2_targ' - This specifies the memory strength (d') parameter of 65 | % the target item distribution scaled by 1-lambda_targ. If given, x0 is 66 | % 1, LB is set to -Inf and UB is set to Inf. If this is not specified, 67 | % x0, LB, and UB are all set to 0. 68 | % 69 | % 'var2_targ' - This specifies the variance of the distribution for 70 | % Dprime2_targ. If given, x0 is set to 1, LB is set to 0, and UB is set 71 | % to Inf. If not given, then x0, LB, and UB are all set to 1. 72 | % 73 | % LURE DISTRIBUTION PARAMETERS: 74 | % 75 | % 'lambda_lure' - This specifies the mixing parameter for lure items in 76 | % the MSD model. If given, x0 is set to .8, LB is set to 0, and UB is set 77 | % to 1. If this input is not given, x0, LB, and UB are set to 1 (i.e., 78 | % the parameter is not estimated). 79 | % 80 | % 'Dprime1_lure' - This specifies the memory strength (d') parameter for 81 | % the lure item distribution scaled by lambda_lure. If given, x0 is 82 | % 1.5, LB is set to 0, and UB is set to Inf. If this input is not given, 83 | % x0, LB, and UB are all set to 0. Note that Dprime1_lure is the increase 84 | % in strength relative to Dprime2_lure. This is for estimation purposes 85 | % to constrain Dprime1_lure >= Dprime2_lure. However, do note that the 86 | % data output by the ROC_SOLVER reflects Dprime1_lure + Dprime2_lure. 87 | % 88 | % 'var1_lure' - This specifies the variance of the distribution for 89 | % Dprime1_lure. If given, x0 is set to 1, LB is set to 0, and UB is set 90 | % to Inf. If not given, then x0, LB, and UB are all set to 1. 91 | % 92 | % 'Dprime2_lure' - This specifies the memory strength (d') parameter of 93 | % the lure item distribution scaled by 1-lambda_lure. If given, x0 is 94 | % 1, LB is set to -Inf and UB is set to Inf. If this is not specified, 95 | % x0, LB, and UB are all set to 0. 96 | % 97 | % 'var2_lure' - This specifies the variance of the distribution for 98 | % Dprime2_lure. If given, x0 is set to 1, LB is set to 0, and UB is set 99 | % to Inf. If not given, then x0, LB, and UB are all set to 1. 100 | % 101 | % Example: If you wanted to estimate lambda_targ, Dprime1_targ, and 102 | % Dprime2_targ, then you would use the following code: 103 | % parNames={'lambda_targ' 'Dprime1_targ' 'Dprime2_targ}; 104 | % [x0,LB,UB]=msd_gen_pars(nbins,nconds,parNames) 105 | % 106 | % Authored by: Joshua D. Koen 107 | 108 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 109 | % The ROC Toolbox is the proprietary property of The Regents of the 110 | % University of California (“The Regents.”) 111 | % 112 | % Copyright © 2014 The Regents of the University of California, Davis 113 | % campus. All Rights Reserved. 114 | % 115 | % Redistribution and use in source and binary forms, with or without 116 | % modification, are permitted by nonprofit, research institutions for 117 | % research use only, provided that the following conditions are met: 118 | % 119 | % • Redistributions of source code must retain the above copyright 120 | % notice, this list of conditions and the following disclaimer. 121 | % 122 | % • Redistributions in binary form must reproduce the above copyright 123 | % notice, this list of conditions and the following disclaimer in the 124 | % documentation and/or other materials provided with the distribution. 125 | % 126 | % • The name of The Regents may not be used to endorse or promote 127 | % products derived from this software without specific prior written 128 | % permission. 129 | % 130 | % The end-user understands that the program was developed for research 131 | % purposes and is advised not to rely exclusively on the program for any 132 | % reason. 133 | % 134 | % THE SOFTWARE PROVIDED IS ON AN "AS IS" BASIS, AND THE REGENTS HAVE NO 135 | % OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR 136 | % MODIFICATIONS. THE REGENTS SPECIFICALLY DISCLAIM ANY EXPRESS OR IMPLIED 137 | % WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 138 | % MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 139 | % IN NO EVENT SHALL THE REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, 140 | % INDIRECT, SPECIAL, INCIDENTAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES, 141 | % INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR 142 | % SERVICES, LOSS OF USE, DATA OR PROFITS, OR BUSINESS INTERRUPTION, 143 | % HOWEVER CAUSED AND UNDER ANY THEORY OF LIABILITY WHETHER IN CONTRACT, 144 | % STRICT LIABILITY OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 145 | % ANY WAY OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 146 | % ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 147 | % 148 | % If you do not agree to these terms, do not download or use the software. 149 | % This license may be modified only in a writing signed by authorized 150 | % signatory of both parties. 151 | % 152 | % For commercial license information please contact 153 | % copyright@ucdavis.edu. 154 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 155 | 156 | % TARGET DISTRIBUTION PARAMETERS 157 | % Set values for the lambda_targ 158 | if ismember('lambda_targ',parNames) 159 | lambda_targ=.8; 160 | llambda_targ=0; 161 | ulambda_targ=1; 162 | else 163 | lambda_targ=1; 164 | llambda_targ=1; 165 | ulambda_targ=1; 166 | end 167 | 168 | % Set values for the Dprime1_targ parameter 169 | if ismember('Dprime1_targ',parNames) 170 | Dprime1_targ=1.5; 171 | lDprime1_targ=0; 172 | uDprime1_targ=Inf; 173 | else 174 | Dprime1_targ=0; 175 | lDprime1_targ=0; 176 | uDprime1_targ=0; 177 | end 178 | 179 | % Set values for the var1_targ paramter 180 | if ismember('var1_targ',parNames) 181 | var1_targ=1; 182 | lvar1_targ=0; 183 | uvar1_targ=Inf; 184 | else 185 | var1_targ=1; 186 | lvar1_targ=1; 187 | uvar1_targ=1; 188 | end 189 | 190 | % Set values for the Dprime2_targ parameter 191 | if ismember('Dprime2_targ',parNames) 192 | Dprime2_targ=1; 193 | lDprime2_targ=-Inf; 194 | uDprime2_targ=Inf; 195 | else 196 | Dprime2_targ=0; 197 | lDprime2_targ=0; 198 | uDprime2_targ=0; 199 | end 200 | 201 | % Set values for the var2_targ paramter 202 | if ismember('var2_targ',parNames) 203 | var2_targ=1; 204 | lvar2_targ=0; 205 | uvar2_targ=Inf; 206 | else 207 | var2_targ=1; 208 | lvar2_targ=1; 209 | uvar2_targ=1; 210 | end 211 | 212 | % LURE DISTRIBUTION PARAMETERS 213 | % Set values for the lambda_lure 214 | if ismember('lambda_lure',parNames) 215 | lambda_lure=.8; 216 | llambda_lure=0; 217 | ulambda_lure=1; 218 | else 219 | lambda_lure=1; 220 | llambda_lure=1; 221 | ulambda_lure=1; 222 | end 223 | 224 | % Set values for the Dprime1_lure parameter 225 | if ismember('Dprime1_lure',parNames) 226 | Dprime1_lure=1.5; 227 | lDprime1_lure=0; 228 | uDprime1_lure=Inf; 229 | else 230 | Dprime1_lure=0; 231 | lDprime1_lure=0; 232 | uDprime1_lure=0; 233 | end 234 | 235 | % Set values for the var1_lure paramter 236 | if ismember('var1_lure',parNames) 237 | var1_lure=1; 238 | lvar1_lure=0; 239 | uvar1_lure=Inf; 240 | else 241 | var1_lure=1; 242 | lvar1_lure=1; 243 | uvar1_lure=1; 244 | end 245 | 246 | % Calculate criterion parameters 247 | criterion=[-1.5 ones(1,nBins-2)*(3/(nBins-2))]; 248 | lcriterion=[-Inf zeros(1,nBins-2)]; 249 | ucriterion=[Inf inf(1,nBins-2)]; 250 | 251 | % Preallocate variables 252 | x0=zeros(nConds,8+length(criterion)); 253 | LB=zeros(nConds,8+length(criterion)); 254 | UB=zeros(nConds,8+length(criterion)); 255 | 256 | % Create output vectors 257 | for a=1:nConds 258 | x0(a,:)=[lambda_targ Dprime1_targ var1_targ Dprime2_targ var2_targ ... 259 | lambda_lure Dprime1_lure var1_lure criterion]; 260 | LB(a,:)=[llambda_targ lDprime1_targ lvar1_targ lDprime2_targ lvar2_targ ... 261 | llambda_lure lDprime1_lure lvar1_lure lcriterion]; 262 | UB(a,:)=[ulambda_targ uDprime1_targ uvar1_targ uDprime2_targ uvar2_targ ... 263 | ulambda_lure uDprime1_lure uvar1_lure ucriterion]; 264 | end 265 | 266 | end 267 | -------------------------------------------------------------------------------- /models/msd/msd_gen_sim_data.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/models/msd/msd_gen_sim_data.m -------------------------------------------------------------------------------- /models/msd/msd_info.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/models/msd/msd_info.m -------------------------------------------------------------------------------- /models/uvsd/uvsd_calc_pred_data.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/models/uvsd/uvsd_calc_pred_data.m -------------------------------------------------------------------------------- /models/uvsd/uvsd_gen_pars.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/models/uvsd/uvsd_gen_pars.m -------------------------------------------------------------------------------- /models/uvsd/uvsd_gen_sim_data.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/models/uvsd/uvsd_gen_sim_data.m -------------------------------------------------------------------------------- /models/uvsd/uvsd_info.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/models/uvsd/uvsd_info.m -------------------------------------------------------------------------------- /redistributions/loadtxt/finputcheck.m: -------------------------------------------------------------------------------- 1 | % finputcheck() - check Matlab function {'key','value'} input argument pairs 2 | % 3 | % Usage: >> result = finputcheck( varargin, fieldlist ); 4 | % >> [result varargin] = finputcheck( varargin, fieldlist, ... 5 | % callingfunc, mode ); 6 | % Input: 7 | % varargin - Cell array 'varargin' argument from a function call using 'key', 8 | % 'value' argument pairs. See Matlab function 'varargin' 9 | % fieldlist - A 4-column cell array, one row per 'key'. The first 10 | % column contains the key string, the second its type(s), 11 | % the third the accepted value range, and the fourth the 12 | % default value. Allowed types are 'boolean', 'integer', 13 | % 'real', 'string', 'cell' or 'struct'. For example, 14 | % {'key1' 'string' { 'string1' 'string2' } 'defaultval_key1'} 15 | % {'key2' {'real' 'integer'} { minint maxint } 'defaultval_key2'} 16 | % callingfunc - Calling function name for error messages. {default: none}. 17 | % mode - ['ignore'|'error'] ignore keywords that are either not specified 18 | % in the fieldlist cell array or generate an error. 19 | % {default: 'error'}. 20 | % Outputs: 21 | % result - If no error, structure with 'key' as fields and 'value' as 22 | % content. If error this output contain the string error. 23 | % varargin - residual varagin containing unrecognized input arguments. 24 | % Requires mode 'ignore' above. 25 | % 26 | % Note: In case of error, a string is returned containing the error message 27 | % instead of a structure. 28 | % 29 | % Example (insert the following at the beginning of your function): 30 | % result = finputcheck(varargin, ... 31 | % { 'title' 'string' [] ''; ... 32 | % 'percent' 'real' [0 1] 1 ; ... 33 | % 'elecamp' 'integer' [1:10] [] }); 34 | % if isstr(result) 35 | % error(result); 36 | % end 37 | % 38 | % Note: 39 | % The 'title' argument should be a string. {no default value} 40 | % The 'percent' argument should be a real number between 0 and 1. {default: 1} 41 | % The 'elecamp' argument should be an integer between 1 and 10 (inclusive). 42 | % 43 | % Now 'g.title' will contain the title arg (if any, else the default ''), etc. 44 | % 45 | % Author: Arnaud Delorme, CNL / Salk Institute, 10 July 2002 46 | 47 | %123456789012345678901234567890123456789012345678901234567890123456789012 48 | 49 | % Copyright (C) Arnaud Delorme, CNL / Salk Institute, 10 July 2002, arno@salk.edu 50 | % 51 | % This program is free software; you can redistribute it and/or modify 52 | % it under the terms of the GNU General Public License as published by 53 | % the Free Software Foundation; either version 2 of the License, or 54 | % (at your option) any later version. 55 | % 56 | % This program is distributed in the hope that it will be useful, 57 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 58 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 59 | % GNU General Public License for more details. 60 | % 61 | % You should have received a copy of the GNU General Public License 62 | % along with this program; if not, write to the Free Software 63 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 64 | 65 | % $Log: finputcheck.m,v $ 66 | % Revision 1.29 2007/03/07 03:54:51 toby 67 | % Documentation edits 68 | % 69 | % Revision 1.28 2007/01/26 17:59:20 arno 70 | % msg wording 71 | % 72 | % Revision 1.27 2006/09/30 07:38:52 toby 73 | % help message edit 74 | % 75 | % Revision 1.26 2006/09/28 03:20:21 toby 76 | % more doc edits 77 | % 78 | % Revision 1.25 2006/09/28 02:59:59 toby 79 | % documentation correction 80 | % 81 | % Revision 1.24 2006/03/11 05:37:07 arno 82 | % header 83 | % 84 | % Revision 1.23 2004/11/06 02:54:06 scott 85 | % a few further small edits to the help msg -sm 86 | % 87 | % Revision 1.22 2004/11/05 15:23:37 arno 88 | % ,sg 89 | % 90 | % Revision 1.21 2004/11/05 04:10:44 scott 91 | % help msg. -sm 92 | % 93 | % Revision 1.20 2004/06/09 16:30:42 arno 94 | % adding or if several types 95 | % 96 | % Revision 1.19 2003/10/29 16:35:57 arno 97 | % msg typo 98 | % 99 | % Revision 1.18 2003/07/30 23:53:58 arno 100 | % debug multiple return values 101 | % 102 | % Revision 1.17 2003/07/26 00:21:17 arno 103 | % allowing cell array for values 104 | % 105 | % Revision 1.16 2003/06/30 02:10:10 arno 106 | % strmatch exact 107 | % 108 | % Revision 1.15 2003/01/31 02:35:38 arno 109 | % debugging lowercase/upercase problem 110 | % 111 | % Revision 1.14 2002/11/20 01:05:44 arno 112 | % take into account duplicate parameters 113 | % 114 | % Revision 1.13 2002/11/18 17:15:18 arno 115 | % adding float arg (=real) 116 | % 117 | % Revision 1.12 2002/11/15 02:16:50 arno 118 | % header for web 119 | % 120 | % Revision 1.11 2002/09/30 15:29:23 arno 121 | % autorizing cell arrays for types 122 | % 123 | % Revision 1.10 2002/09/30 00:42:08 arno 124 | % debug input arguments 125 | % 126 | % Revision 1.9 2002/07/29 18:00:53 arno 127 | % debugging for NaN 128 | % 129 | % Revision 1.8 2002/07/29 17:24:22 arno 130 | % header 131 | % 132 | % Revision 1.7 2002/07/20 19:10:41 arno 133 | % debugging output 134 | % 135 | % Revision 1.6 2002/07/19 17:58:11 arno 136 | % returning non-matched 'key' 'val' arguments 137 | % 138 | % Revision 1.5 2002/07/19 17:46:53 arno 139 | % g empty if no varargin 140 | % 141 | % Revision 1.4 2002/07/19 16:27:14 arno 142 | % adding ignore mode 143 | % 144 | % Revision 1.3 2002/07/10 02:18:32 arno 145 | % header info 146 | % 147 | % Revision 1.2 2002/07/10 02:17:27 arno 148 | % debugging error message passing 149 | % 150 | % Revision 1.1 2002/07/10 01:03:19 arno 151 | % Initial revision 152 | % 153 | 154 | function [g, varargnew] = finputcheck( vararg, fieldlist, callfunc, mode ) 155 | 156 | if nargin < 2 157 | help finputcheck; 158 | return; 159 | end; 160 | if nargin < 3 161 | callfunc = ''; 162 | else 163 | callfunc = [callfunc ' ' ]; 164 | end; 165 | if nargin < 4 166 | mode = 'do not ignore'; 167 | end; 168 | NAME = 1; 169 | TYPE = 2; 170 | VALS = 3; 171 | DEF = 4; 172 | SIZE = 5; 173 | 174 | varargnew = {}; 175 | % create structure 176 | % ---------------- 177 | if ~isempty(vararg) 178 | vararg = removedup(vararg); 179 | for index=1:length(vararg) 180 | if iscell(vararg{index}) 181 | vararg{index} = {vararg{index}}; 182 | end; 183 | end; 184 | try 185 | g = struct(vararg{:}); 186 | catch 187 | g = [ callfunc 'error: bad ''key'', ''val'' sequence' ]; return; 188 | end; 189 | else 190 | g = []; 191 | end; 192 | 193 | for index = 1:size(fieldlist,NAME) 194 | % check if present 195 | % ---------------- 196 | if ~isfield(g, fieldlist{index, NAME}) 197 | g = setfield( g, fieldlist{index, NAME}, fieldlist{index, DEF}); 198 | end; 199 | tmpval = getfield( g, {1}, fieldlist{index, NAME}); 200 | 201 | % check type 202 | % ---------- 203 | if ~iscell( fieldlist{index, TYPE} ) 204 | res = fieldtest( fieldlist{index, NAME}, fieldlist{index, TYPE}, ... 205 | fieldlist{index, VALS}, tmpval, callfunc ); 206 | if isstr(res), g = res; return; end; 207 | else 208 | testres = 0; 209 | tmplist = fieldlist; 210 | for it = 1:length( fieldlist{index, TYPE} ) 211 | if ~iscell(fieldlist{index, VALS}) 212 | res{it} = fieldtest( fieldlist{index, NAME}, fieldlist{index, TYPE}{it}, ... 213 | fieldlist{index, VALS}, tmpval, callfunc ); 214 | else res{it} = fieldtest( fieldlist{index, NAME}, fieldlist{index, TYPE}{it}, ... 215 | fieldlist{index, VALS}{it}, tmpval, callfunc ); 216 | end; 217 | if ~isstr(res{it}), testres = 1; end; 218 | end; 219 | if testres == 0, 220 | g = res{1}; 221 | for tmpi = 2:length(res) 222 | g = [ g 10 'or ' res{tmpi} ]; 223 | end; 224 | return; 225 | end; 226 | end; 227 | end; 228 | 229 | % check if fields are defined 230 | % --------------------------- 231 | allfields = fieldnames(g); 232 | for index=1:length(allfields) 233 | if isempty(strmatch(allfields{index}, fieldlist(:, 1)', 'exact')) 234 | if ~strcmpi(mode, 'ignore') 235 | g = [ callfunc 'error: undefined argument ''' allfields{index} '''']; return; 236 | end; 237 | varargnew{end+1} = allfields{index}; 238 | varargnew{end+1} = getfield(g, {1}, allfields{index}); 239 | end; 240 | end; 241 | 242 | 243 | function g = fieldtest( fieldname, fieldtype, fieldval, tmpval, callfunc ); 244 | NAME = 1; 245 | TYPE = 2; 246 | VALS = 3; 247 | DEF = 4; 248 | SIZE = 5; 249 | g = []; 250 | 251 | switch fieldtype 252 | case { 'integer' 'real' 'boolean' 'float' }, 253 | if ~isnumeric(tmpval) 254 | g = [ callfunc 'error: argument ''' fieldname ''' must be numeric' ]; return; 255 | end; 256 | if strcmpi(fieldtype, 'boolean') 257 | if tmpval ~=0 & tmpval ~= 1 258 | g = [ callfunc 'error: argument ''' fieldname ''' must be 0 or 1' ]; return; 259 | end; 260 | else 261 | if strcmpi(fieldtype, 'integer') 262 | if ~isempty(fieldval) 263 | if (isnan(tmpval) & ~any(isnan(fieldval))) ... 264 | & (~ismember(tmpval, fieldval)) 265 | g = [ callfunc 'error: wrong value for argument ''' fieldname '''' ]; return; 266 | end; 267 | end; 268 | else % real or float 269 | if ~isempty(fieldval) 270 | if tmpval < fieldval(1) | tmpval > fieldval(2) 271 | g = [ callfunc 'error: value out of range for argument ''' fieldname '''' ]; return; 272 | end; 273 | end; 274 | end; 275 | end; 276 | 277 | 278 | case 'string' 279 | if ~isstr(tmpval) 280 | g = [ callfunc 'error: argument ''' fieldname ''' must be a string' ]; return; 281 | end; 282 | if ~isempty(fieldval) 283 | if isempty(strmatch(lower(tmpval), lower(fieldval), 'exact')) 284 | g = [ callfunc 'error: wrong value for argument ''' fieldname '''' ]; return; 285 | end; 286 | end; 287 | 288 | 289 | case 'cell' 290 | if ~iscell(tmpval) 291 | g = [ callfunc 'error: argument ''' fieldname ''' must be a cell array' ]; return; 292 | end; 293 | 294 | 295 | case 'struct' 296 | if ~isstruct(tmpval) 297 | g = [ callfunc 'error: argument ''' fieldname ''' must be a structure' ]; return; 298 | end; 299 | 300 | 301 | case ''; 302 | otherwise, error([ 'finputcheck error: unrecognized type ''' fieldname '''' ]); 303 | end; 304 | 305 | % remove duplicates in the list of parameters 306 | % ------------------------------------------- 307 | function cella = removedup(cella) 308 | [tmp indices] = unique(cella(1:2:end)); 309 | if length(tmp) ~= length(cella)/2 310 | fprintf('Note: duplicate ''key'', ''val'' parameter(s), keeping the last one(s)\n'); 311 | end; 312 | cella = cella(sort(union(indices*2-1, indices*2))); -------------------------------------------------------------------------------- /redistributions/loadtxt/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, Arnaud Delorme 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /redistributions/loadtxt/loadtxt.m: -------------------------------------------------------------------------------- 1 | % loadtxt() - load ascii text file into numeric or cell arrays 2 | % 3 | % Usage: 4 | % >> array = loadtxt( filename, 'key', 'val' ...); 5 | % 6 | % Inputs: 7 | % filename - name of the input file 8 | % 9 | % Optional inputs 10 | % 'skipline' - number of lines to skip {default:0}. If this number is 11 | % negative the program will only skip non-empty lines 12 | % (can be usefull for files transmitted from one platform 13 | % to an other, as CR may be inserted at every lines). 14 | % 'convert' - 'on' standard text conversion, see note 1 15 | % 'off' no conversion, considers text only 16 | % 'force' force conversion, NaN are returned 17 | % for non-numeric inputs {default:'on'} 18 | % 'delim' - ascii character for delimiters. {default:[9 32] 19 | % i.e space and tab}. It is also possible to enter 20 | % strings, Ex: [9 ' ' ',']. 21 | % 'blankcell' - ['on'|'off'] extract blank cells {default:'on'} 22 | % 'verbose' - ['on'|'off'] {default:'on'} 23 | % 'nlines' - [integer] number of lines to read {default: all file} 24 | % 25 | % Outputs: 26 | % array - cell array. If the option 'force' is given, the function 27 | % retrun a numeric array. 28 | % 29 | % Notes: 1) Since it uses cell arrays, the function can handle text input. 30 | % The function reads each token and then try to convert it to a 31 | % number. If the conversion is unsucessfull, the string itself 32 | % is included in the array. 33 | % 2) The function adds empty entries for rows that contains 34 | % fewer columns than others. 35 | % 36 | % Author: Arnaud Delorme, CNL / Salk Institute, 29 March 2002 37 | 38 | % Copyright (C) Arnaud Delorme, CNL / Salk Institute, 29 March 2002 39 | % 40 | % This program is free software; you can redistribute it and/or modify 41 | % it under the terms of the GNU General Public License as published by 42 | % the Free Software Foundation; either version 2 of the License, or 43 | % (at your option) any later version. 44 | % 45 | % This program is distributed in the hope that it will be useful, 46 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 47 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 48 | % GNU General Public License for more details. 49 | % 50 | % You should have received a copy of the GNU General Public License 51 | % along with this program; if not, write to the Free Software 52 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 53 | 54 | function array = loadtxt( filename, varargin ); 55 | 56 | if nargin < 1 57 | help loadtxt; 58 | return; 59 | end; 60 | if ~isempty(varargin) 61 | try, g = struct(varargin{:}); 62 | catch, disp('Wrong syntax in function arguments'); return; end; 63 | else 64 | g = []; 65 | end; 66 | 67 | g = finputcheck( varargin, { 'convert' 'string' { 'on' 'off' 'force' } 'on'; 68 | 'skipline' 'integer' [0 Inf] 0; 69 | 'verbose' 'string' { 'on' 'off' } 'on'; 70 | 'uniformdelim' 'string' { 'on' 'off' } 'off'; 71 | 'blankcell' 'string' { 'on' 'off' } 'on'; 72 | 'delim' { 'integer' 'string' } [] [9 32]; 73 | 'nlines' 'integer' [] Inf }); 74 | if isstr(g), error(g); end; 75 | if strcmpi(g.blankcell, 'off'), g.uniformdelim = 'on'; end; 76 | g.convert = lower(g.convert); 77 | g.verbose = lower(g.verbose); 78 | g.delim = char(g.delim); 79 | 80 | % open the file 81 | % ------------- 82 | if exist(filename) ~=2, error( ['file ' filename ' not found'] ); end; 83 | fid=fopen(filename,'r','ieee-le'); 84 | if fid<0, error( ['file ' filename ' found but error while opening file'] ); end; 85 | 86 | index = 0; 87 | while index < abs(g.skipline) 88 | tmpline = fgetl(fid); 89 | if g.skipline > 0 | ~isempty(tmpline) 90 | index = index + 1; 91 | end; 92 | end; % skip lines --------- 93 | 94 | inputline = fgetl(fid); 95 | linenb = 1; 96 | if strcmp(g.verbose, 'on'), fprintf('Reading file (lines): '); end; 97 | while isempty(inputline) | inputline~=-1 98 | colnb = 1; 99 | if ~isempty(inputline) 100 | tabFirstpos = 1; 101 | 102 | % convert all delimiter to the first one 103 | if strcmpi(g.uniformdelim, 'on') 104 | for index = 2:length(g.delim) 105 | inputline(find(inputline == g.delim(index))) = g.delim(1); 106 | end; 107 | end; 108 | 109 | while ~isempty(deblank(inputline)) 110 | if strcmpi(g.blankcell,'off'), inputline = strtrim(inputline); end; 111 | if tabFirstpos && length(inputline) > 1 && all(inputline(1) ~= g.delim), tabFirstpos = 0; end; 112 | [tmp inputline tabFirstpos] = mystrtok(inputline, g.delim, tabFirstpos); 113 | switch g.convert 114 | case 'off', array{linenb, colnb} = tmp; 115 | case 'on', 116 | tmp2 = str2double(tmp); 117 | if isnan( tmp2 ) , array{linenb, colnb} = tmp; 118 | else array{linenb, colnb} = tmp2; 119 | end; 120 | case 'force', array{linenb, colnb} = str2double(tmp); 121 | end; 122 | colnb = colnb+1; 123 | end; 124 | linenb = linenb +1; 125 | end; 126 | inputline = fgetl(fid); 127 | if linenb > g.nlines 128 | inputline = -1; 129 | end; 130 | if ~mod(linenb,10) & strcmp(g.verbose, 'on'), fprintf('%d ', linenb); end; 131 | end; 132 | if strcmp(g.verbose, 'on'), fprintf('%d\n', linenb-1); end; 133 | if strcmp(g.convert, 'force'), array = [ array{:} ]; end; 134 | fclose(fid); 135 | 136 | % problem strtok do not consider tabulation 137 | % ----------------------------------------- 138 | function [str, strout, tabFirstpos] = mystrtok(strin, delim, tabFirstpos); 139 | % remove extra spaces at the beginning 140 | while any(strin(1) == delim) && strin(1) ~= 9 && strin(1) ~= ',' 141 | strin = strin(2:end); 142 | end; 143 | % for tab and coma, consider empty cells 144 | if length(strin) > 1 && any(strin(1) == delim) 145 | if tabFirstpos || any(strin(2) == delim) 146 | str = ''; 147 | strout = strin(2:end); 148 | if strin(2) ~= 9 && strin(2) ~= ',' 149 | tabFirstpos = 0; 150 | strout = strtrim(strout); 151 | end; 152 | else 153 | [str, strout] = strtok(strin, delim); 154 | end; 155 | else 156 | [str, strout] = strtok(strin, delim); 157 | end; 158 | -------------------------------------------------------------------------------- /redistributions/sortcell/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009, Jeffrey Jackson 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /redistributions/sortcell/sortcell.m: -------------------------------------------------------------------------------- 1 | function Y = sortcell(X, DIM) 2 | % SORTCELL Sort a cell array in ascending order. 3 | % 4 | % Description: SORTCELL sorts the input cell array according to the 5 | % dimensions (columns) specified by the user. 6 | % 7 | % Usage: Y = sortcell(X, DIM) 8 | % 9 | % Input: 10 | % X: the cell array to be sorted. 11 | % DIM: (optional) one or more column numbers. Simply an array of one or 12 | % more column numbers. The first number is the primary column on 13 | % which to sort. Extra column numbers may be supplied if secondary 14 | % sorting is required. The defuault value is 1, if no dimension 15 | % array is supplied. 16 | % 17 | % Output: 18 | % Y: the sorted cell array. 19 | % 20 | % Example: Y = sortcell(X, [3 2]) 21 | % 22 | % Note that this function has only been tested on mixed cell arrays 23 | % containing character strings and numeric values. 24 | % 25 | % Documentation Date: Feb.01,2007 13:36:04 26 | % 27 | % Tags: 28 | % {TAG} {TAG} {TAG} 29 | % 30 | % 31 | 32 | % Copyright 2007 Jeff Jackson (Ocean Sciences, DFO Canada) 33 | % Creation Date: Jan. 24, 2007 34 | % Last Updated: Jan. 25, 2007 35 | 36 | % Check to see if no input arguments were supplied. If this is the case, 37 | % stop execution and output an error message to the user. 38 | if nargin == 0 39 | error('No input arguments were supplied. At least one is expected.'); 40 | % Check to see if the only input argument is a cell array. If it isn't 41 | % then stop execution and output an error message to the user. Also set the 42 | % DIM value since it was not supplied. 43 | elseif nargin == 1 44 | if ~iscell(X) 45 | error('Input argument is not a cell array. A cell array is expected.'); 46 | end 47 | DIM = 1; 48 | % Check to see if the first input argument is a cell array and the second 49 | % one is numeric. If either check fails then stop execution and output an 50 | % error message to the user. 51 | elseif nargin == 2 52 | if ~iscell(X) 53 | error('The first input argument is not a cell array. A cell array is expected.'); 54 | end 55 | if ~isnumeric(DIM) 56 | error('The second input argument is not numeric. At least one numeric value is expected.'); 57 | end 58 | % Check to see if too many arguments were input. If there were then exit 59 | % the function issuing a error message to the user. 60 | elseif nargin > 2 61 | error('Too many input arguments supplied. Only two are allowed.'); 62 | end 63 | 64 | % Now find out if the cell array is being sorted on more than one column. 65 | % If it is then use recursion to call the sortcell function again to sort 66 | % the less important columns first. Repeat calls to sortcell until only one 67 | % column is left to be sorted. Then return the sorted cell array to the 68 | % calling function to continue with the higher priority sorting. 69 | ndim = length(DIM); 70 | if ndim > 1 71 | col = DIM(2:end); 72 | X = sortcell(X, col); 73 | end 74 | 75 | % Get the dimensions of the input cell array. 76 | [nrows, ncols] = size(X); 77 | 78 | % Retrieve the primary dimension (column) to be sorted. 79 | col = DIM(1); 80 | 81 | % Place the cells for this column in variable 'B'. 82 | B = X(:,col); 83 | 84 | % Check each cell in cell array 'B' to see if it contains either a 85 | % character string or numeric value. If it is a character string it returns 86 | % a '1' in the same location of boolean array 'a'; a '0' otherwise. If it 87 | % is a numeric value it returns a '1' in the boolean array 'b'; a '0' 88 | % otherwise. 89 | a = cellfun('isclass', B, 'char'); 90 | suma = sum(a); 91 | b = cellfun('isclass', B, 'double'); 92 | sumb = sum(b); 93 | 94 | % Check to see if cell array 'B' contained only character string. 95 | % If cell array B contains character strings then do nothing because 96 | % no further content handling is required. 97 | if suma == nrows 98 | % Check to see if cell array 'B' contained only numeric values. 99 | elseif sumb == nrows 100 | % If the cells in cell array 'B' contain numeric values retrieve the cell 101 | % contents and change 'B' to a numeric array. 102 | B = [B{:}]; 103 | else 104 | error('This column is mixed so sorting cannot be completed.'); 105 | end 106 | 107 | % Sort the current array and return the new index. 108 | [ix,ix] = sort(B); 109 | 110 | % Using the index from the sorted array, update the input cell array and 111 | % return it. 112 | Y = X(ix,:); 113 | -------------------------------------------------------------------------------- /roc_startup.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/roc_startup.m -------------------------------------------------------------------------------- /roc_version.m: -------------------------------------------------------------------------------- 1 | function roc_version 2 | % Usage: 3 | % roc_version() 4 | % 5 | % This function prints the version of the ROC Toolbox to the screen. 6 | % 7 | % Authored by: Joshua Koen 8 | 9 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 10 | % The ROC Toolbox is the proprietary property of The Regents of the 11 | % University of California (“The Regents.”) 12 | % 13 | % Copyright © 2014 The Regents of the University of California, Davis 14 | % campus. All Rights Reserved. 15 | % 16 | % Redistribution and use in source and binary forms, with or without 17 | % modification, are permitted by nonprofit, research institutions for 18 | % research use only, provided that the following conditions are met: 19 | % 20 | % • Redistributions of source code must retain the above copyright 21 | % notice, this list of conditions and the following disclaimer. 22 | % 23 | % • Redistributions in binary form must reproduce the above copyright 24 | % notice, this list of conditions and the following disclaimer in the 25 | % documentation and/or other materials provided with the distribution. 26 | % 27 | % • The name of The Regents may not be used to endorse or promote 28 | % products derived from this software without specific prior written 29 | % permission. 30 | % 31 | % The end-user understands that the program was developed for research 32 | % purposes and is advised not to rely exclusively on the program for any 33 | % reason. 34 | % 35 | % THE SOFTWARE PROVIDED IS ON AN "AS IS" BASIS, AND THE REGENTS HAVE NO 36 | % OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR 37 | % MODIFICATIONS. THE REGENTS SPECIFICALLY DISCLAIM ANY EXPRESS OR IMPLIED 38 | % WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 39 | % MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 40 | % IN NO EVENT SHALL THE REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, 41 | % INDIRECT, SPECIAL, INCIDENTAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES, 42 | % INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR 43 | % SERVICES, LOSS OF USE, DATA OR PROFITS, OR BUSINESS INTERRUPTION, 44 | % HOWEVER CAUSED AND UNDER ANY THEORY OF LIABILITY WHETHER IN CONTRACT, 45 | % STRICT LIABILITY OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 46 | % ANY WAY OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 47 | % ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | % 49 | % If you do not agree to these terms, do not download or use the software. 50 | % This license may be modified only in a writing signed by authorized 51 | % signatory of both parties. 52 | % 53 | % For commercial license information please contact 54 | % copyright@ucdavis.edu. 55 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 56 | 57 | version = '1.1.3'; 58 | fprintf('ROC Toolbox v%s\n',version); 59 | 60 | end 61 | -------------------------------------------------------------------------------- /sdt_accuracy_bias/calc_acc_aprime.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/sdt_accuracy_bias/calc_acc_aprime.m -------------------------------------------------------------------------------- /sdt_accuracy_bias/calc_acc_auc.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/sdt_accuracy_bias/calc_acc_auc.m -------------------------------------------------------------------------------- /sdt_accuracy_bias/calc_acc_az.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/sdt_accuracy_bias/calc_acc_az.m -------------------------------------------------------------------------------- /sdt_accuracy_bias/calc_acc_da.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/sdt_accuracy_bias/calc_acc_da.m -------------------------------------------------------------------------------- /sdt_accuracy_bias/calc_acc_dprime.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/sdt_accuracy_bias/calc_acc_dprime.m -------------------------------------------------------------------------------- /sdt_accuracy_bias/calc_acc_dr.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/sdt_accuracy_bias/calc_acc_dr.m -------------------------------------------------------------------------------- /sdt_accuracy_bias/calc_bias_beta.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/sdt_accuracy_bias/calc_bias_beta.m -------------------------------------------------------------------------------- /sdt_accuracy_bias/calc_bias_c.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/sdt_accuracy_bias/calc_bias_c.m -------------------------------------------------------------------------------- /sdt_accuracy_bias/calc_rating_acc_bias.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/sdt_accuracy_bias/calc_rating_acc_bias.m -------------------------------------------------------------------------------- /utilities/bin_sim_data.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/utilities/bin_sim_data.m -------------------------------------------------------------------------------- /utilities/bootstrap_freqs.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/utilities/bootstrap_freqs.m -------------------------------------------------------------------------------- /utilities/calc_nTrials.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/utilities/calc_nTrials.m -------------------------------------------------------------------------------- /utilities/cumulp2freq.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/utilities/cumulp2freq.m -------------------------------------------------------------------------------- /utilities/freq2zscores.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/utilities/freq2zscores.m -------------------------------------------------------------------------------- /utilities/get_all_models.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/utilities/get_all_models.m -------------------------------------------------------------------------------- /utilities/get_group_data.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/utilities/get_group_data.m -------------------------------------------------------------------------------- /utilities/plot_roc_summary.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/utilities/plot_roc_summary.m -------------------------------------------------------------------------------- /utilities/remove_bad_zvalues.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/utilities/remove_bad_zvalues.m -------------------------------------------------------------------------------- /utilities/summarize_model.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdkoen/roc_toolbox/7f73ea7f0cb67bcd61b6e1141761f5357530d388/utilities/summarize_model.m --------------------------------------------------------------------------------