1
function [response] = ComputeNakaRushton(params,contrast)
b'% [response] = ComputeNakaRushton(params,contrast)'
b'% Compute the Naka-Rushton function on passed vector of contrasts.'
b'% Several different forms may be computed depending on length of'
b'% passed params vector.'
b'% response = contrast^n/[contrast^n + sigma^n]'
b'% response = Rmax*[contrast^n]/[contrast^n + sigma^n]'
b'% response = Rmax*[contrast^n]/[contrast^m + sigma^m]'
b'% 8/1/05 dhb, pr Wrote from FitLightnessOrient version'
b'% 8/2/07 dhb Rewrote to allow several different forms depending'
b'% on length of params.'
b'% 12/5/10 dhb Expanded comment. Error check on input length'
b'% Extract parameter vector into meaningful variables'
b'if (length(params) == 2)'
4
3
exponent = params(2);
5
4
exponent1 = params(2);
b'elseif (length(params) == 3)'
8
7
exponent = params(3);
9
8
exponent1 = params(3);
b'elseif (length(params) == 4)'
12
11
exponent = params(3);
13
12
exponent1 = params(4);
14
13
error('Inproper format for passed parameter vector');
b'% Check for bad contrast input'
b'if (any(contrast < 0))'
15
14
error('Cannot deal with negative contrast');
b'% Handle really weird parameter values'
b'if (sigma < 0 | exponent < 0 | exponent1 < 0)'
16
15
response = -1*ones(size(contrast));
17
16
% Now pump the linear response through a non-linearity
18
17
expContrast = (contrast./sigma).^exponent;
19
18
expContrast1 = contrast.^exponent1;
20
19
sigma1 = sigma.^exponent1;
21
20
response = A*(expContrast ./ (expContrast1 + sigma1));
b'\\ No newline at end of file'
21
function [response] = ComputeNakaRushton(params,contrast)
22
% [response] = ComputeNakaRushton(params,contrast)
24
% Compute the Naka-Rushton function on passed vector of contrasts.
25
% Several different forms may be computed depending on length of
26
% passed params vector.
31
% response = contrast^n/[contrast^n + sigma^n]
37
% response = Rmax*[contrast^n]/[contrast^n + sigma^n]
44
% response = Rmax*[contrast^n]/[contrast^m + sigma^m]
46
% 8/1/05 dhb, pr Wrote from FitLightnessOrient version
47
% 8/2/07 dhb Rewrote to allow several different forms depending
48
% on length of params.
49
% 12/5/10 dhb Expanded comment. Error check on input length
50
% 9/23/13 dhb Fix BAD bug. This wasn't computing what the comments said it was.
51
% Not sure when that crept in. The contrast in the numerator was
52
% being divided by sigma before being raised to the power n. No idea why.
54
% Extract parameter vector into meaningful variables
55
if (length(params) == 2)
59
exponent1 = params(2);
60
elseif (length(params) == 3)
64
exponent1 = params(3);
65
elseif (length(params) == 4)
69
exponent1 = params(4);
71
error('Inproper format for passed parameter vector');
74
% Check for bad contrast input
75
if (any(contrast < 0))
76
error('Cannot deal with negative contrast');
79
% Handle really weird parameter values
80
if (sigma < 0 || exponent < 0 || exponent1 < 0)
81
response = -1*ones(size(contrast));
84
% Now pump the linear response through a non-linearity
85
expContrast = (contrast).^exponent;
86
expContrast1 = contrast.^exponent1;
87
sigma1 = sigma.^exponent1;
88
response = A*(expContrast ./ (expContrast1 + sigma1));