Skip to content

Commit 0366fe1

Browse files
author
Douglas Greve
committed
Merge branch 'dev' of github.com:freesurfer/freesurfer into dev
2 parents 2ef689d + bb90cae commit 0366fe1

File tree

5 files changed

+119
-27
lines changed

5 files changed

+119
-27
lines changed

distribution/FreeSurferColorLUT.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,15 @@
277277
265 Left-Eyeball 60 60 60 0
278278
266 Right-Eyeball 60 60 60 0
279279

280+
270 ctl-lh-infragranular 205 70 78 0
281+
271 ctl-lh-layer1 210 80 78 0
282+
272 ctl-lh-layer2 215 90 78 0
283+
273 ctl-lh-layer3 220 100 78 0
284+
274 ctl-lh-layer4 225 110 78 0
285+
275 ctl-lh-layer5 230 120 78 0
286+
276 ctl-lh-layer6 235 135 78 0
287+
277 ctx-lh-supragranular 240 140 78 0
288+
280289
# lymph node and vascular labels
281290
331 Aorta 255 0 0 0
282291
332 Left-Common-IliacA 255 80 0 0
@@ -308,6 +317,15 @@
308317
358 Pos-Lymph 20 130 180 0
309318
359 Neg-Lymph 20 180 130 0
310319

320+
370 ctl-rh-infragranular 205 70 130 0
321+
371 ctl-rh-layer1 210 80 130 0
322+
372 ctl-rh-layer2 215 90 130 0
323+
373 ctl-rh-layer3 220 100 130 0
324+
374 ctl-rh-layer4 225 110 130 0
325+
375 ctl-rh-layer5 230 120 130 0
326+
376 ctl-rh-layer6 235 135 130 0
327+
377 ctx-rh-supragranular 240 140 130 0
328+
311329
400 V1 206 62 78 0
312330
401 V2 121 18 134 0
313331
402 BA44 199 58 250 0

mri_compute_volume_fractions/mri_compute_layer_fractions.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ main(int argc, char *argv[])
168168

169169
MRIreInitCache(mri_layers) ;
170170

171-
if (FS_names && nlayers != 1)
171+
if (FS_names && nlayers > 2)
172172
ErrorExit(ERROR_UNSUPPORTED, "%s: if specifying FS_names must use -nlayers 1", Progname) ;
173173
printf("reading laminar surfaces from %s.?\n", LAMINAR_NAME) ;
174174
for (i = 0 ; i <= nlayers ; i++) {
@@ -186,8 +186,15 @@ main(int argc, char *argv[])
186186
}
187187
}
188188
} else {
189-
int req = snprintf(fname, STRLEN,
190-
"%s/%s/surf/%s.%s.%d", sdir, subject,hemi,LAMINAR_NAME,i) ;
189+
int req ;
190+
if (FS_names && i == 0)
191+
req = snprintf(fname, STRLEN, "%s/%s/surf/%s.white", sdir, subject,hemi) ;
192+
else if (FS_names && i == 2)
193+
req = snprintf(fname, STRLEN, "%s/%s/surf/%s.pial", sdir, subject,hemi) ;
194+
else if (FS_names)
195+
req = snprintf(fname, STRLEN, "%s/%s/surf/%s.%s", sdir, subject,hemi,LAMINAR_NAME) ;
196+
else
197+
req = snprintf(fname, STRLEN, "%s/%s/surf/%s.%s.%d", sdir, subject,hemi,LAMINAR_NAME,i) ;
191198
if( req >= STRLEN ) {
192199
std::cerr << __FUNCTION__ << ": Truncation on line " << __LINE__ << std::endl;
193200
}

mris_convert/mris_convert.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,13 +465,12 @@ main(int argc, char *argv[])
465465
mris->vg.valid = 0;
466466
}
467467

468-
// ??? should we call MRIcopyMRIS() instead ???
469468
if(MRISfileNameType(out_fname) == MRIS_VOLUME_FILE) {
470469
printf("Saving surface xyz %s as a volume format\n",out_fname);
471470
MRI *vol = MRIallocSequence(mris->nvertices, 1, 1, MRI_FLOAT, 3);
472-
MRIScopyMRI(mris,vol,0,"x");
473-
MRIScopyMRI(mris,vol,1,"y");
474-
MRIScopyMRI(mris,vol,2,"z");
471+
MRIcopyMRIS(vol,mris,0,"x");
472+
MRIcopyMRIS(vol,mris,1,"y");
473+
MRIcopyMRIS(vol,mris,2,"z");
475474
MRIwrite(vol,out_fname);
476475
MRIfree(&vol);
477476
}

mris_expand/mris_expand.cpp

Lines changed: 75 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "const.h"
3737
#include "timer.h"
3838
#include "version.h"
39+
#include "randomfields.h"
3940

4041
int main(int argc, char *argv[]) ;
4142
static int get_option(int argc, char *argv[]) ;
@@ -47,7 +48,12 @@ static int use_thickness = 0 ;
4748
static int nsurfaces = 1 ;
4849
static const char *thickness_name = "thickness" ;
4950
static const char *pial_name = "pial" ;
50-
static const char *tmap_fname = NULL ;
51+
static char *tmap_fname = NULL ;
52+
static char *tmap_write_fname = NULL ;
53+
static float tmap_std = 0.0 ;
54+
static float tmap_min = .25 ;
55+
static float tmap_max = .75 ;
56+
static int tmap_avgs = 0 ;
5157
static int nbrs = 2 ;
5258

5359
static char *orig_name = NULL ;
@@ -173,12 +179,50 @@ main(int argc, char *argv[])
173179
parms.mri_dtrans = MRIread(tmap_fname);
174180
if (parms.mri_dtrans == NULL)
175181
ErrorExit(ERROR_NOFILE,
176-
"%s: could not tmap vertex percentages from %s\n", Progname, tmap_fname) ;
182+
"%s: could not read tmap vertex percentages from %s\n", Progname, tmap_fname) ;
177183
if (parms.mri_dtrans->width != mris->nvertices)
178184
ErrorExit(ERROR_NOFILE,
179-
"%s: could not tmap width %d != mris->nvertices %d in %s\n",
185+
"%s: tmap width %d != mris->nvertices %d in %s\n",
180186
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));
187+
}
188+
else if (!FZERO(tmap_std)) // create a random map of distances
189+
{
190+
RFS *rfs = RFspecInit(0, NULL);
191+
int vno ;
192+
193+
parms.mri_dtrans = MRIalloc(mris->nvertices, 1, 1, MRI_FLOAT) ;
194+
if (parms.mri_dtrans == NULL)
195+
ErrorExit(ERROR_NOFILE,
196+
"%s: could not allocate tmap vertex percentages from %s\n", Progname, tmap_fname) ;
197+
198+
printf("creating random tmap distances\n") ;
199+
rfs->name = strcpyalloc("gaussian");
200+
rfs->params[0] = mm_out ; // mean is halfway through the ribbon
201+
rfs->params[1] = tmap_std; // std
202+
203+
for (vno = 0 ; vno < mris->nvertices ; vno++)
204+
mris->vertices[vno].val = RFdrawVal(rfs);
205+
206+
MRISaverageVals(mris, tmap_avgs) ;
207+
for (vno = 0 ; vno < mris->nvertices ; vno++)
208+
{
209+
float dist = mris->vertices[vno].val ;
210+
211+
dist = MIN(MAX(dist, tmap_min), tmap_max) ;
212+
if (mris->vertices[vno].ripflag)
213+
dist = 0 ;
214+
215+
if (vno == Gdiag_no)
216+
printf("vno %d: val %f, ripflag %d\n", vno, dist, mris->vertices[vno].ripflag) ;
217+
218+
mris->vertices[vno].val = dist ;
219+
MRIsetVoxVal(parms.mri_dtrans, vno, 0, 0, 0, dist) ;
220+
}
221+
if (tmap_write_fname != NULL)
222+
{
223+
printf("writing random tmap to %s\n", tmap_write_fname) ;
224+
MRISwriteValues(mris, tmap_write_fname) ;
225+
}
182226
}
183227
else
184228
parms.mri_dtrans = NULL ;
@@ -329,6 +373,12 @@ get_option(int argc, char *argv[])
329373
nargs = 1 ;
330374
fprintf(stderr, "l_surf_repulse = %2.3f\n", parms.l_surf_repulse) ;
331375
}
376+
else if (!stricmp(option, "wd"))
377+
{
378+
tmap_write_fname = argv[2] ;
379+
nargs = 1 ;
380+
fprintf(stderr, "writing random tmap to %s\n", tmap_write_fname) ;
381+
}
332382
else if (!stricmp(option, "pial"))
333383
{
334384
pial_name = argv[2] ;
@@ -338,9 +388,22 @@ get_option(int argc, char *argv[])
338388
else if (!stricmp(option, "tmap"))
339389
{
340390
use_thickness = -1 ;
341-
tmap_fname = argv[2] ;
342-
printf("reading thickness target percent map from %s\n", tmap_fname) ;
343-
nargs = 1 ;
391+
if (!stricmp(argv[2], "random"))
392+
{
393+
tmap_std = atof(argv[3]);
394+
tmap_min = atof(argv[4]);
395+
tmap_max = atof(argv[5]);
396+
tmap_avgs = atoi(argv[6]);
397+
printf("creating random tmap in [%2.2f, %2.2f] with std %2.2f and %d averages\n",
398+
tmap_min, tmap_max, tmap_std, tmap_avgs) ;
399+
nargs = 5 ;
400+
}
401+
else
402+
{
403+
tmap_fname = argv[2] ;
404+
printf("reading thickness target percent map from %s\n", tmap_fname) ;
405+
nargs = 1 ;
406+
}
344407
}
345408
else switch (toupper(*option))
346409
{
@@ -414,5 +477,10 @@ usage_exit(int code)
414477
printf(" Example: mris_expand -thickness lh.white 0.5 lh.graymid\n");
415478
printf(" Example: mris_expand -label labelfile lh.white 0.5 lh.graymid\n");
416479
printf(" Example: mris_expand -tmap thickness_pct_target.mgz lh.white 0.5 lh.graymid\n");
480+
printf(" use a prespecified map of percent thickness to compute the target locations for expansion\n");
481+
printf(" Example: mris_expand -tmap random 2 .25 .75 100 -wd tmap.mgz lh.white 0.5 lh.graymid\n");
482+
printf(" creates a random target distance map with gaussian sampling (mean=.5, std=2) and cropping to .25/.75\n");
483+
printf(" and spatial averaging 100 times (cropping is average averaging). The map will be written to \n");
484+
printf(" file tmap.mgz\n");
417485
exit(code) ;
418486
}

utils/gcsa.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,9 +2248,7 @@ int GCSArelabelWithAseg(GCSA *gcsa, MRI_SURFACE *mris, MRI *mri_aseg)
22482248
{
22492249
int old_index, vno, vno_classifier, vno_prior, label, index, changed, cc_annotation;
22502250
VERTEX *v, *v_classifier, *v_prior;
2251-
GCSA_NODE *gcsan;
2252-
CP_NODE *cpn;
2253-
double v_inputs[100], p;
2251+
double v_inputs[100], p[3];
22542252
double x, y, z;
22552253

22562254
for (changed = vno = 0; vno < mris->nvertices; vno++) {
@@ -2267,11 +2265,11 @@ int GCSArelabelWithAseg(GCSA *gcsa, MRI_SURFACE *mris, MRI *mri_aseg)
22672265
v_classifier = GCSAsourceToClassifierVertex(gcsa, v_prior);
22682266
vno_classifier = v_classifier - gcsa->mris_classifiers->vertices;
22692267
if (vno_classifier == Gdiag_no) DiagBreak();
2270-
gcsan = &gcsa->gc_nodes[vno_classifier];
2268+
GCSA_NODE *gcsan = &gcsa->gc_nodes[vno_classifier];
22712269

22722270
CTABfindAnnotation(mris->ct, v->annotation, &old_index);
22732271

2274-
cpn = &gcsa->cp_nodes[vno_prior];
2272+
CP_NODE *cpn = &gcsa->cp_nodes[vno_prior];
22752273
if (IS_CC(label)) {
22762274
CTABfindName(mris->ct, "corpuscallosum", &index);
22772275
if (index < 0) CTABfindName(mris->ct, "Medial_wall", &index);
@@ -2291,7 +2289,7 @@ int GCSArelabelWithAseg(GCSA *gcsa, MRI_SURFACE *mris, MRI *mri_aseg)
22912289
else if (old_index >= 0 && mris->ct && !stricmp(mris->ct->entries[old_index]->name, "corpuscallosum")) {
22922290
// find 2nd most likely label that isn't callosum
22932291
CTABannotationAtIndex(mris->ct, old_index, &cc_annotation);
2294-
label = GCSANclassify(gcsan, cpn, v_inputs, gcsa->ninputs, &p, &cc_annotation, 1, vno);
2292+
label = GCSANclassify(gcsan, cpn, v_inputs, gcsa->ninputs, p, &cc_annotation, 1, vno);
22952293
if (label != v->annotation) {
22962294
changed++;
22972295
v->annotation = label;
@@ -2305,9 +2303,7 @@ int GCSAreclassifyMarked(GCSA *gcsa, MRI_SURFACE *mris, int mark, int *exclude_l
23052303
{
23062304
int old_index, vno, vno_classifier, vno_prior, label, index, changed, num, n;
23072305
VERTEX *v, *v_classifier, *v_prior, *vn;
2308-
GCSA_NODE *gcsan;
2309-
CP_NODE *cpn;
2310-
double v_inputs[100], p;
2306+
double v_inputs[100], p[3];
23112307

23122308
for (changed = vno = 0; vno < mris->nvertices; vno++) {
23132309
v = &mris->vertices[vno];
@@ -2321,12 +2317,12 @@ int GCSAreclassifyMarked(GCSA *gcsa, MRI_SURFACE *mris, int mark, int *exclude_l
23212317
v_classifier = GCSAsourceToClassifierVertex(gcsa, v_prior);
23222318
vno_classifier = v_classifier - gcsa->mris_classifiers->vertices;
23232319
if (vno_classifier == Gdiag_no) DiagBreak();
2324-
gcsan = &gcsa->gc_nodes[vno_classifier];
2320+
GCSA_NODE *gcsan = &gcsa->gc_nodes[vno_classifier];
23252321

23262322
CTABfindAnnotation(mris->ct, v->annotation, &old_index);
23272323

2328-
cpn = &gcsa->cp_nodes[vno_prior];
2329-
label = GCSANclassify(gcsan, cpn, v_inputs, gcsa->ninputs, &p, exclude_list, nexcluded, vno);
2324+
CP_NODE *cpn = &gcsa->cp_nodes[vno_prior];
2325+
label = GCSANclassify(gcsan, cpn, v_inputs, gcsa->ninputs, p, exclude_list, nexcluded, vno);
23302326
if (label >= 0 && label != v->annotation) {
23312327
changed++;
23322328
v->annotation = label;
@@ -2337,9 +2333,13 @@ int GCSAreclassifyMarked(GCSA *gcsa, MRI_SURFACE *mris, int mark, int *exclude_l
23372333
that had nonzero priors and reclassify them based on nbrs. */
23382334
do {
23392335
for (num = vno = 0; vno < mris->nvertices; vno++) {
2340-
VERTEX_TOPOLOGY const * const vt = &mris->vertices_topology[vno];
23412336
v = &mris->vertices[vno];
23422337
if (v->ripflag || v->marked != mark) continue;
2338+
VERTEX_TOPOLOGY const * const vt = &mris->vertices_topology[vno];
2339+
/* moved to before assigning VERTEX_TOPOLOGY const * const vt
2340+
* v = &mris->vertices[vno];
2341+
* if (v->ripflag || v->marked != mark) continue;
2342+
*/
23432343
if (vno == Gdiag_no) DiagBreak();
23442344
for (n = 0; n < vt->vnum; n++) {
23452345
vn = &mris->vertices[vt->v[n]];

0 commit comments

Comments
 (0)