From af5f1264a062e25001a41c6238a22bfd996a4771 Mon Sep 17 00:00:00 2001 From: "joseph.lizier" Date: Mon, 9 Feb 2015 00:03:45 +0000 Subject: [PATCH] Adding sample tutorial solutions, updating image for the web, and updating build file to include tutorials --- build.xml | 1 + .../heartBreathResults-kraskovMI.png | Bin 7570 -> 8268 bytes .../runHeartBreathRateKraskovMI.m | 76 ++++++++++++ .../runHeartBreathRateKraskovMIWithLags.m | 117 ++++++++++++++++++ 4 files changed, 194 insertions(+) create mode 100644 tutorial/sampleExerciseSolutions/matlabOctave/runHeartBreathRateKraskovMI.m create mode 100644 tutorial/sampleExerciseSolutions/matlabOctave/runHeartBreathRateKraskovMIWithLags.m diff --git a/build.xml b/build.xml index 77c4b9c..6bc44ff 100755 --- a/build.xml +++ b/build.xml @@ -190,6 +190,7 @@ + diff --git a/demos/octave/SchreiberTransferEntropyExamples/sampleResults/heartBreathResults-kraskovMI.png b/demos/octave/SchreiberTransferEntropyExamples/sampleResults/heartBreathResults-kraskovMI.png index a24709a8326e4ec75da5ab27beccf4e690e6e137..3ca3d5872e61377c4c2f4b3ba8c03525bf670125 100644 GIT binary patch delta 7690 zcmZ8_XH-*Bv$lo+p$9>V3IwJ1UIPRv(u;r;DbkyOp(DaE6zLE_KoCMik=}a~6)8#y zO^^h-5jFK*tvNJ@JC z{5cN~Pewq%S%+X+O4(HbmeJMOor$sKaa!?a^!!xl$xeoe({AY2Um>e3GhE8SRSpxD z$C|3j#(@(X*%WUkJN;g03SGIz(LLfZ%;o0xt++w!;biLvkBPgl9>?XjSZXHH$-2Hd zOy0k^i0r@e`g0^q_Da8{%;C&RWo?`lO6Bj5-mJ##Z{QRp=nimYL&sTKd2$a{@{Epn z{+Vs_`%lUY$nR$TNkElWPkDR9#i(4BmBri*TJbwG6&Ebb^zZW!za^|Z9;^d(aTJ#J z*<3~+2KlT;%kNdcr*}y^={SEqE+qUUuHcECVSs(pqF@@mOUCl_TfZBVLLyJ%GAbNW zJo(b|k+;g=!Qelw2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g$wCz+bC5oj z%6dOTHhrW?ot26OOtn5M5|2csW)Eg;T*gb-@YR&xMEVvh<3iUMW*(r~&Q0Z+8y!_{;`S-)yN9|jNz zb&0MpKF<$w=?S1+s{L_#k2^2!O{$a5^NVB{gmB>r)HsmA`u;n-FMavyKY?<0bY56w zh_n^}>kNrNa&gro-|lFI%y)*UPwsGJVje|VUm$16OQY=^{F6Hu?gtU$(N1_JZ4PFL|`3ie|$Rb3WrrGMPKXpN*+*L8M#!C z3ejoeV(#T*HL)USh>K1g5y`mc5Z<3;qICqJsu*`URx{mKNLT5)o?f%jqV?L5gp(1A z?UMqYJP$nNN|=p#Dfhivc_a4G)^)!Cq^?Rneb%M$`Zw^-4tN(0Ctnx(-;v}TF&18w lnUcDOl9Gnf+0)9(^qcFX^e@ScVj}-fAl-@xNL~=L{~uXEKoS4| diff --git a/tutorial/sampleExerciseSolutions/matlabOctave/runHeartBreathRateKraskovMI.m b/tutorial/sampleExerciseSolutions/matlabOctave/runHeartBreathRateKraskovMI.m new file mode 100644 index 0000000..ca20b05 --- /dev/null +++ b/tutorial/sampleExerciseSolutions/matlabOctave/runHeartBreathRateKraskovMI.m @@ -0,0 +1,76 @@ +%% +%% Java Information Dynamics Toolkit (JIDT) +%% Copyright (C) 2012, Joseph T. Lizier +%% +%% This program is free software: you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published by +%% the Free Software Foundation, either version 3 of the License, or +%% (at your option) any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see . +%% + +% function [miHeartToBreath] = runHeartBreathRateKraskovMI() +% +% runHeartBreathRateKraskovMI +% Version 1.0 +% Joseph Lizier +% 3/2/2015 +% +% Used to explore mutual information in the heart rate / breath rate example of Schreiber -- +% but estimates MI using Kraskov-Stoegbauer-Grassberger estimation. +% +% Note that the paths (to libraries, data, etc) are set assuming this code is run in +% the folder tutorial/sampleExercises/matlabOctave, relative to the main folder of the JIDT distribution. +% +% +% Outputs +% - miHeartToBreath - MI (heart ; breath) + + +function [miHeartToBreath] = runHeartBreathRateKraskovMI() + + tic; + + % Add Octave utilities to the path + addpath('../../../demos/octave/'); + + % Assumes the jar is three levels up - change this if this is not the case + % Octave is happy to have the path added multiple times; I'm unsure if this is true for matlab + javaaddpath('../../../infodynamics.jar'); + + data = load('../../../demos/data/SFI-heartRate_breathVol_bloodOx.txt'); + + % Restrict to the samples that Schreiber mentions: + data = data(2350:3550,:); + + % Separate the data from each column: + heart = data(:,1); + chestVol = data(:,2); + bloodOx = data(:,3); + timeSteps = length(heart); + + fprintf('MI for heart rate <-> breath rate for Kraskov estimation with %d samples:\n', timeSteps); + + % Using a KSG estimator for MI is the least biased way to run this: + miCalc=javaObject('infodynamics.measures.continuous.kraskov.MutualInfoCalculatorMultiVariateKraskov2'); + + % Compute an MI value between heart and breath + + miCalc.initialise(1,1); % univariate calculation + miCalc.setProperty('k', '4'); % 4 nearest neighbours for KSG estimator + miCalc.setObservations(octaveToJavaDoubleArray(heart), ... + octaveToJavaDoubleArray(chestVol)); + miHeartToBreath = miCalc.computeAverageLocalOfObservations(); + fprintf('MI: = %.3f nats\n', miHeartToBreath); + + tElapsed = toc; + fprintf('Total runtime was %.1f sec\n', tElapsed); +end + diff --git a/tutorial/sampleExerciseSolutions/matlabOctave/runHeartBreathRateKraskovMIWithLags.m b/tutorial/sampleExerciseSolutions/matlabOctave/runHeartBreathRateKraskovMIWithLags.m new file mode 100644 index 0000000..6ee37a7 --- /dev/null +++ b/tutorial/sampleExerciseSolutions/matlabOctave/runHeartBreathRateKraskovMIWithLags.m @@ -0,0 +1,117 @@ +%% +%% Java Information Dynamics Toolkit (JIDT) +%% Copyright (C) 2012, Joseph T. Lizier +%% +%% This program is free software: you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published by +%% the Free Software Foundation, either version 3 of the License, or +%% (at your option) any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see . +%% + +% function [miHeartToBreath] = runHeartBreathRateKraskovMIWithLags(lags, numSurrogates) +% +% runHeartBreathRateKraskovMI +% Version 1.0 +% Joseph Lizier +% 3/2/2015 +% +% Used to explore mutual information in the heart rate / breath rate example of Schreiber -- +% but estimates MI using Kraskov-Stoegbauer-Grassberger estimation. +% +% This script is used to address challenge 1, incorporating lags between heart and breath data. +% +% Note that the paths (to libraries, data, etc) are set assuming this code is run in +% the folder tutorial/sampleExercises/matlabOctave, relative to the main folder of the JIDT distribution. +% +% +% Inputs +% - lags - a scalar specifying a single, or vector specifying multiple, lag from heart to breath to evaluate MI with. +% These lags may be negative, implying a (positive) lag from breath to heart. +% - surrogates - number of surrogates to compute MI for, showing the null distribution if there were no +% relationship at the given lag. +% Outputs +% - miHeartToBreath - MI (heart ; breath) for each value of lags + + +function [miHeartToBreath] = runHeartBreathRateKraskovMIWithLags(lags, numSurrogates) + + tic; + + % Add Octave utilities to the path + addpath('../../../demos/octave/'); + + % Assumes the jar is three levels up - change this if this is not the case + % Octave is happy to have the path added multiple times; I'm unsure if this is true for matlab + javaaddpath('../../../infodynamics.jar'); + + if (nargin < 1) + lags = [0]; + end + + if (nargin < 2) + numSurrogates = 0; + end + + data = load('../../../demos/data/SFI-heartRate_breathVol_bloodOx.txt'); + + % Restrict to the samples that Schreiber mentions: + data = data(2350:3550,:); + + % Separate the data from each column: + heart = data(:,1); + chestVol = data(:,2); + bloodOx = data(:,3); + timeSteps = length(heart); + + fprintf('MI for heart rate <-> breath rate for Kraskov estimation with %d samples:\n', timeSteps); + + % Using a KSG estimator for MI is the least biased way to run this: + miCalc=javaObject('infodynamics.measures.continuous.kraskov.MutualInfoCalculatorMultiVariateKraskov2'); + + for lagIndex = 1:length(lags) + lag = lags(lagIndex); + % Compute an MI value for this lag + + miCalc.initialise(1,1); % univariate calculation + miCalc.setProperty('k', '4'); + if (lag < 0) + source = chestVol; + target = heart; + else + source = heart; + target = chestVol; + end + miCalc.setProperty('TIME_DIFF', sprintf("%d", abs(lag))); + miCalc.setObservations(octaveToJavaDoubleArray(source), ... + octaveToJavaDoubleArray(target)); + miHeartToBreath(lagIndex) = miCalc.computeAverageLocalOfObservations(); + fprintf('MI(lag=%d): = %.3f nats', lag, miHeartToBreath(lagIndex)); + if (numSurrogates > 0) + % My observations suggest that most results here for lags -15:15 are statistically significant + % (threshold for multiple comparisons corrected 0.05 level would be about 0.08 nats.) + miHeartToBreathNullDist = miCalc.computeSignificance(numSurrogates); + miHeartToBreathNullMean = miHeartToBreathNullDist.getMeanOfDistribution(); + miHeartToBreathNullStd = miHeartToBreathNullDist.getStdOfDistribution(); + fprintf(" (null = %.3f +/- %.3f)", miHeartToBreathNullMean, miHeartToBreathNullStd), + end + fprintf("\n"); + end + + tElapsed = toc; + fprintf('Total runtime was %.1f sec\n', tElapsed); + + plot(lags, miHeartToBreath, 'rx', 'markersize', 10); + set (gca,'fontsize',26); + xlabel('Lag', 'FontSize', 36, 'FontWeight', 'bold'); + ylabel('MI (nats)', 'FontSize', 36, 'FontWeight', 'bold'); + print('heartBreathResults-kraskovMI.eps', '-depsc'); +end +