jni / ray

Automatic segmentation of electron microscopy volumes
Other
31 stars 10 forks source link

figure out difference between ∆VOI and assignment to learn labels. #21

Closed jni closed 13 years ago

jni commented 13 years ago

Hi All,

You may remember that we discussed one of the finer points of learn_agglomerate() during our meeting on Monday. I would assign superpixels to ground truth bodies (a superpixel is assigned the ground truth body that it shares the most overlap with), and then perform a candidate merge if and only if the two superpixels are assigned to the same body. Meanwhile, Toufiq suggested a different approach, and found that it gave more "should merge" responses. The approach was to compute the voi difference before and after the merge, and merge if and only if the difference is negative.

Now, Toufiq ran the training with both methods and found no difference in performance, so figuring it out was a mostly academic exercise, but I'm all in favor of those so here we go.

Imagine

GT:

________
| A | B |
|   |   |
|   |___|
|   | C |
|   |   |
|___|___|

ws:

________
| 1 | 2 |
|   |   |
|   |___|
|  _|_3 |
| | 4_| |
|_|_|___|

(Warning: superpixels not to scale!)

So now we are trying to decide whether to merge sp4 with either the gtA or gtC. Suppose that the gt sizes are |gtA| = 1/2 and |gtB| = |gtC| = 1/4, while the overlaps with sp4 are |gtA ^ sp4| = 3/100 and |gtC ^ sp4| = 2/100 (so |sp4| = 5/100). This is shown in the following contingency table:

In [139]: ctable
Out[139]: 
array([[ 47.,   0.,   0.,   3.],
       [  0.,  25.,   0.,   0.],
       [  0.,   0.,  23.,   2.]])

where rows are GT bodies and columns are watershed superpixels.

Now, we could merge superpixel 4 with sp3:

In [132]: ctable2 = ctable.copy()

In [133]: ctable2[:,2] += ctable2[:,3] # Note: zero-based indexing

In [134]: ctable2[:,3] = 0

In [137]: v2 = ev.split_voi(None, None, cont=ctable2)

In [140]: v2-v1
Out[140]: array([-0.1005448 ,  0.08899893])

In [138]: (v2-v1).sum()
Out[138]: -0.011545871562488291

Which would say "merge" according to Toufiq's criterion. But now let's examine the other candidate merge, sp4 with sp1, which is the merge I would have allowed with the assignment criterion:

In [141]: ctable3 = ctable.copy()

In [142]: ctable3[:,0] += ctable3[:,3]

In [143]: ctable3[:,3] = 0

In [144]: v3 = ev.split_voi(None, None, cont=ctable3)

In [145]: v3-v1
Out[145]: array([-0.16372246,  0.07375303])

In [146]: (v3-v1).sum()
Out[146]: -0.089969430753965907

Which also comes out negative! So the reason the negative VOI criterion gave more negative examples is that you can get a negative change in VOI with multiple different candidate merges, but only one gives the maximal negative change in VOI. In this example at least it's the one given by superpixel assignment.

To reiterate though, either criterion gives a similar learning performance, which makes sense since this should only happen when small superpixels are straddling the ground truth boundary.