[python-dtcwt] 387/497: improve verification workflow

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:06:30 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/sid
in repository python-dtcwt.

commit 3dc3baf53cd60256f1239ab3f8be6c2e6fa6b316
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date:   Mon Feb 10 11:03:00 2014 +0000

    improve verification workflow
    
    Make use of https://github.com/timseries/dtcwt_matlab as a convenient
    repository of DTCWT METLAB code and download the toolbox we need on
    first run. Generate qbgn.npz from the .mat file and remove qbgn.mat from
    the repository.
---
 matlab/.gitignore            |   3 +++
 matlab/README.md             |  13 +++++++------
 matlab/gen_verif.m           |  15 +++++++++++----
 matlab/regen_verification.sh |  24 +++++++++++++++++++++---
 matlab/verif_m_to_npz.py     |   7 +++++--
 tests/qbgn.mat               | Bin 826597 -> 0 bytes
 tests/qbgn.npz               | Bin 652203 -> 652796 bytes
 tests/verification.npz       | Bin 4510508 -> 4293123 bytes
 8 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/matlab/.gitignore b/matlab/.gitignore
index 2d92f62..55f21d7 100644
--- a/matlab/.gitignore
+++ b/matlab/.gitignore
@@ -1 +1,4 @@
 verification.mat
+qbgn.mat
+toolboxes/
+toolboxes.zip
diff --git a/matlab/README.md b/matlab/README.md
index 9191edb..3393756 100644
--- a/matlab/README.md
+++ b/matlab/README.md
@@ -3,13 +3,14 @@
 This directory contains the MATLAB files required to recreate the verification
 data. Obviously you must have MATLAB installed but you also require the DT-CWT
 toolbox available on [Nick Kingsbury's](http://www-sigproc.eng.cam.ac.uk/~ngk/)
-home page.
+home page or from the [dtcwt-matlab](https://github.com/rjw57/dtcwt-matlab)
+repository on GitHub.
 
-The ``regen_verification.sh`` script will run MATLAB and Python to re-generate
-the verification data. It uses the scripts ``gen_verif.m`` and
-``verif_m_to_npz.py``. You should use this script but you may need to configure
-it slightly to set the location of MATLAB on your system and the DTCWT
-toolboxes.
+The ``regen_verification.sh`` script will download the necessary toolboxes from
+GitHub if they are not present and run MATLAB and Python to re-generate the
+verification data. It uses the scripts ``gen_verif.m`` and
+``verif_m_to_npz.py``. You should use this script to re-generate verification
+results.
 
 The ``gen_verif.m`` script is not sophisticated; it simply exercises a number
 of the DT-CWT toolbox routines and saves the result to ``verification.mat``.
diff --git a/matlab/gen_verif.m b/matlab/gen_verif.m
index df072c0..bfcf285 100644
--- a/matlab/gen_verif.m
+++ b/matlab/gen_verif.m
@@ -4,7 +4,16 @@
 %%
 %% Run with something like:
 %%
-%% $ MATLABPATH=/path/to/dtcwt_toolbox4_3 /path/to/matlab -nosplash -nodesktop -r "run /path/to/gen_verif; quit"
+%% $ /path/to/matlab -nosplash -nodesktop -r "run /path/to/gen_verif; quit"
+%%
+%% There should be the DTCWT toolboxes installed in a toolboxes directory next
+%% to the script. See the regen_verification.sh script for an example of setting
+%% this up.
+
+% Add the qbgn and toolbox files to the path
+strFilePath=[fileparts(which(mfilename('fullpath'))) '/'];
+addpath([strFilePath 'qbgn/']);
+addpath(genpath([strFilePath 'toolboxes/']));
 
 %% Load Lena image
 inputs = load('lena.mat');
@@ -47,8 +56,6 @@ for sb=1:6
 end
 
 %% Generate quantized bandlimited gaussian noise (gbgn) phantom
-strFilePath=[fileparts(which(mfilename('fullpath'))) '/'];
-addpath([strFilePath 'qbgn/']);
 %generate quantized band-limited gaussian noise, and case to 8-bit to save space
 qbgn = uint8(gen_qbgn(128,128));
 %take the 3D wavelet transform, which defaults to near_sym_a (5,7) and qshift_b (14 taps)
@@ -56,7 +63,7 @@ qbgn = uint8(gen_qbgn(128,128));
 %now re-arrange the coefficients to form complex-valued high-pass subbands instead of alternating real/imag parts
 qbgn_Yh = ri2c(qbgn_Yh);
 
-save('../tests/qbgn.mat','qbgn');
+save('qbgn.mat','qbgn');
 
 save('verification.mat', 'lena_coldfilt', 'lena_colifilt', 'lena_Yl', 'lena_Yh', 'lena_Yscale', ...
      'lena_Ylb', 'lena_Yhb', 'lena_Yscaleb', 'lena_upsample', 'qbgn_Yl', 'qbgn_Yh', 'qbgn_Yscale');
diff --git a/matlab/regen_verification.sh b/matlab/regen_verification.sh
index 8d76e8b..39e5d9f 100755
--- a/matlab/regen_verification.sh
+++ b/matlab/regen_verification.sh
@@ -2,23 +2,41 @@
 
 ## CONFIGURATION
 
+# URL to download toolboxen from
+TOOLBOX_URL=https://github.com/timseries/dtcwt_matlab/archive/master.zip
+
 # Path to dtcwt toolbox
 DTCWT_TOOLBOX=$HOME/Downloads/dtcwt_toolbox4_3
 
 # Path to dtcwt keypoints toolbox
 DTCWT_KEYPOINTS=$HOME/Downloads/DTCWTkeypoints
 
+# Path to dtcwt 3D toolbox
+DTCWT_3D=$HOME/Downloads/DTCWT_3D
+
 # Path to MATLAB
 MATLAB=/opt/MATLAB/R2013b/bin/matlab
 
 ## END OF CONFIGURATION
 
-# Update MATLAB path
-export MATLABPATH="$MATLABPATH:$DTCWT_TOOLBOX:$DTCWT_KEYPOINTS"
-
 # Change to this directory
 cd "`dirname "${BASH_SOURCE[0]}"`"
 
+# Download toolboxes if necessary
+if [ ! -f toolboxes.zip ]; then
+    echo "Downloading toolboxes..."
+    wget -O toolboxes.zip $TOOLBOX_URL
+fi
+
+# Unzip toolboxes if necessary
+if [ ! -d toolboxes ]; then
+    echo "Excracting toolboxes..."
+    mkdir toolboxes
+    cd toolboxes
+    unzip ../toolboxes.zip
+    cd ..
+fi
+
 if [ -f verification.mat ]; then
     rm verification.mat
 fi
diff --git a/matlab/verif_m_to_npz.py b/matlab/verif_m_to_npz.py
index a6af710..9a9c95f 100755
--- a/matlab/verif_m_to_npz.py
+++ b/matlab/verif_m_to_npz.py
@@ -2,7 +2,7 @@
 
 import numpy as np
 from scipy.io import loadmat
-from numpy import savez
+from numpy import savez_compressed
 
 def _mean(a, axis=None, *args, **kwargs):
     """Equivalent to numpy.mean except that the axis along which the mean is taken is not removed."""
@@ -75,4 +75,7 @@ summaries = dict((k, summarise_mat(v)) for k, v in verif.iteritems())
 for k,v in verif_cube.iteritems():
     summaries[k] = summarise_cube(v)
     
-savez('../tests/verification.npz', **summaries)
+savez_compressed('../tests/verification.npz', **summaries)
+
+# Convert qbgn.mat -> qbgn.npz
+savez_compressed('../tests/qbgn.npz', **loadmat('qbgn.mat'))
diff --git a/tests/qbgn.mat b/tests/qbgn.mat
deleted file mode 100644
index 10edef1..0000000
Binary files a/tests/qbgn.mat and /dev/null differ
diff --git a/tests/qbgn.npz b/tests/qbgn.npz
index 7f8b59f..471c851 100644
Binary files a/tests/qbgn.npz and b/tests/qbgn.npz differ
diff --git a/tests/verification.npz b/tests/verification.npz
index 847c35a..492a82b 100644
Binary files a/tests/verification.npz and b/tests/verification.npz differ

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-dtcwt.git



More information about the debian-science-commits mailing list