Skip to content

Commit

Permalink
mri_volsynth.cpp. #NF. Added --cube. Added ability to set grid value …
Browse files Browse the repository at this point in the history
…with ValueA
  • Loading branch information
Douglas Greve committed Sep 20, 2021
1 parent a570d89 commit 213bb09
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions mri_volsynth/mri_volsynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ MPoint *ctrpoints=NULL, *crsctrpoints=NULL;
int nctrpoints=0, CPUseRealRAS;
int cgridspace=8, rgridspace=8, sgridspace=2;
int spherecenter[3], spherecenterset = 0;
double cubeedgemm = -1;

/*---------------------------------------------------------------*/
int main(int argc, char **argv)
Expand Down Expand Up @@ -191,6 +192,11 @@ int main(int argc, char **argv)
mritemp->zsize = res[2];
mritemp->tr = res[3];
}
else {
res[0] = mritemp->xsize;
res[1] = mritemp->ysize;
res[2] = mritemp->zsize;
}

dim[0] = mritemp->width;
dim[1] = mritemp->height;
Expand Down Expand Up @@ -345,9 +351,50 @@ int main(int argc, char **argv)
mritemp->zsize = res[2];
mritemp->tr = res[3];
}
mri=MRIgrid(mritemp,cgridspace,rgridspace,sgridspace,1,NULL);
mri=MRIgrid(mritemp,cgridspace,rgridspace,sgridspace,ValueA,NULL);
if(!mri) exit(1);
}
else if (strcmp(pdfname,"cube")==0) {
int c0 = round(dim[0]/2.0);
int r0 = round(dim[1]/2.0);
int s0 = round(dim[2]/2.0);
int c1 = round((dim[0] - cubeedgemm/res[0])/2.0);
int c2 = round((dim[0] + cubeedgemm/res[0])/2.0);
int r1 = round((dim[1] - cubeedgemm/res[1])/2.0);
int r2 = round((dim[1] + cubeedgemm/res[1])/2.0);
int s1 = round((dim[2] - cubeedgemm/res[2])/2.0);
int s2 = round((dim[2] + cubeedgemm/res[2])/2.0);
printf("Cube %lf (%d %d %d) %d %d %d %d %d %d\n",cubeedgemm,c0,r0,s0,c1,c2,r1,r2,s1,s2);
printf("dim %d %d %d, res = %lf %lf %lf\n",dim[0],dim[1],dim[2],res[0],res[1],res[2]);
if(c1 <= 0 || c1 >= dim[0]) exit(1);
if(c2 <= 0 || c2 >= dim[0]) exit(1);
if(r1 <= 0 || r1 >= dim[1]) exit(1);
if(r2 <= 0 || r2 >= dim[1]) exit(1);
if(s1 <= 0 || s1 >= dim[2]) exit(1);
if(s2 <= 0 || s2 >= dim[2]) exit(1);
if(mritemp == NULL){
mritemp = MRIconst(dim[0], dim[1], dim[2], dim[3], 0, NULL);
mritemp->xsize = res[0];
mritemp->ysize = res[1];
mritemp->zsize = res[2];
mritemp->tr = res[3];
}
mri = MRIconst(dim[0], dim[1], dim[2], dim[3], 0, NULL);
if(!mri) exit(1);
mri->xsize = res[0];
mri->ysize = res[1];
mri->zsize = res[2];
mri->tr = res[3];
MRIsetVoxVal(mri,c0,r0,s0,0,ValueA);
MRIsetVoxVal(mri,c1,r1,s1,0,ValueA);
MRIsetVoxVal(mri,c1,r1,s2,0,ValueA);
MRIsetVoxVal(mri,c1,r2,s1,0,ValueA);
MRIsetVoxVal(mri,c1,r2,s2,0,ValueA);
MRIsetVoxVal(mri,c2,r1,s1,0,ValueA);
MRIsetVoxVal(mri,c2,r1,s2,0,ValueA);
MRIsetVoxVal(mri,c2,r2,s1,0,ValueA);
MRIsetVoxVal(mri,c2,r2,s2,0,ValueA);
}
else if (strcmp(pdfname,"sliceno")==0) {
printf("SliceNo \n");
if(mritemp == NULL){
Expand Down Expand Up @@ -396,7 +443,8 @@ int main(int argc, char **argv)
// Override
if(nframes > 0) mri->nframes = nframes;
if(TR > 0) mri->tr = TR;
} else {
}
else {
if(mri == NULL) {
usage_exit();
}
Expand Down Expand Up @@ -758,6 +806,12 @@ static int parse_commandline(int argc, char **argv) {
pdfname = "grid";
nargsused = 3;
}
else if (!strcmp(option, "--cube")) {
if(nargc < 1) argnerr(option,1);
sscanf(pargv[0],"%lf",&cubeedgemm);
pdfname = "cube";
nargsused = 1;
}
else if (!strcmp(option, "--delta-crsf")) {
if (nargc < 4) argnerr(option,4);
sscanf(pargv[0],"%d",&delta_crsf[0]);
Expand Down

0 comments on commit 213bb09

Please sign in to comment.