diff --git a/slicetimer.cc b/slicetimer.cc index 7bdd475b4e26be79da46490f8260a017ae4ce4ac..d8c11ed69d0dfeae33bafe06ff4ae2e47108c044 100644 --- a/slicetimer.cc +++ b/slicetimer.cc @@ -1,7 +1,7 @@ /* slicetimer.cc - FMRIB's Slice Timing Utility - + Peter Bannister, Stephen Smith and Matthew Webster, FMRIB Image Analysis Group - + Copyright (C) 2001-2009 University of Oxford */ /* CCOPYRIGHT */ @@ -34,14 +34,14 @@ string examples="slicetimer -i <timeseries> [-o <corrected_timeseries>] [options Option<bool> help(string("-h,--help"), false, string("display this message"), false, no_argument); -Option<bool> verbose(string("-v,--verbose"), false, - string("switch on diagnostic messages"), +Option<bool> verbose(string("-v,--verbose"), false, + string("switch on diagnostic messages"), false, no_argument); -Option<bool> odd(string("--odd"), false, - string("use interleaved acquisition"), +Option<bool> odd(string("--odd"), false, + string("use interleaved acquisition"), false, no_argument); -Option<bool> down(string("--down"), false, - string("reverse slice indexing (default is: slices were acquired bottom-up)"), +Option<bool> down(string("--down"), false, + string("reverse slice indexing (default is: slices were acquired bottom-up)"), false, no_argument); Option<string> inputname(string("-i,--in"), string(""), string("filename of input timeseries"), @@ -69,7 +69,7 @@ int do_slice_correction() { volume4D<float> timeseries; Matrix timings; - + int no_volumes, no_slices; float repeat_time, offset=0, slice_spacing; @@ -79,7 +79,7 @@ int do_slice_correction() if (!outputname.set()) outputname.set_value(inputname.value() + "_st"); } else if (outputname.set()) { - cerr << "Must specify an input volume (-i or --in) to generate corrected data." + cerr << "Must specify an input volume (-i or --in) to generate corrected data." << endl; return -1; } @@ -108,20 +108,20 @@ int do_slice_correction() // for(int i=1; i<=1201; i++) cout << i << " " << userkernel(i) << endl; float recenter = (((float) no_slices)/2 - 0.5)/ no_slices; // only valid for slice-count-based corrections - + for (int slice=1; slice<=no_slices; slice++) { if (tglobal.set()) { offset = tglobal.value(); } else if (tcustom.set()) { offset = timings(slice, 1); - } else if (ocustom.set()) { + } else if (ocustom.set()) { int local_count=1; while (local_count <= no_slices) { if (timings(local_count, 1) == slice) { offset = recenter -(local_count -1)* (slice_spacing / repeat_time); local_count = no_slices + 1; - } else + } else local_count++; } } else if (odd.value()) { // acquisition order: 1,3,5, ..., 2,4,6 ... @@ -131,7 +131,7 @@ int do_slice_correction() offset = recenter - ((slice -1) / 2) * (slice_spacing / repeat_time); } else if (down.value()) { offset = recenter - (no_slices - slice) * (slice_spacing / repeat_time); - } else { + } else { offset = recenter - (slice -1) * (slice_spacing / repeat_time); } @@ -145,11 +145,11 @@ int do_slice_correction() } timeseries.setvoxelts(interpseries,x_pos,y_pos,slice-1); } - + if (verbose.value()) cerr << "Slice " << slice << " offset " << offset << endl; } - + if (direction.value() == 1) timeseries.swapdimensions(3,2,1); // reverse Flip z and x if (direction.value() == 2) timeseries.swapdimensions(1,3,2); // reverse Flip z and y @@ -160,7 +160,7 @@ int do_slice_correction() int main (int argc,char** argv) { Tracer tr("main"); - + OptionParser options(title, examples); try { @@ -183,30 +183,29 @@ int main (int argc,char** argv) options.usage(); exit(EXIT_FAILURE); } - - if ( inputname.unset()) + + if ( inputname.unset()) { options.usage(); - cerr << endl - << "--in or -i MUST be used." + cerr << endl + << "--in or -i MUST be used." << endl; exit(EXIT_FAILURE); } - + } catch(X_OptionError& e) { options.usage(); cerr << endl << e.what() << endl; exit(EXIT_FAILURE); } catch(std::exception &e) { cerr << e.what() << endl; - } + } int retval = do_slice_correction(); - + if (retval!=0) { cerr << endl << endl << "Error detected: try -h for help" << endl; } return retval; } -