Extending and Customizing- How do I change the default options in the Matlab function PFIT?
Depending on the application, people will use the psignifit software in different ways, but each user will probably stick to a similar set of options (for instance, always using the Weibull function, always with a certain prior on lambda, always computing slopes with respect to log10 x, etc). It is strongly recommended that you do not edit the m-files of the psignifit toolbox to install your default options, or for any other reason: this is simply because it is a non-modular form of development, and it will only require you to do the work over again if you ever download a future version of the toolbox. For the same reason, do not add files to the psignifit toolbox directory (or for that matter any other toolbox directory). Instead, keep your own code in your own directory and add that directory to the Matlab path (for experienced Matlab users this may seem an obvious thing to say - for others perhaps less so). Instead, you can add your own defaults by creating a "wrapper" function (in a separate directory), such as the following example: function [s, sFull, str] = myfit(dat, varargin)
MYFIT: example of personalized wrapper around PFIT (N.B. change the name MYFIT to something more informative!) Personalized default options (listed in the m-file), are used with syntax: s = myfit(dat); Options can be added/overridden by specifying further arguments, e.g: s = myfit(dat, 'shape', 'logistic', 'sens', '0', 'plot_opt', 'plot'); defaultOpts = { % list your preferred defaults here, for example: 'shape' 'weibull' 'n_intervals' '2' 'slope_opt' 'log' 'runs' '1999' 'verbose' 'false' 'lambda_prior' '-g [0, 0.02]' }'; % note the tick to transpose the cell array - this is vital
[s sFull str] = pfit(dat, defaultOpts{:}, varargin{:});
- Is it possible to implement the <insert name> psychometric function instead of the logistic, Weibull, etc?
If you want to add a new psychometric function shape to the psignifit engine, it needs to be written in C and added to Psychometric.c before the engine (mex-file) is compiled. The function should follow the conventions laid down in the other functions from that file: if you look at, for example, JLogistic, you'll note that the function can operate in several different modes and has to be able to return derivatives, inverses and slopes, among other information. Once you've written it, you have to add your function to the list of recognized function names in PsychoPrefs.c: In the function MatchShape, there are two definitions that need to be changed:
#define kNumberOfShapes 5 PsychDistribFuncPtr matched = NULL, possible[kNumberOfShapes] = {JCumulativeGaussian, JGumbel, JLogistic, JWeibull, JLinear}; Add your new function name to the list, and increment kNumberOfShapes accordingly. Then you need to re-compile the engine (lucky you). That would allow you to use the engine to fit and bootstrap with your new function. You would also have to make (similar, but somewhat simpler) additions to psychf.m in order for the Matlab toolbox to plot your function in the normal way.
|