From f71e3479f0961ab1ca786a4405296456c92f1939 Mon Sep 17 00:00:00 2001 From: Douglas Greve Date: Tue, 7 Dec 2021 10:50:11 -0500 Subject: [PATCH] mri_fill. #NF. Added new standalone option -pointset to fill in voxels around a pointset (eg, with ento) --- mri_fill/mri_fill.cpp | 31 +++++++++++++++++++++++++++++++ mri_fill/mri_fill.help.xml | 2 ++ 2 files changed, 33 insertions(+) diff --git a/mri_fill/mri_fill.cpp b/mri_fill/mri_fill.cpp index 61030cb2c1b..8c878a76980 100644 --- a/mri_fill/mri_fill.cpp +++ b/mri_fill/mri_fill.cpp @@ -47,6 +47,7 @@ #include "talairachex.h" #include "connectcomp.h" #include "mrisegment.h" +#include "ctrpoints.h" /*------------------------------------------------------------------- @@ -3765,6 +3766,36 @@ get_option(int argc, char *argv[]) else if (!stricmp(option, "no-auto-man")) { DoAutoMan = 0; } + else if (!stricmp(option, "pointset")) { + /* Stand-alone option: takes one or more point sets and fills in + the all the voxels that intersect lines connecting any two + points within a given point set. Fill value determined by the + sign of the xcentroid of a point set. The orginal use case for + this was to help correct the surface in entorhinal cortex where + there would often be a "bite" out of the surface. See docs for + MRIreadControlPoints(). + */ + if(argc < 4){ + printf("-pointset invol outvol ps1 \n"); + exit(1); + } + printf("Reading input %s\n",argv[2]); + MRI *invol = MRIread(argv[2]); + if(invol == NULL) exit(1); + char *outvolfile = argv[3]; + int n; + for(n=0; n < argc-4; n++){ + int count, useRealRAS; + printf("Reading control point file %s\n",argv[4+n]); + MPoint *mp = MRIreadControlPoints(argv[4+n], &count, &useRealRAS); + if(mp == NULL) exit(1); + MRIfillPoints(invol, 0, count, useRealRAS, mp); + free(mp); + } + printf("Writing output %s\n",outvolfile); + int err = MRIwrite(invol,outvolfile); + exit(err); + } else switch (toupper(*option)) { case 'P': diff --git a/mri_fill/mri_fill.help.xml b/mri_fill/mri_fill.help.xml index fb8c76488a1..ad91ee8c3f6 100644 --- a/mri_fill/mri_fill.help.xml +++ b/mri_fill/mri_fill.help.xml @@ -66,6 +66,8 @@ Get edits based on the difference between auto and man and apply to the output. Edit col,row,slice,autoval,manval will be written to the edits.txt file -no-auto-man Turns off -auto-man + -pointset invol outvol ps {ps2 ...} + Stand-alone option: takes one or more pointsets and fills in the all the voxels that intersect lines connecting any two points within a given point set. -ctab colortable Embed color table in the output