Skip to content
Snippets Groups Projects
Commit 3992c613 authored by Matthew Webster's avatar Matthew Webster
Browse files

Current Version Jan 15

parent cf103270
No related branches found
No related tags found
No related merge requests found
// fslcc.cc cross-correlate two time series
// fslcc.cc cross-correlate two time series timepoint by timepoint
// Steve Smith and Matthew Webster, FMRIB Image Analysis Group
// Copyright (C) 2001-2010 University of Oxford
// Copyright (C) 2001-2015 University of Oxford
// CCOPYRIGHT
#include "newimage/newimageall.h"
......@@ -36,43 +36,43 @@ int fmrib_main(int argc, char *argv[])
read_volume4D(input_volume1,input_name1);
read_volume4D(input_volume2,input_name2);
if (input_volume1.maxx() != input_volume2.maxx() || input_volume1.maxy() != input_volume2.maxy() || input_volume1.maxz() != input_volume2.maxz())
if (!samesize(input_volume1,input_volume2,3))
{
cerr << "Error: Mismatch in image dimensions" << endl;
return 1;
}
if ( !nodemean.value() ) {
input_volume1-=input_volume1.mean();
input_volume2-=input_volume2.mean();
}
volume<T> mask;
if(fnmask.value().length()>0){
read_volume(mask,fnmask.value());
if(!samesize(input_volume1,mask,3)){
cerr << "Error: Mismatch in mask dimensions" << endl;
return 1;
}
} else {
mask=input_volume1[0];
mask=1;
}
volume<T> theMask;
if( fnmask.value().length() > 0 ) {
read_volume(theMask,fnmask.value());
if(!samesize(input_volume1[0],theMask)){
cerr << "Error: Mismatch in mask dimensions" << endl;
return 1;
}
if ( !nodemean.value() ) {
for(int t1=0;t1<=input_volume1.maxt();t1++)
input_volume1[t1] *= theMask;
input_volume1[t1] -= input_volume1[t1].mean(mask);
for(int t2=0;t2<=input_volume2.maxt();t2++)
input_volume2[t2] *= theMask;
}
input_volume2[t2] -= input_volume2[t2].mean(mask);
}
for(int t1=0;t1<input_volume1.tsize();t1++)
for(int t1=0;t1<=input_volume1.maxt();t1++)
{
double ss1=sqrt(input_volume1.constantSubVolume(t1).sumsquares());
for(int t2=0;t2<input_volume2.tsize();t2++)
double ss1=sqrt(input_volume1[t1].sumsquares(mask));
for(int t2=0;t2<=input_volume2.maxt();t2++)
{
double ss2=sqrt(input_volume2.constantSubVolume(t2).sumsquares());
double ss2=sqrt(input_volume2[t2].sumsquares(mask));
double score=0;
for(int k=0;k<input_volume1.zsize();k++)
for(int j=0;j<input_volume1.ysize();j++)
for(int i=0;i<=input_volume1.xsize();i++)
score+=(double)input_volume1(i,j,k,t1)*(double)input_volume2(i,j,k,t2);
for(int k=0;k<=input_volume1.maxz();k++)
for(int j=0;j<=input_volume1.maxy();j++)
for(int i=0;i<=input_volume1.maxx();i++)
if ( !fnmask.set() || mask(i,j,k)>0 )
score+=(double)input_volume1(i,j,k,t1)*(double)input_volume2(i,j,k,t2);
if (!noabs.value())
score=fabs(score);
score/=(ss1*ss2);
......@@ -87,7 +87,7 @@ int fmrib_main(int argc, char *argv[])
int main(int argc,char *argv[])
{
string title("fslcc");
string title("fslcc: Cross-correlate two time-series, timepoint by timepoint");
string examples("fslcc [options] <first_input> <second_input> ");
OptionParser options(title, examples);
......@@ -99,7 +99,7 @@ int main(int argc,char *argv[])
unsigned int done;
try {
done=options.parse_command_line(argc, argv);
done=options.parse_command_line(argc, argv,0,true);
}
catch(X_OptionError& e) {
options.usage();
......
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