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

Change -roi code - hopefully fixed a bug

parent 47a3b1d8
No related branches found
No related tags found
No related merge requests found
...@@ -809,29 +809,35 @@ if (!separatenoise) ...@@ -809,29 +809,35 @@ if (!separatenoise)
/******************************************************/ /******************************************************/
else if (string(argv[i])=="-roi") else if (string(argv[i])=="-roi")
{ {
// add and subtract 0.5 to ensure the rounding is OK int x0=atoi(argv[i+1]);
int x0=atoi(argv[i+1])-0.5; int x1=atoi(argv[i+1])+atoi(argv[i+2]);
int x1=atoi(argv[i+1])+atoi(argv[i+2])+0.5; int y0=atoi(argv[i+3]);
int y0=atoi(argv[i+3])-0.5; int y1=atoi(argv[i+3])+atoi(argv[i+4]);
int y1=atoi(argv[i+3])+atoi(argv[i+4])+0.5; int z0=atoi(argv[i+5]);
int z0=atoi(argv[i+5])-0.5; int z1=atoi(argv[i+5])+atoi(argv[i+6]);
int z1=atoi(argv[i+5])+atoi(argv[i+6])+0.5;
int t0=atoi(argv[i+7]); int t0=atoi(argv[i+7]);
int t1=atoi(argv[i+7])+atoi(argv[i+8]); int t1=atoi(argv[i+7])+atoi(argv[i+8]);
ColumnVector v0, v1; ColumnVector v0(4), v1(4);
v0 << x0 << y0 << z0 << 1.0; v0 << x0 << y0 << z0 << 1.0;
v1 << x1 << y1 << z1 << 1.0; v1 << x1 << y1 << z1 << 1.0;
// swap back to restore min/max order as necessary
if (v0(1)>v1(1)) { v0(4)=v0(1); v0(1)=v1(1); v1(1)=v0(4); }
if (v0(2)>v1(2)) { v0(4)=v0(2); v0(2)=v1(2); v1(2)=v0(4); }
if (v0(3)>v1(3)) { v0(4)=v0(3); v0(3)=v1(3); v1(3)=v0(4); }
v0 = input_volume.niftivox2newimagevox_mat() * v0; v0 = input_volume.niftivox2newimagevox_mat() * v0;
v1 = input_volume.niftivox2newimagevox_mat() * v1; v1 = input_volume.niftivox2newimagevox_mat() * v1;
x0=MISCMATHS::round(v0(1));
y0=MISCMATHS::round(v0(2));
z0=MISCMATHS::round(v0(3));
x1=MISCMATHS::round(v1(1));
y1=MISCMATHS::round(v1(2));
z1=MISCMATHS::round(v1(3));
// swap back to restore min/max order as necessary
int tmp;
if (x0>x1) { tmp=x0; x0=x1; x1=tmp; }
if (y0>y1) { tmp=y0; y0=y1; y1=tmp; }
if (z0>z1) { tmp=z0; z0=z1; z1=tmp; }
for(int t=0;t<input_volume.tsize();t++) for(int t=0;t<input_volume.tsize();t++)
for(int z=0;z<input_volume.zsize();z++) for(int z=0;z<input_volume.zsize();z++)
for(int y=0;y<input_volume.ysize();y++) for(int y=0;y<input_volume.ysize();y++)
for(int x=0;x<input_volume.xsize();x++) for(int x=0;x<input_volume.xsize();x++)
if((x<v0(1)) || (x>=v1(1)) || (y<v0(2)) || (y>=v1(2)) || (z<v0(3)) || (z>=v1(3)) || (t<t0) || (t>=t1) ) if((x<x0) || (x>=x1) || (y<y0) || (y>=y1) || (z<z0) || (z>=z1) || (t<t0) || (t>=t1) )
input_volume.value(x,y,z,t)=0; input_volume.value(x,y,z,t)=0;
i+=8; i+=8;
} }
......
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