Skip to content
Snippets Groups Projects
Commit f89ad312 authored by Mark Jenkinson's avatar Mark Jenkinson
Browse files

Works now

parent 9ed71a84
No related branches found
No related tags found
No related merge requests found
......@@ -19,63 +19,6 @@ void print_usage(const string& progname) {
cerr << " e.g. " << progname << " invol y x -z outvol" << endl;
}
int dimarg(const string& val)
{
if (val=="x") {
return 1;
} else if (val=="x-" || val=="-x") {
return -1;
} else if (val=="y") {
return 2;
} else if (val=="y-" || val=="-y") {
return -2;
} else if (val=="z") {
return 3;
} else if (val=="z-" || val=="-z") {
return -3;
} else {
return 0;
}
}
template <class T>
void setrow(Matrix& affmat, int rownum, int dimnum, const volume4D<T>& invol)
{
if (dimnum==1 || dimnum==-1) {
affmat(rownum,1)=1*sign(dimnum); affmat(rownum,2)=0; affmat(rownum,3)=0;
}
if (dimnum==2 || dimnum==-2) {
affmat(rownum,1)=0; affmat(rownum,2)=1*sign(dimnum); affmat(rownum,3)=0;
}
if (dimnum==3 || dimnum==-3) {
affmat(rownum,1)=0; affmat(rownum,2)=0; affmat(rownum,3)=1*sign(dimnum);
}
if (dimnum>0) return;
float fov=0.0;
if (dimnum==-1) {
fov = invol.xsize() * invol.xdim();
}
if (dimnum==-2) {
fov = invol.ysize() * invol.ydim();
}
if (dimnum==-3) {
fov = invol.zsize() * invol.zdim();
}
affmat(rownum,4)=fov;
}
template <class T>
Matrix getmat(const volume4D<T>& invol, int dim1, int dim2, int dim3)
{
Matrix affmat(4,4);
affmat = 0.0;
affmat(4,4)=1.0;
setrow(affmat,1,dim1,invol);
setrow(affmat,2,dim2,invol);
setrow(affmat,3,dim3,invol);
return affmat;
}
template <class T>
int fmrib_main(int argc,char *argv[])
......@@ -96,7 +39,7 @@ int fmrib_main(int argc,char *argv[])
read_volume4D(invol,inname,volinfo);
Matrix affmat;
affmat = getmat(invol,dimarg(newx),dimarg(newy),dimarg(newz));
affmat = invol.swapmat(newx,newy,newz);
if (showmat) {
cout << affmat << endl;
......@@ -106,7 +49,7 @@ int fmrib_main(int argc,char *argv[])
cerr << "WARNING:: Flipping Left/Right (as det < 0)" << endl;
}
invol.swapdimensions(dimarg(newx),dimarg(newy),dimarg(newz));
invol.swapdimensions(newx,newy,newz);
return save_volume4D(invol,outname,volinfo);
}
......
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