diff --git a/test.cc b/test.cc
index 336701eed481543fa9c86f764befb99b1b97e7ae..91ce76f37f0fc1a8c9e0253f23319b8c909107cb 100644
--- a/test.cc
+++ b/test.cc
@@ -4,89 +4,85 @@
 
 /*  CCOPYRIGHT  */
 
-#include <iostream>
-#include "newmatap.h"
-#include "newmatio.h"
-#include "newimage/newimageall.h"
+#include "libvis/miscplot.h"
 #include "miscmaths/miscmaths.h"
 #include "miscmaths/miscprob.h"
-#include <string>
-#include "utils/log.h"
-#include "melgmix.h"
-#include "meloptions.h"
-#include "melhlprfns.h"
-#include <time.h>
-#include "miscmaths/miscprob.h"
+#include "utils/options.h"
+#include <vector>
+ 
+using namespace MISCPLOT;
+using namespace MISCMATHS;
+using namespace Utilities;
+using namespace std;
 
+// The two strings below specify the title and example usage that is
+//  printed out as the help or usage message
 
-using namespace std;
-using namespace Utilities;
-using namespace NEWIMAGE;
-using namespace Melodic;
+string title="test (Version 1.0)\nCopyright(c) 2007, University of Oxford (Christian F. Beckmann)";
+string examples="test int";
 
+Option<bool> help(string("--help"), false,
+		  string("        display this message"),
+		  false, no_argument);
+Option<int> num(string("--num"), 1,
+		  string("number of iterations"),
+		  false, requires_argument);
 
-void usage(void)
-{
-  cout << "Usage: test infile ICfile [mixfile]" << endl;
-  exit(1);
-}
+int nonoptarg;
+
+////////////////////////////////////////////////////////////////////////////
 
-int main(int argc, char *argv[])
+// Local functions
+int do_work(int argc, char* argv[]) 
 {
-  Matrix Mats;
-
-  Matrix A,C;
-  RowVector B;
-
-  Mats = normrnd(5,10);
-  std_pca(Mats,C,A,B);
-
-  cout << " STD PCA : " << endl << A << endl << endl << B << endl << endl;
-  em_pca(Mats, A, B, 4);
-  cout << "  EM PCA : " << endl << A << endl << endl << B << endl << endl;
-
-  string RAWfname;
-  RAWfname = string(argv[1]);
-
-  volume4D<float> RawData;
-  volumeinfo VolInfo;
-  cout << " Reading orig. data " << RAWfname << " ... " << endl<< endl;
-  read_volume4D(RawData,RAWfname,VolInfo);
-  Matrix mat;
-  
-  volume<float> RawData2;
-  read_volume(RawData2,RAWfname);
-
-  print_size(RawData2);
-
-  A = normrnd(7,3);
-  C = normrnd(5,3);
-
-  cout << " here " << endl;
-  Mats = krprod(A,C);
-
-  cout << " A : " << A << endl << endl;
-  cout << " B : " << C << endl << endl;
-  
-  cout << " C : " << Mats << endl << endl;
-  
-  write_ascii_matrix(string("A"),A);
-  write_ascii_matrix(string("B"),C);
-  write_ascii_matrix(string("C"),Mats);
-
-  Matrix tmpA, tmpB;
-  tmpA = zeros(A.Nrows(),A.Ncols());
-  tmpB = zeros(C.Nrows(),C.Ncols());
-
-  krfact(Mats, tmpA, tmpB);
-
-  cout << " A2 : " << tmpA << endl << endl; 
-  cout << " B2 : " << tmpB << endl << endl; 
-  write_ascii_matrix(string("A2"),tmpA);
-  write_ascii_matrix(string("B2"),tmpB);
-
-  tmpA = krapprox(Mats,tmpA.Nrows());
-  write_ascii_matrix(string("C2"),tmpA);
-  
-  return 0;
+ 
+	Matrix mat;
+	mat = normrnd(300,(int)num.value())+2;
+	
+	cout << "BLAH " << num.value() << endl;
+  	for (int i=1; i <= (int)num.value();i++){
+		cout << "Processing " << i << endl;
+	  	miscplot newplot;
+		ColumnVector col;
+       	col = mat.Column(i);
+      	newplot.add_bpdata(col);
+     	newplot.boxplot(string("test")+num2str(i)+string(".png"),string("TEST"));
+	}	
+  	return 0;
 }
+
+////////////////////////////////////////////////////////////////////////////
+
+	int main(int argc,char *argv[])
+	{
+
+	  Tracer tr("main");
+	  OptionParser options(title, examples);
+
+	  try {
+	    // must include all wanted options here (the order determines how
+	    //  the help message is printed)
+	    options.add(help);
+	    options.add(num);
+	    options.parse_command_line(argc, argv);
+
+	    // line below stops the program if the help was requested or 
+	    //  a compulsory option was not set
+	    if ( (help.value()) || (!options.check_compulsory_arguments(true)) )
+	      {
+			options.usage();
+			exit(EXIT_FAILURE);
+	      }
+
+	  }  catch(X_OptionError& e) {
+	    options.usage();
+	    cerr << endl << e.what() << endl;
+	    exit(EXIT_FAILURE);
+	  } catch(std::exception &e) {
+	    cerr << e.what() << endl;
+	  } 
+
+	  // Call the local functions
+	  return do_work(argc,argv);
+	}
+