Skip to content

Commit c772afc

Browse files
committed
added -tmap option allowing users to add some target noise to the
1 parent 22aafde commit c772afc

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

mris_expand/mris_expand.cpp

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static int use_thickness = 0 ;
4747
static int nsurfaces = 1 ;
4848
static const char *thickness_name = "thickness" ;
4949
static const char *pial_name = "pial" ;
50+
static const char *tmap_fname = NULL ;
5051
static int nbrs = 2 ;
5152

5253
static char *orig_name = NULL ;
@@ -119,9 +120,16 @@ main(int argc, char *argv[])
119120
ErrorExit(ERROR_BADPARM, "%s: could not open log file %s", Progname, log_fname) ;
120121
}
121122
if (use_thickness)
122-
printf("expanding surface %s by %2.1f%% of thickness "
123-
"and writing it to %s\n",
124-
in_fname, 100.0*mm_out, out_fname) ;
123+
{
124+
if (use_thickness > 0)
125+
printf("expanding surface %s by %2.1f%% of thickness "
126+
"and writing it to %s\n",
127+
in_fname, 100.0*mm_out, out_fname) ;
128+
else
129+
printf("expanding surface %s by percentages in %s "
130+
"and writing it to %s\n",
131+
in_fname, tmap_fname, out_fname) ;
132+
}
125133
else
126134
printf("expanding surface %s by %2.1f mm and writing it to %s\n",
127135
in_fname, mm_out, out_fname) ;
@@ -138,7 +146,7 @@ main(int argc, char *argv[])
138146
}
139147
if (use_thickness)
140148
{
141-
printf("reading thickness...\n") ;
149+
printf("reading thickness %s...\n", thickness_name) ;
142150
if (MRISreadCurvatureFile(mris, thickness_name) != NO_ERROR)
143151
ErrorExit(ERROR_NOFILE, "%s: could not load thickness file", Progname) ;
144152
MRISsaveVertexPositions(mris, WHITE_VERTICES) ;
@@ -160,6 +168,20 @@ main(int argc, char *argv[])
160168

161169
if (parms.mri_brain && FZERO(mris->vg.xsize))
162170
MRIScopyVolGeomFromMRI(mris, parms.mri_brain) ;
171+
if (tmap_fname != NULL)
172+
{
173+
parms.mri_dtrans = MRIread(tmap_fname);
174+
if (parms.mri_dtrans == NULL)
175+
ErrorExit(ERROR_NOFILE,
176+
"%s: could not tmap vertex percentages from %s\n", Progname, tmap_fname) ;
177+
if (parms.mri_dtrans->width != mris->nvertices)
178+
ErrorExit(ERROR_NOFILE,
179+
"%s: could not tmap width %d != mris->nvertices %d in %s\n",
180+
Progname, parms.mri_dtrans->width, mris->nvertices, tmap_fname) ;
181+
printf("setting vno distance to %f\n", MRIgetVoxVal(parms.mri_dtrans, 0, 0, 0, 0));
182+
}
183+
else
184+
parms.mri_dtrans = NULL ;
163185
MRISexpandSurface(mris, mm_out, &parms, use_thickness, nsurfaces);
164186
#if 0
165187
if (navgs > 0)
@@ -313,6 +335,13 @@ get_option(int argc, char *argv[])
313335
printf("reading pial surface from %s\n", pial_name) ;
314336
nargs = 1 ;
315337
}
338+
else if (!stricmp(option, "tmap"))
339+
{
340+
use_thickness = -1 ;
341+
tmap_fname = argv[2] ;
342+
printf("reading thickness target percent map from %s\n", tmap_fname) ;
343+
nargs = 1 ;
344+
}
316345
else switch (toupper(*option))
317346
{
318347
case 'O':
@@ -384,5 +413,6 @@ usage_exit(int code)
384413
Progname) ;
385414
printf(" Example: mris_expand -thickness lh.white 0.5 lh.graymid\n");
386415
printf(" Example: mris_expand -label labelfile lh.white 0.5 lh.graymid\n");
416+
printf(" Example: mris_expand -tmap thickness_pct_target.mgz lh.white 0.5 lh.graymid\n");
387417
exit(code) ;
388418
}

utils/mrisurf_timeStep.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,6 +2063,7 @@ int MRISexpandSurface(MRI_SURFACE *mris, float distance, INTEGRATION_PARMS *parm
20632063
MRI_SURFACE *mris_ico;
20642064
MHT *mht = NULL;
20652065

2066+
printf("MRISexpandSurface, use_thick %d, mri_dtrans %lx\n", use_thick, (long unsigned int)parms->mri_dtrans);
20662067
l_spring_orig = parms->l_spring;
20672068
if (Gdiag & DIAG_SHOW) {
20682069
mrisLogIntegrationParms(stderr, mris, parms);
@@ -2117,6 +2118,7 @@ int MRISexpandSurface(MRI_SURFACE *mris, float distance, INTEGRATION_PARMS *parm
21172118
if (v->ripflag) {
21182119
continue;
21192120
}
2121+
21202122
MRISsetXYZ(mris, vno,
21212123
v->x + distance * v->nx,
21222124
v->y + distance * v->ny,
@@ -2206,6 +2208,12 @@ int MRISexpandSurface(MRI_SURFACE *mris, float distance, INTEGRATION_PARMS *parm
22062208
DiagBreak();
22072209
}
22082210
if (use_thick) {
2211+
if (use_thick < 0 && parms->mri_dtrans != NULL) // use map of target percentages
2212+
{
2213+
distance = MRIgetVoxVal(parms->mri_dtrans, vno, 0, 0, 0) ;
2214+
if (vno == 0 && DIAG_VERBOSE_ON)
2215+
printf("!!!!!!!!!!!! resetting distance to %f !!!!!!!!!!!!!\n", distance);
2216+
}
22092217
dx = pial_x[vno] - v->origx;
22102218
dy = pial_y[vno] - v->origy;
22112219
dz = pial_z[vno] - v->origz;

0 commit comments

Comments
 (0)