Skip to content

Commit

Permalink
mri_volsynth.cpp. #NF. Now can specify output precision (did nothing …
Browse files Browse the repository at this point in the history
…before).
  • Loading branch information
Douglas Greve committed Jan 18, 2022
1 parent 721ad45 commit 9b61275
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion mri_volsynth/mri_volsynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ float p0[4];
int usep0 = 0;
float cdircos[3], rdircos[3], sdircos[3];
const char *pdfname = "gaussian";
char *precision=NULL; /* not used yet */
char *precision=NULL;
int mritype; // precision
MRI *mri, *mrism, *mritemp, *mri2;
long seed = -1; /* < 0 for auto */
char *seedfile = NULL;
Expand Down Expand Up @@ -538,6 +539,17 @@ int main(int argc, char **argv)
printf("Computing absolute value\n");
MRIabs(mri,mri);
}
if(precision != NULL){
printf("Changing precision to %s (no rescale)\n",precision);
MRI *mri2 = MRISeqchangeType(mri, mritype, 0.0, 0.999, 1);
if(mri2 == NULL){
printf("ERROR: MRISeqchangeType\n");
exit(1);
}
MRIfree(&mri);
mri = mri2;
}

if(colortablefile){
printf("Embedding ctab from %s\n",colortablefile);
mri->ct = CTABreadASCII(colortablefile);
Expand Down Expand Up @@ -999,6 +1011,17 @@ static void check_options(void) {
}
if(!DoCurv) getfmtid(volid);

if(precision != NULL){

if(strcmp(StrLower(precision), "uchar") == 0) mritype = MRI_UCHAR;
else if(strcmp(StrLower(precision), "short") == 0) mritype = MRI_SHORT;
else if(strcmp(StrLower(precision), "int") == 0) mritype = MRI_INT;
else if(strcmp(StrLower(precision), "float") == 0) mritype = MRI_FLOAT;
else {
printf("ERROR: precision %s not supported\n",precision);
exit(1);
}
}
return;
}
/* --------------------------------------------- */
Expand Down

0 comments on commit 9b61275

Please sign in to comment.