wichmann-lab/psignifit

Remove toolbox dependencies

Closed this issue · 3 comments

The software requires expensive additional toolboxes (at least for R2012a) for the functions betapdf(), lgamma() and normpdf(). There are free versions of these functions that use the same GPL as this project. Including these would support additional users. One could either add these as direct replacements (though they may or not be as optimized as builtin functions) or put them in an 'extra' folder that is added to the path if and only if the proprietary functions are not found:

function addGplFcns 
%adds path to 'extra' if functions not found betapdf(), lgamma() and normpdf()
% Matlab only supplies these with expensive toolboxes.
% The 'extra' folder holds GPL versions of these functions

if exist('betapdf','file') &&  exist('lgamma','file') && exist('normpdf','file'), return; end;
%at least one function missing
fprintf('x');
extPath = fullfile(fileparts(mfilename('fullpath')), 'extra'); % get the full path to this function, strip away 'ft_defaults'
if ~exist(extPath, 'dir'), warning('Unable to find folder %s', extPath); end;
addpath(extPath);

extra.zip

Hi!
Could you check where exactly these functions are used in the code in your older matlab version? I could not find it immediately and in most places at least we already use self written simplifications for these functions. (my_[] in private)

Also in R2016a I am sure we only require the original matlab license (I just checked again and license('inuse') returns only matlab after running some fits in psignifit)

I am using the latest version of your software from Github. With R2012a (and no toolboxes) the script demo_006 fails

Error in getSlope (line 39)
        slopeNormalized = normpdf(normalizedStimLevel);

If you supply the attached normpdf the same script fails

Undefined function 'betapdf' for input arguments of type 'double'.
Error in biasAna/@(x)betapdf(x,2,2)

lgamma is a dependency of the betapdf I supplied, if you include normpdf and betapdf without lgamma the same script fails

Undefined function 'lgamma' for input arguments of type 'double'.
Error in betapdf (line 64)
    pdf(k) = exp ((a - 1) * log (x(k))...

including these as my_normpdf, my_betapdf would fix the issue for older versions of Matlab that do not have the Statistics and Machine Learning Toolbox

I just fixed this.
biasAna now uses the already provided my_betapdf which we striped of all checks
for normpdf I now swiftly implemented the standard normal pdf, which is the only case we need.

Thank you for the hint! This kind of dependency is easy to miss.