diff --git a/build.xml b/build.xml index ca0b6de..158bf57 100755 --- a/build.xml +++ b/build.xml @@ -5,7 +5,7 @@ - + diff --git a/demos/AutoAnalyser/README-AutoAnalyserDemo.pdf b/demos/AutoAnalyser/README-AutoAnalyserDemo.pdf index 3442cb5..7032b39 100644 Binary files a/demos/AutoAnalyser/README-AutoAnalyserDemo.pdf and b/demos/AutoAnalyser/README-AutoAnalyserDemo.pdf differ diff --git a/demos/java/README-SimpleJavaDemos.pdf b/demos/java/README-SimpleJavaDemos.pdf index 344af19..2177807 100755 Binary files a/demos/java/README-SimpleJavaDemos.pdf and b/demos/java/README-SimpleJavaDemos.pdf differ diff --git a/demos/octave/SchreiberTransferEntropyExamples/README-SchreiberTeDemos.pdf b/demos/octave/SchreiberTransferEntropyExamples/README-SchreiberTeDemos.pdf index ca98df4..1467f22 100755 Binary files a/demos/octave/SchreiberTransferEntropyExamples/README-SchreiberTeDemos.pdf and b/demos/octave/SchreiberTransferEntropyExamples/README-SchreiberTeDemos.pdf differ diff --git a/demos/octave/SchreiberTransferEntropyExamples/runHeartBreathRateKraskov.m b/demos/octave/SchreiberTransferEntropyExamples/runHeartBreathRateKraskov.m index dbc4d76..3bf4dbd 100755 --- a/demos/octave/SchreiberTransferEntropyExamples/runHeartBreathRateKraskov.m +++ b/demos/octave/SchreiberTransferEntropyExamples/runHeartBreathRateKraskov.m @@ -28,10 +28,10 @@ % % % Inputs -% - kHistory - destination embedding length -% - lHistory - source embedding length +% - kHistory - destination embedding length, or "auto" for an auto-embedding (Ragwitz criteria, which takes a minute or two to run) +% - lHistory - source embedding length, or "auto" for an auto-embedding (Ragwitz criteria, which takes a minute or two to run) % - knns - a scalar specifying a single, or vector specifying multiple, value of K nearest neighbours to evaluate TE (Kraskov) with. -% - numSurrogates - a scalar specifying the number of surrogates to evaluate TE from null distribution +% - numSurrogates - a scalar specifying the number of surrogates to evaluate TE from null distribution (which further multiplies the runtime) % Outputs % - teHeartToBreath - TE (heart -> breath) for each value of k nearest neighbours % - teBreathToHeart - TE (breath -> heart) for each value of k nearest neighbours @@ -67,17 +67,44 @@ function [teHeartToBreath, teBreathToHeart] = runHeartBreathRateKraskov(kHistory % Using a KSG estimator for TE is the least biased way to run this: teCalc=javaObject('infodynamics.measures.continuous.kraskov.TransferEntropyCalculatorKraskov'); + % Set up for any potential auto-embedding: + if (ischar(kHistory)) % Assume == 'auto' + % we're auto-embedding at least the destination: + if (ischar(lHistory)) % Assume == 'auto' + % we're auto embedding both source and destination + teCalc.setProperty(teCalc.PROP_AUTO_EMBED_METHOD, ... + teCalc.AUTO_EMBED_METHOD_RAGWITZ); + else + % we're auto embedding destination only + teCalc.setProperty(teCalc.PROP_AUTO_EMBED_METHOD, ... + teCalc.AUTO_EMBED_METHOD_RAGWITZ_DEST_ONLY); + end + teCalc.setProperty(teCalc.PROP_K_SEARCH_MAX, '10'); + teCalc.setProperty(teCalc.PROP_TAU_SEARCH_MAX, '5'); + end for knnIndex = 1:length(knns) knn = knns(knnIndex); % Compute a TE value for knn nearest neighbours % Perform calculation for heart -> breath (lag 1) - teCalc.initialise(kHistory,1,lHistory,1,1); + if (ischar(kHistory)) % Assume == 'auto' + % we're auto-embedding at least the destination: + teCalc.initialise(); + else + % We're not auto embedding + teCalc.initialise(kHistory,1,lHistory,1,1); + end teCalc.setProperty('k', sprintf('%d',knn)); teCalc.setObservations(octaveToJavaDoubleArray(heart), ... octaveToJavaDoubleArray(chestVol)); teHeartToBreath(knnIndex) = teCalc.computeAverageLocalOfObservations(); + % Grab the embedding parameters (in case of auto-embedding), converting from Java to native strings + kUsedHB = char(teCalc.getProperty(teCalc.K_PROP_NAME)); + kTauUsedHB = char(teCalc.getProperty(teCalc.K_TAU_PROP_NAME)); + lUsedHB = char(teCalc.getProperty(teCalc.L_PROP_NAME)); + lTauUsedHB = char(teCalc.getProperty(teCalc.L_TAU_PROP_NAME)); + % And compare to surrogates if required if (numSurrogates > 0) teHeartToBreathNullDist = teCalc.computeSignificance(numSurrogates); teHeartToBreathNullMean = teHeartToBreathNullDist.getMeanOfDistribution(); @@ -85,22 +112,34 @@ function [teHeartToBreath, teBreathToHeart] = runHeartBreathRateKraskov(kHistory end % Perform calculation for breath -> heart (lag 1) - teCalc.initialise(kHistory,1,lHistory,1,1); + if (ischar(kHistory)) % Assume == 'auto' + % we're auto-embedding at least the destination: + teCalc.initialise(); + else + % We're not auto embedding + teCalc.initialise(kHistory,1,lHistory,1,1); + end teCalc.setProperty('k', sprintf('%d',knn)); teCalc.setObservations(octaveToJavaDoubleArray(chestVol), ... octaveToJavaDoubleArray(heart)); teBreathToHeart(knnIndex) = teCalc.computeAverageLocalOfObservations(); + % Grab the embedding parameters (in case of auto-embedding) + kUsedBH = char(teCalc.getProperty(teCalc.K_PROP_NAME)); + kTauUsedBH = char(teCalc.getProperty(teCalc.K_TAU_PROP_NAME)); + lUsedBH = char(teCalc.getProperty(teCalc.L_PROP_NAME)); + lTauUsedBH = char(teCalc.getProperty(teCalc.L_TAU_PROP_NAME)); + % And compare to surrogates if required if (numSurrogates > 0) teBreathToHeartNullDist = teCalc.computeSignificance(numSurrogates); teBreathToHeartNullMean = teBreathToHeartNullDist.getMeanOfDistribution(); teBreathToHeartNullStd = teBreathToHeartNullDist.getStdOfDistribution(); end - fprintf('TE(k=%d,l=%d,knn=%d): h->b = %.3f', kHistory, lHistory, knn, teHeartToBreath(knnIndex)); + fprintf('TE(k=%s,kTau=%s,l=%s,lTau=%s,knn=%d): h->b = %.3f', kUsedHB, kTauUsedHB, lUsedHB, lTauUsedHB, knn, teHeartToBreath(knnIndex)); if (numSurrogates > 0) fprintf(' (null = %.3f +/- %.3f)', teHeartToBreathNullMean, teHeartToBreathNullStd); end - fprintf(', b->h = %.3f nats', teBreathToHeart(knnIndex)); + fprintf('; TE(k=%s,kTau=%s,l=%s,lTau=%s,knn=%d): b->h = %.3f nats', kUsedBH, kTauUsedBH, lUsedBH, lTauUsedBH, knn, teBreathToHeart(knnIndex)); if (numSurrogates > 0) fprintf('(null = %.3f +/- %.3f)\n', teBreathToHeartNullMean, teBreathToHeartNullStd); else diff --git a/demos/python/README-PythonDemos.pdf b/demos/python/README-PythonDemos.pdf index 9c0770b..d93b86a 100755 Binary files a/demos/python/README-PythonDemos.pdf and b/demos/python/README-PythonDemos.pdf differ diff --git a/demos/r/README-R_Demos.pdf b/demos/r/README-R_Demos.pdf index edb3221..39dbec0 100755 Binary files a/demos/r/README-R_Demos.pdf and b/demos/r/README-R_Demos.pdf differ diff --git a/readme-template.txt b/readme-template.txt index c612afe..c387a79 100755 --- a/readme-template.txt +++ b/readme-template.txt @@ -132,6 +132,15 @@ Notices for this software are found in the notices/JAMA directory. Release notes =============== +v1.3 10/7/2015 at r677 +---------------------- +Added AutoAnalyser (Code Generator) GUI demo; +Added auto-embedding capability via Ragwitz criteria for AIS and TE calculators (KSG estimators); +Added Java demo 9 for showcasing use of Ragwitz auto-embedding; +Adding small amount of noise to data in all KSG estimators now by default (may be disabled via setProperty()); +Added getProperty() methods for all conditional MI and TE calculators; +Upgraded Python demos for Python 3 compatibility; + v1.2.1 12/2/2015 at r621 ------------------------ Added tutorial slides, description of exercises and sample exercise solutions;