From 2ebc306085d50ece84eb26c2e56565e14cf434ae Mon Sep 17 00:00:00 2001
From: Christian Beckmann <c.beckmann@donders.ru.nl>
Date: Sat, 22 Sep 2012 20:30:26 +0000
Subject: [PATCH] fixed GLM OLS bug

---
 meldata.cc | 23 ++++++++++++++---------
 melica.cc  |  2 +-
 test.cc    | 26 +++++++++++++++-----------
 3 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/meldata.cc b/meldata.cc
index a840e60..c4f2471 100644
--- a/meldata.cc
+++ b/meldata.cc
@@ -138,18 +138,24 @@ namespace Melodic{
 
   void MelodicData::set_TSmode()
   {
+   	dbgmsg(string("START: set_TSmode"));	
+	
 	Matrix tmp, tmpT, tmpS, tmpT2, tmpS2, tmpT3;
 	
     tmp = expand_dimred(mixMatrix);
     tmpT = zeros(tmp.Nrows()/numfiles, tmp.Ncols());
     tmpS = zeros(numfiles, tmp.Ncols());
 
-	if(opts.approach.value()==string("tica")){
+	outMsize("tmp",tmp);
+	outMsize("tmpT",tmpT);
+	outMsize("tmpS",tmpS);
+
+  	dbgmsg(string("   approach ") << opts.approach.value() << endl);	
+
+	if(!opts.approach.value()==string("concat")){
+		message("Calculating T- and S-modes " << endl);
     	explained_var = krfact(tmp,tmpT,tmpS);
-		outMsize("tmp",tmp);
-		outMsize("tmpT",tmpT);
-		outMsize("tmpS",tmpS);
-		if(opts.approach.value()==string("tica")){		
+    	if(opts.approach.value()==string("tica")){		
     		Tmodes.clear(); Smodes.clear();
     		for(int ctr = 1; ctr <= tmp.Ncols(); ctr++){
 				tmpT3 << reshape(tmp.Column(ctr),tmpT.Nrows(),numfiles);
@@ -165,7 +171,6 @@ namespace Melodic{
 				}
       			add_Tmodes(tmpT2);
       			add_Smodes(tmpS2);
-    		}
 		}
 	
 	//add GLM OLS fit
@@ -185,9 +190,9 @@ namespace Melodic{
 	}
 	
     }
-//	else{
-//		add_Tmodes(tmp);
-//	}
+	else{
+		add_Tmodes(tmp);
+	}
 	
 	dbgmsg(string("END: set_TSmode"));
     
diff --git a/melica.cc b/melica.cc
index e09becd..72cb01f 100644
--- a/melica.cc
+++ b/melica.cc
@@ -476,7 +476,7 @@ namespace Melodic {
       melodat.set_ICstats(scales);
       melodat.sort();
 
-	  message("Calculating T- and S-modes " << endl);
+	  //message("Calculating T- and S-modes " << endl);
       melodat.set_TSmode();
 		
     }
diff --git a/test.cc b/test.cc
index 8994048..3a13d0e 100644
--- a/test.cc
+++ b/test.cc
@@ -34,6 +34,12 @@ using namespace std;
 	Option<int> help(string("-h,--help"), 0,
 		string("display this help text"),
 		false,no_argument);
+	Option<int> xdim(string("-x,--xdim"), 10,
+		string("xdim"),
+		false,requires_argument);
+	Option<int> ydim(string("-y,--ydim"), 10,
+		string("ydim"),
+		false,requires_argument);
 		/*
 }
 */
@@ -42,7 +48,12 @@ using namespace std;
 // Local functions
 
 int do_work(int argc, char* argv[]) {
-
+    
+	Matrix test;
+	
+	cerr << " X: "<< xdim.value() << ", Y: "<< ydim.value() << endl;
+	test = zeros(xdim.value(),ydim.value());
+	cerr << "Created matrix of size " << test.Nrows() << " x " << test.Ncols() << endl;
 	return 0;
 }
 
@@ -55,17 +66,10 @@ int do_work(int argc, char* argv[]) {
 	    // must include all wanted options here (the order determines how
 	    //  the help message is printed)
 	
-		  double tmptime = time(NULL);
-		  srand((unsigned int) tmptime);
-
-		cerr << (unsigned int) tmptime << endl << endl;
-
-		cerr << unifrnd(2,2) << endl;
-		exit(1);
-	/*
 			options.add(fnin);		
 			options.add(help);
-		
+			options.add(xdim);
+			options.add(ydim);
 	    options.parse_command_line(argc, argv);
 
 	    // line below stops the program if the help was requested or 
@@ -76,7 +80,7 @@ int do_work(int argc, char* argv[]) {
 	    }else{
 	  		// Call the local functions
 	  		return do_work(argc,argv);
-			}*/
+			}
 		}catch(X_OptionError& e) {
 			options.usage();
 	  	cerr << endl << e.what() << endl;
-- 
GitLab