[MINC-users] Compute overlap?

Alex Zijdenbos zijdenbos at gmail.com
Tue Aug 30 12:31:56 EDT 2011


On Mon, Aug 29, 2011 at 7:39 PM, Andrew Janke <a.janke at gmail.com> wrote:
> Hi Lisa,
>
> On 30 August 2011 09:23, Lisa F. Akiyama <lrisa87 at uw.edu> wrote:
>> Is there a MINC tool that will compute overlaps (dice coefficient, jaccard
>> coefficient, etc)?
>
> You could compute a dice coefficient using mincmath and mincstats
> assuming both volumes are masks:
>
>   $ mincmath -and in1.mnc in2.mnc and.mnc
>   $ nvox1=`mincstats -count -quiet in1.mnc`
>   $ nvox2=`mincstats -count -quiet in2.mnc`
>   $ nvoxand=`mincstats -count -quiet and.mnc`
>
>   $ dice=`echo "(2 * $nvoxand) / ($nvox1 + $nvox2)" | bc -l`
>
> Note that I haven't checked the above! but it should put you on the right track!

Looks good to me - I have a bit of perl code that does essentially the
same thing:

sub Dice {
    my ($vol1, $vol2) = @_;

    my $sum = &TmpFile('masksum');

    &Run(['mincmath', '-clobber', '-add', $vol1, $vol2, $sum]) && die;

    my @stats;
    &Run(['mincstats', '-quiet', '-count', '-binvalue', '1,2', $sum],
\@stats) && die;
    chomp @stats;

    return (2.0 * $stats[1]) / (2.0 * $stats[1] + $stats[0]);
}

> Other options are to write you own by adding a function to minccmp.
> There is also a rather unfriendly tool in conglomerate called voldiff
> that computes all sorts of wonderful segmentation comparison things.
> It expects input to be in the same form as the output of classify
> IIRC.  Perhaps someone else who has battled voldiff before can give
> some insight.

Voldiff was written by Vasco Kollokian in days long gone by; it
generates a variety of metrics derived from a confusion matrix that
may be non-dichotomous (multi-class segmentations). It indeed expects
"standard" output from classify, with labels 1,2, and 3 for CSF, GM,
and WM, respectively, but I think it should work for the more general
case as well. It's output is rather verbose so can be a bit tricky to
parse.

In some ideal world I think similar functionality would end up in
minccmp; that just requires somebody to spend enough time to add it :)

-- A


More information about the MINC-users mailing list