From 148f2211d51fd5f25082a44a3fdc6c5503b456ac Mon Sep 17 00:00:00 2001 From: Matthew Webster <mwebster@fmrib.ox.ac.uk> Date: Mon, 3 Sep 2018 13:46:04 +0000 Subject: [PATCH] wrong value for default\! --- fslmerge.cc | 54 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/fslmerge.cc b/fslmerge.cc index 2099f54..b7214a3 100755 --- a/fslmerge.cc +++ b/fslmerge.cc @@ -1,13 +1,13 @@ // fslmerge.cc concatenate AVW files into a single output // Steve Smith, David Flitney, Stuart Clare and Matthew Webster, FMRIB Image Analysis Group -// Copyright (C) 2000-2010 University of Oxford -// CCOPYRIGHT +// Copyright (C) 2000-2010 University of Oxford +// CCOPYRIGHT #define EXPOSE_TREACHEROUS #include "newimage/newimageall.h" #include "newimage/fmribmain.h" using namespace NEWIMAGE; -void print_usage(const string& progname) +void print_usage(const string& progname) { cout << endl; cout << "Usage: fslmerge <-x/y/z/t/a/tr> <output> <file1 file2 .......> [tr value in seconds]" << endl; @@ -27,18 +27,18 @@ int fmrib_main(int argc, char *argv[]) NiftiIO reader; NiftiHeader header(reader.loadHeader(return_validimagefilename(string(argv[3])))); - float newTR(header.pixdim[3]); - + float newTR(header.pixdim[4]); + if (!strcmp(argv[1], "-t")) direction=0; else if (!strcmp(argv[1], "-x")) direction=1; else if (!strcmp(argv[1], "-y")) direction=2; - else if (!strcmp(argv[1], "-z")) direction=3; + else if (!strcmp(argv[1], "-z")) direction=3; else if (!strcmp(argv[1], "-a")) direction=4; else if (!strcmp(argv[1], "-tr")) { direction=0; newTR=atof(argv[--argc]); } - else + else { print_usage(string(argv[0])); return(1); @@ -53,27 +53,27 @@ int fmrib_main(int argc, char *argv[]) } for(int vol = 4; vol < argc; vol++) - { + { header=reader.loadHeader(return_validimagefilename(string(argv[vol]))); if (direction==0) tdimtot+=header.dim[4]; - if (direction==1) xdimtot+=header.dim[1]; + if (direction==1) xdimtot+=header.dim[1]; if (direction==2) ydimtot+=header.dim[2]; if (direction==3) zdimtot+=header.dim[3]; } volume4D<T> output_volume(xdimtot,ydimtot,zdimtot,tdimtot); - read_volume4D(input_volume,string(argv[3])); + read_volume4D(input_volume,string(argv[3])); output_volume.copyproperties(input_volume); for(int vol = 3; vol < argc; vol++) - { + { if (vol>3) { - read_volume4D(input_volume,string(argv[vol])); + read_volume4D(input_volume,string(argv[vol])); // sanity check on valid orientation info (it should be consistent) if ((output_volume.sform_code()!=NIFTI_XFORM_UNKNOWN) || (output_volume.qform_code()!=NIFTI_XFORM_UNKNOWN)) { if ((input_volume.sform_code()!=NIFTI_XFORM_UNKNOWN) || (input_volume.qform_code()!=NIFTI_XFORM_UNKNOWN)) { float rms = rms_deviation(output_volume.newimagevox2mm_mat(),input_volume.newimagevox2mm_mat()); if ( rms > 0.5 && direction == 0 ) { // arbitrary 0.5mm rms diff threshold - maybe too sensitive? - cerr << endl << "WARNING:: Inconsistent orientations for individual images when attempting to merge." <<endl; + cerr << endl << "WARNING:: Inconsistent orientations for individual images when attempting to merge." <<endl; cerr <<" Merge will use voxel-based orientation which is probably incorrect - *PLEASE CHECK*!" <<endl<<endl; } } @@ -81,24 +81,24 @@ int fmrib_main(int argc, char *argv[]) } if (direction == 0 && (input_volume.xsize() != xdimtot || input_volume.ysize() != ydimtot || input_volume.zsize() != zdimtot)) dimerror=1; if (direction == 1 && (input_volume.ysize() != ydimtot || input_volume.zsize() != zdimtot || input_volume.tsize() != tdimtot)) dimerror=1; - if (direction == 2 && (input_volume.xsize() != xdimtot || input_volume.zsize() != zdimtot || input_volume.tsize() != tdimtot)) dimerror=1; + if (direction == 2 && (input_volume.xsize() != xdimtot || input_volume.zsize() != zdimtot || input_volume.tsize() != tdimtot)) dimerror=1; if (direction == 3 && (input_volume.xsize() != xdimtot || input_volume.ysize() != ydimtot || input_volume.tsize() != tdimtot)) dimerror=1; if (dimerror) { - cerr << "Error in size-match along non-concatenated dimension for input file: " << string(argv[vol]) << endl; + cerr << "Error in size-match along non-concatenated dimension for input file: " << string(argv[vol]) << endl; return 1; } - - for(int t=0;t<input_volume.tsize();t++) + + for(int t=0;t<input_volume.tsize();t++) for(int k=0;k<input_volume.zsize();k++) - for(int j=0;j<input_volume.ysize();j++) + for(int j=0;j<input_volume.ysize();j++) for(int i=0;i<input_volume.xsize();i++) output_volume.value(i+xoffset,j+yoffset,k+zoffset,t+toffset)=input_volume.value(i,j,k,t); - if (direction==0) toffset+=input_volume.tsize(); - if (direction==1) xoffset+=input_volume.xsize(); - if (direction==2) yoffset+=input_volume.ysize(); - if (direction==3) zoffset+=input_volume.zsize(); + if (direction==0) toffset+=input_volume.tsize(); + if (direction==1) xoffset+=input_volume.xsize(); + if (direction==2) yoffset+=input_volume.ysize(); + if (direction==3) zoffset+=input_volume.zsize(); } output_volume.setTR(newTR); save_volume4D(output_volume,string(argv[2])); @@ -108,12 +108,10 @@ int fmrib_main(int argc, char *argv[]) int main(int argc,char *argv[]) { - if (argc < 4) - { + if (argc < 4) + { print_usage(string(argv[0])); - return 1; + return 1; } - return call_fmrib_main(dtype(string(argv[3])),argc,argv); + return call_fmrib_main(dtype(string(argv[3])),argc,argv); } - - -- GitLab