Skip to content
Snippets Groups Projects
Commit 5524f7b6 authored by Saad Jbabdi's avatar Saad Jbabdi
Browse files

added distance weighting option

parent f407f132
No related branches found
No related tags found
No related merge requests found
......@@ -270,6 +270,31 @@ void rem_cols(Matrix& myOMmat,Matrix& tractcoordmat,const bool tractcoordbool,co
}
void add_connexity(SymmetricMatrix& CtCt,const Matrix& coord){
// compute CtCt range
float r=CtCt.Minimum();
float R=CtCt.Maximum();
// compute distance matrix
SymmetricMatrix D(coord.Nrows());
for(int i=1;i<=coord.Nrows();i++)
for(int j=1;j<=i;j++){
D(i,j)=std::sqrt((coord.Row(i)-coord.Row(j)).SumSquare());
}
D=D.MaximumAbsoluteValue()-D;
// change distance range
float m=D.Minimum(),M=D.Maximum();
D=(D-m)*(R-r)/(M-m)+r;
// add distance to CtCt matrix
for(int i=1;i<=coord.Nrows();i++)
for(int j=1;j<=i;j++){
CtCt(i,j)=std::sqrt(CtCt(i,j)*CtCt(i,j)+D(i,j)*D(i,j));
}
}
int main ( int argc, char **argv ){
......@@ -405,9 +430,20 @@ int main ( int argc, char **argv ){
SymmetricMatrix CtCt;
CtCt << corrcoef(newOMmat.t());
CtCt << CtCt+1;
// adding connexity constraint
if(opts.connexity.value()){
if(!coordbool){
cerr<<"WARNING !! No coordinates provided. I cannot apply any connexity constraint."<<endl;
}
else{
add_connexity(CtCt,mycoordmat);
}
}
if(opts.power.value()!=1){
CtCt << pow(CtCt,opts.power.value());
}
if(!opts.reord1.value()){
......
......@@ -31,6 +31,7 @@ class ccopsOptions {
Option<string> excl_mask;
Option<bool> reord1;
Option<bool> reord2;
Option<bool> connexity;
Option<int> bin;
Option<float> power;
bool parse_command_line(int argc, char** argv);
......@@ -72,6 +73,9 @@ class ccopsOptions {
reord2(string("--r2"), bool(false),
string("do tractspace reordering (default no)"),
false, no_argument),
connexity(string("--con"), bool(false),
string("add connexity constraint (default no)"),
false, no_argument),
bin(string("--bin"), 0,
string("binarise at (default 0 - no binarisation)"),
false, requires_argument),
......@@ -89,6 +93,7 @@ class ccopsOptions {
options.add(excl_mask);
options.add(reord1);
options.add(reord2);
options.add(connexity);
options.add(bin);
options.add(power);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment