Skip to content

Commit

Permalink
mri_diff.cpp. #NF. Added --count-thresh to be able to specify the min…
Browse files Browse the repository at this point in the history
…imum number of voxels that are different to throw an error status
  • Loading branch information
Douglas Greve committed Apr 1, 2021
1 parent f8cb899 commit e34ae45
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions mri_diff/mri_diff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ char *InVol1File=NULL;
char *InVol2File=NULL;
char *subject, *hemi, *SUBJECTS_DIR;
double pixthresh=0, resthresh=0, geothresh=0;
int diffcountthresh = 0;
char *DiffFile=NULL;
int DiffAbs=0, AbsDiff=1,DiffPct=0;
char *AvgDiffFile=NULL;
Expand Down Expand Up @@ -498,8 +499,13 @@ int main(int argc, char *argv[]) {
if(CheckPixVals) fprintf(fp,"diffcount %d\n",ndiff);
fclose(fp);
}
ExitStatus = 106;
if (ExitOnDiff) exit(106);
if(ndiff > diffcountthresh) {
ExitStatus = 106;
if (ExitOnDiff) exit(106);
}
else {
printf("But diff count does not exceed diff count thresh %d\n",diffcountthresh);
}
}
}

Expand Down Expand Up @@ -681,11 +687,18 @@ static int parse_commandline(int argc, char **argv) {
if (nargc < 1) CMDargNErr(option,1);
InVol2File = pargv[0];
nargsused = 1;
} else if (!strcasecmp(option, "--thresh")) {
}
else if (!strcasecmp(option, "--thresh")) {
if (nargc < 1) CMDargNErr(option,1);
sscanf(pargv[0],"%lf",&pixthresh);
nargsused = 1;
} else if (!strcasecmp(option, "--res-thresh")) {
}
else if (!strcasecmp(option, "--count-thresh")) {
if (nargc < 1) CMDargNErr(option,1);
sscanf(pargv[0],"%d",&diffcountthresh);
nargsused = 1;
}
else if (!strcasecmp(option, "--res-thresh")) {
if (nargc < 1) CMDargNErr(option,1);
sscanf(pargv[0],"%lf",&resthresh);
CheckResolution=1;
Expand Down Expand Up @@ -821,6 +834,7 @@ static void print_usage(void) {
printf(" --count : print number of differing voxels\n");
printf("\n");
printf(" --thresh thresh : pix diffs must be greater than this \n");
printf(" --count-thresh nvox : there must be at least this many voxels that are diff\n");
printf(" --log DiffFile : store diff info in this file. \n");
printf(" --diff DiffVol : save difference image. \n");
printf(" --diff_label_suspicious DiffVol : differing voxels replaced\n");
Expand Down

0 comments on commit e34ae45

Please sign in to comment.