Hi Nick-I've shortened the run time of the script (attached) by comparing the size of the two labels and restricting the search to only those vertices that exist in the smaller label.
My logic is that there can't possibly be any more matching vertices than the size of the smaller label, so I may as well only act upon the smaller search space. If label A has 50,000 vertices and label B has 1,000 vertices, well, then I've saved 49,000 searches. This might not be a big deal for any individual iteration of the script, but it adds up when I'm running the script on 2 hemispheres by 35 aparc labels by 168 subjects!
Please let me know if I've missed some fundamental piece of info on the nature of labels and it would be better to stick with the longer version.
Thanks again for all of your help!(David Brang- I copied you on this because I think your recent post can be answered by the thread that I have going here with Nick. The attached script could easily be altered to find the intersection of all of the labels you've created.)
--------- Jim Porter Graduate Student Clinical Science & Psychopathology Research University of Minnesota Nick Schmansky wrote:
Jim Ok, one more time, attached is another iteration of the labels_intersection and labels_union scripts. These ignore the x,y,z and stats columns, looking only at the vertex numbers. In the case of identical vertices, the x,y,z,stats column data from the first file argare included in the output file.Nick On Sun, 2009-08-30 at 19:37 -0500, James Porter wrote:FYI, Nick-It may be something to do with the 'comm' program on Mac OS X (assuming that you wrote the scripts on a UNIX machine), but the labels_intersect file doesn't quite work properly. However, I do get correct intersection results from the labels_union script by simply switching 'uniq -u' to 'uniq -d' and leaving everything else the same. Below you can see that there are identical lines in the two files, 'comm' doesn't find them, and 'uniq -d' does find them.$ grep 42796 TEST.zero.label 42796 -22.144 -40.241 27.868 0.000000 142796 -4.945 52.116 -14.802 0.000000 $ grep 42796 aparc_labels/lh.postcentral.label 42796 -22.144 -40.241 27.868 0.00000 $ labels_intersect TEST.zero.label lh.postcentral.label Int.label $ head Int.label #!ascii label , from subject 17682 vox2ras=TkReg 0 $ labels_intersect_jim TEST.zero.label lh.postcentral.label JimInt.label $ head JimInt.label #!ascii label , from subject 17682 vox2ras=TkReg 1175 42796 -22.144 -40.241 27.868 0.000000 43946 -22.166 -39.570 28.120 0.000000 43953 -22.313 -39.961 27.481 0.000000 45154 -21.927 -37.868 29.306 0.000000 45167 -22.067 -38.462 27.645 0.000000 45168 -22.290 -38.809 28.096 0.000000 45173 -21.669 -38.528 26.871 0.000000 45174 -22.199 -39.236 27.196 0.000000Also of note, if the 5th stats column in the label files are different, no union or intersection is correctly found. The labels generated by mri_surfcluster have the cluster pval from the monte carlo simulations in the 5th column, but the labels generated by mri_annotation2label just have zeros. It's easy enough to fix with sed, though.Thanks for the help! --------- Jim Porter Graduate Student Clinical Science & Psychopathology Research University of Minnesota Nick Schmansky wrote:Jim, Attached are two scripts for getting the union or intersect of two label files. Nick On Thu, 2009-08-27 at 20:32 -0500, James Porter wrote:Hello- Is there a simple way to obtain the intersection of two labels, outputinto a third label? Or the intersection of a label and an .mgh file output by mri_surfcluster?For instance, I have a cluster defined by mri_glmfit/mri_surfcluster that spans multiple anatomical regions, and I want to investigate the values from subsections of the cluster. That is to say, I want to run mris_anatomical_stats on only the section of my cluster that covers, say, precentral cortex but not caudal middle frontal or pars opercularis.I've tried several strategies without success. The most promising seemed to be just having mri_surfcluster output an aparc file, and then pass that aparc file into mris_anatomical_stats. However, that aparc just puts the very first region definition to every vertex. The same happens if I run mri_label2aparc on the labels output by mri_surfcluster. This happens no matter which LUT or ctab I use, i.e., with aparc.annot.ctab the whole volume gets labeled "bankssts" and with FreeSurferColorLUT.txt every vertex in the cluster volume gets labeled "Left-Cerebral-Exterior."I guess there are a few issues in this email, but the most important one to me is being able to run mris_anatomical_stats on the union of a cluster file and the individual regions from the standard aparc atlas.Any suggestions? Thanks in advance, --------- Jim Porter Graduate Student Clinical Science & Psychopathology Research University of Minnesota _______________________________________________ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
labels_intersect_jim
Description: application/text
_______________________________________________ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer