// eddy_combine.cc : In case JAC resampling is used in the eddy output, then no pairs of phase encoding directions are combined. // This is performed by this tool that combines (by taking the average of) pairs of phase encoding directions. // Input text files provide the information needed to find out which volumes to combine. // Pos_SeriesVol and Neg_SeriesVol are text files produced by DiffPreprocPipeline.sh // Stamatios Sotiropoulos, FMRIB Analysis Group, 2012 #ifndef EXPOSE_TREACHEROUS #define EXPOSE_TREACHEROUS #endif #include "newimage/newimageall.h" using namespace NEWIMAGE; void print_usage(const string& progname) { cout << endl; cout << "Usage: eddy_combine " << endl; cout << "If onlymatched_flag=1, then only the volumes that have matched Pos/Neg pairs will be included in the output" << endl; cout << endl; } //Copy a single volume from one 4D image to another void CopyVolume(const volume4D& In,volume4D& Out, const int InVolume, const int OutVolume){ for(int k=0;k& In1,const volume4D& In2, volume4D& Out, const int InVolume1, const int InVolume2,const int OutVolume){ for(int k=0;k PosData, NegData; Matrix PosVols, NegVols, Posbvals, Posbvecs, Negbvals, Negbvecs; read_volume4D(PosData,string(argv[1])); Posbvals=read_ascii_matrix(string(argv[2])); Posbvecs=read_ascii_matrix(string(argv[3])); PosVols=read_ascii_matrix(string(argv[4])); read_volume4D(NegData,string(argv[5])); Negbvals=read_ascii_matrix(string(argv[6])); Negbvecs=read_ascii_matrix(string(argv[7])); NegVols=read_ascii_matrix(string(argv[8])); string oname=string(argv[9]); int flag=atoi(argv[10]); //Initialise Output int tsize=0; int xsize(PosData.xsize()); int ysize(PosData.ysize()); int zsize(PosData.zsize()); if (flag==0) tsize=Posbvals.Ncols()+Negbvals.Ncols()-PosVols.Column(1).Sum(); //number of total input volumes minus the matched volumes else tsize=PosVols.Column(1).Sum(); //number of matched volumes volume4D Output_Data(xsize,ysize,zsize,tsize); Matrix Output_bvals(1,tsize); Matrix Output_bvecs(3,tsize); ColumnVector CombinedVols(tsize); CombinedVols=0.0; Output_Data.copyproperties(PosData); //copy header info int OutVolIndex=0; int PosVolIndex=0; int NegVolIndex=0; for (int l=1; l<=PosVols.Nrows(); l++){ //For each series pair for (int offset=0; offset