forked from racheldenison/temporal-attention
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rd_dprime.m
44 lines (37 loc) · 1.07 KB
/
rd_dprime.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function [dprime,criterion] = rd_dprime(h,fa,option,ceilopt)
if nargin < 4 || isempty(ceilopt)
ceilopt = 'noadjust';
end
if isempty(fa)
fa = nan(size(h));
end
switch ceilopt
case 'noadjust'
if any(h >= 1) | any(fa >= 1) | any(h <= 0) | any(fa <= 0)
error('h and fa must be non-ceiling proportions, i.e. >= 0 & =< 1!')
end
case 'adjust'
h(h==1) = .99;
h(h==0) = .01;
fa(fa==1) = .99;
fa(fa==0) = .01;
otherwise
error('ceilopt not recognized.')
end
if isempty(option) | ~ischar(option)
option = input('what do you want? ''yesno'' or ''2afc'': ');
end
zh = norminv(h,0,1); zfa = norminv(fa,0,1);
switch option
case 'yesno'
dprime = zh - zfa;
criterion = -0.5*(zh+zfa);
case '2afc'
% dprime = (zh - zfa)/sqrt(2); % this is correct for h = p(c) and fa = 1-p(c)
% criterion = -0.5*(zh+zfa);
dprime = zh*sqrt(2);
criterion = nan(size(dprime));
otherwise
error('option not recognised! please use ''yesno'' or ''2afc''!');
end
return