From 5e518620c751989624c0d6e26b4faf7366d0964e Mon Sep 17 00:00:00 2001 From: Jan Mandel Date: Sat, 2 Apr 2016 22:52:34 -0600 Subject: [PATCH] fixing, new like3 --- other/Matlab/detection/cmapmod14.m | 6 +++--- other/Matlab/detection/like3.m | 34 ++++++++++++++++++++++++++++++++ other/Matlab/detection/like_test.m | 6 ++++-- other/Matlab/detection/showmod14files.m | 4 ++-- other/Matlab/detection/sort_rsac_files.m | 2 +- 5 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 other/Matlab/detection/like3.m diff --git a/other/Matlab/detection/cmapmod14.m b/other/Matlab/detection/cmapmod14.m index 603dae9a..274eb248 100644 --- a/other/Matlab/detection/cmapmod14.m +++ b/other/Matlab/detection/cmapmod14.m @@ -30,9 +30,9 @@ atten=5; for i=0:imax w=exp(-atten*i/imax)-exp(-atten); col=(1-w)*yellow+w*red; - cmap(8+3*i ,:)=col; - cmap(8+3*i+1,:)=0.8*col; - cmap(8+3*i+2,:)=0.6*col; + cmap(8+3*i ,:)=0.4*col; + cmap(8+3*i+1,:)=0.7*col; + cmap(8+3*i+2,:)=1*col; end if size(cmap,1)>256, error('imax too large') diff --git a/other/Matlab/detection/like3.m b/other/Matlab/detection/like3.m new file mode 100644 index 00000000..28dde2b3 --- /dev/null +++ b/other/Matlab/detection/like3.m @@ -0,0 +1,34 @@ +function [v0,v1]=like3(dw,t,stretch) + +% stretch: +Tmin=stretch(1);Tmax=stretch(2);Tneg=stretch(3);Tpos=stretch(4); + +max_like=log(0.9); + +% get p0 = data likelhood of 1 as a function of t, p1=derivative + +slope_neg=0.5; +slope_pos=0.1; + +p0=max_like*(t>=Tmin & t<=Tmax) + ... + (max_like+(t-Tmin)*slope_neg).*(tTmax); + +p1= (tTmax)*slope_pos; + +% everything else is derived from that + +% p0 + p1 = 1 +% p0 = 1 - p1 +% logp0 = log(1 - p1) = log(1 -exp(logp0)) + +n0=log(1-exp(p0)); +n1=-p1.*exp(p0)./(1-exp(p0)).^2; + +v0 = dw.*p0.*(dw>0) - dw.*n0.*(dw<0); +v1 = dw.*p1.*(dw>0) - dw.*n1.*(dw<0); + + +end + + diff --git a/other/Matlab/detection/like_test.m b/other/Matlab/detection/like_test.m index 5ebcb863..9dfb3b7e 100644 --- a/other/Matlab/detection/like_test.m +++ b/other/Matlab/detection/like_test.m @@ -3,10 +3,12 @@ stretch=[0.5,10,5,10]; t=[-10:0.01:30]; [p0,p1]=like(1,t,stretch); [n0,n1]=like(-1,t,stretch); -figure(1),clf +% figure(1),clf +figure plot(t,p0,t,n0) grid on -figure(2),clf +figure +% figure(2),clf plot(t,p1,t,n1) grid on diff --git a/other/Matlab/detection/showmod14files.m b/other/Matlab/detection/showmod14files.m index e2d59efa..5534d1e7 100644 --- a/other/Matlab/detection/showmod14files.m +++ b/other/Matlab/detection/showmod14files.m @@ -1,9 +1,9 @@ function M=showmod14files(search) % display one or more MOD14 Matlab files % input: -% search file name, or search string, default '*.mat' +% search file name, or search string if ~exist('search','var'), - search='*.tif.mat'; + search=''; end d=sort_rsac_files(search); diff --git a/other/Matlab/detection/sort_rsac_files.m b/other/Matlab/detection/sort_rsac_files.m index 0e9f77bc..10219257 100644 --- a/other/Matlab/detection/sort_rsac_files.m +++ b/other/Matlab/detection/sort_rsac_files.m @@ -4,7 +4,7 @@ function p=sort_rsac_files(prefix) % file_search directory search string % d cell array of file names ordered by time -d=dir(prefix);d={d.name}; +d=dir([prefix,'*.tif.mat']);d={d.name}; if(isempty(d)), error(['No files found for ',file_search]),end % order the files in time -- 2.11.4.GIT