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

Multi-dimensional splitting

parent d3c2534e
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,7 @@ using namespace NEWIMAGE; ...@@ -11,7 +11,7 @@ using namespace NEWIMAGE;
void print_usage(const string& progname) void print_usage(const string& progname)
{ {
cout << endl; cout << endl;
cout << "Usage: avwmerge <-x/y/z/t> <output> <file1 file2 .......>" << endl; cout << "Usage: avwmerge <-x/y/z/t/a> <output> <file1 file2 .......>" << endl;
cout << " -t : concatenate images in time" << endl; cout << " -t : concatenate images in time" << endl;
cout << " -x : concatenate images in the x direction" << endl; cout << " -x : concatenate images in the x direction" << endl;
cout << " -y : concatenate images in the y direction" << endl; cout << " -y : concatenate images in the y direction" << endl;
......
...@@ -13,26 +13,41 @@ using namespace MISCMATHS; ...@@ -13,26 +13,41 @@ using namespace MISCMATHS;
void print_usage(const string& progname) void print_usage(const string& progname)
{ {
cout << endl; cout << endl;
cout << "Usage: avwsplit <inputfile.hdr>" << endl; cout << "Usage: avwsplit++ <inputfile.hdr>" << endl;
cout << " avwsplit <inputfile.hdr> [basename]" << endl; cout << " avwsplit++ <inputfile.hdr> [basename] [-t/x/y/z]" << endl;
cout << " -t : concatenate images in time (default behaviour)" << endl;
cout << " -x : concatenate images in the x direction" << endl;
cout << " -y : concatenate images in the y direction" << endl;
cout << " -z : concatenate images in the z direction" << endl;
} }
template <class T> template <class T>
int fmrib_main(int argc, char *argv[]) int fmrib_main(int argc, char *argv[])
{ {
volume4D<T> input_volume; volume4D<T> input_vol;
volumeinfo vinfo; volumeinfo vinfo;
volume<T> output_volume; volume4D<T> output_vol;
string input_name=string(argv[1]); string input_name=string(argv[1]);
string output_name="vol"; string output_name="vol";
read_volume4D(input_volume,input_name,vinfo); int xoff=1,yoff=1,zoff=1,toff=1,nsize;
int t; read_volume4D(input_vol,input_name,vinfo);
if (argc==3) output_name=string(argv[2]); if ((argc>2) && (argv[2][0]!='-')) output_name=string(argv[2]);
for(t=0;t<=input_volume.maxt();t++) if (argv[argc-1][0] == '-')
{
if (argv[argc-1][1] == 't') toff=input_vol.tsize();
if (argv[argc-1][1] == 'z') zoff=input_vol.zsize();
if (argv[argc-1][1] == 'y') yoff=input_vol.ysize();
if (argv[argc-1][1] == 'x') xoff=input_vol.xsize();
}
else toff=input_vol.tsize();
nsize=xoff*yoff*zoff*toff;
for(int j=0;j<nsize;j++)
{ {
output_volume=input_volume[t]; input_vol.setROIlimits(0+j*(xoff!=1),0+j*(yoff!=1),0+j*(zoff!=1),0+j*(toff!=1),input_vol.xsize()-1-(nsize-j-1)*(xoff!=1),input_vol.ysize()-1-(nsize-j-1)*(yoff!=1),input_vol.zsize()-1-(nsize-j-1)*(zoff!=1),input_vol.tsize()-1-(nsize-j-1)*(toff!=1));
save_volume(output_volume,(output_name+num2str(t,4)),vinfo); input_vol.activateROI();
output_vol=input_vol.ROI();
save_volume4D(output_vol,(output_name+num2str(j,4)),vinfo);
} }
return 0; return 0;
} }
...@@ -44,7 +59,7 @@ int main(int argc,char *argv[]) ...@@ -44,7 +59,7 @@ int main(int argc,char *argv[])
Tracer tr("main"); Tracer tr("main");
string progname=argv[0]; string progname=argv[0];
if (argc != 3 && argc != 2) if (argc <= 1 && argc >= 5)
{ {
print_usage(progname); print_usage(progname);
return 1; return 1;
......
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