Adding features for voxel classification

2 views
Skip to first unread message

Rick Giuly

unread,
Apr 1, 2013, 8:56:17 PM4/1/13
to kurt weiss, cyt...@googlegroups.com
Hi Kurt. You can add more features by editing this file cytoseg_classify.py

The function in cytoseg_classify.py is on line 1258:

def getPointFeaturesAt(inputVolumeDict, volume,
derivativeVolumesIdentifier, gui, point)


As a software engineer, I have to apologize for this code. It's a pretty
experimental program and not cleaned up how I'd like it. In any case,
you'd need to "uncomment" these to turn on the eigen values of the
structure tensor.


xGVolume = gui.getVolume('%s_0Gradient_blur%d' %\
(derivativeVolumesIdentifier, i))
xG = at(xGVolume, point)
yGVolume = gui.getVolume('%s_1Gradient_blur%d' %\
(derivativeVolumesIdentifier, i))
yG = at(yGVolume, point)
zGVolume = gui.getVolume('%s_2Gradient_blur%d' %\
(derivativeVolumesIdentifier, i))
zG = at(zGVolume, point)



stAtSelectedPoint = structureTensor(xG,yG,zG)


sortedEigAtSelectedPoint =
numpy.linalg.eigvals(stAtSelectedPoint)

sortedEigAtSelectedPoint.sort()


prefix = sizeIdentifiers[i] + '_'

f[prefix + 'eig0'] = sortedEigAtSelectedPoint[0]
f[prefix + 'eig1'] = sortedEigAtSelectedPoint[1]
f[prefix + 'eig2'] = sortedEigAtSelectedPoint[2]


Since I "commented them out" by using the "if 0" trick, what you can do
to "uncomment" them is bring them out of the "if 0" statement completely.




Note:

Keep in mind these would only be 3 features out of about 120 if you keep
the values of the 2D patch - each value counts as a feature.

In practice with a random forest, my guess is you may not see much
difference when only 3 out of about 120 features are added.

If you want to use fewer values in the 2D patch you can set the size of
the patch of pixels that is used with the windowSize, for example:

windowSize = 2

right before the line

for xOffset in range(-(windowSize+1), windowSize, step):






> Can you point me in that
> direction so I can begin some trail and error to see if anything helps?
> I did some looking and found things like differenceOfGaussians in
> filters.py. But I don't see anything else like hessian matrix or
> structure tensor eigenvalues or laplacian of guassian smoothed that were
> mentioned in that paper.

kurt weiss

unread,
Apr 2, 2013, 3:12:49 PM4/2/13
to cyt...@googlegroups.com
Thanks Rick,
So I see two sections of code that begin with "for xOffset in range.." (see below). The second is in an if 0 block as well. Should I 'uncomment' that second section, first section, both? and should I put the new window size before the first block? and should window size be an arbitrary number? or some function of the scale parameter as it was set at the beginning of the code?
Thank you very much,
Kurt

 # experimental features
            if 0:
                for xOffset in range(-9, 10, 3):
                    for yOffset in range(-9, 10, 3):
                        f['inputVolume_%s_%d_%d' % (key, xOffset, yOffset)] =\
                            inputVolume[point[0] + xOffset, point[1] + yOffset, point[2]]

            #windowSize = 3
            #windowSize = 5

            scale = 1

            if key == 'originalVolume':
                windowSize = 6 * scale
            else:
                windowSize = 2 * scale


            step = 1 * scale

            #print "point"
            #print point[0]
            #print point[1]
            #print point[2]
            #print inputVolume.shape


            for xOffset in range(-(windowSize+1), windowSize, step):
                for yOffset in range(-(windowSize+1), windowSize, step):
                    f['focus_%s_%d_%d' % (key, xOffset, yOffset)] =\
                        inputVolume[point[0] + xOffset, point[1] + yOffset, point[2]]


        # experimental features
        if 0:

            for xOffset in range(-(windowSize+1), windowSize, step):
                for yOffset in range(-(windowSize+1), windowSize, step):
                    f['xG_%d_%d' % (xOffset, yOffset)] =\
                        xGVolume[point[0] + xOffset, point[1] + yOffset, point[2]]
                    f['yG_%d_%d' % (xOffset, yOffset)] =\
                        yGVolume[point[0] + xOffset, point[1] + yOffset, point[2]]

    # return features
    return f



--
You received this message because you are subscribed to the Google Groups "Cytoseg" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoseg+unsubscribe@googlegroups.com.
To post to this group, send email to cyt...@googlegroups.com.
Visit this group at http://groups.google.com/group/cytoseg?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.





--
.

Rick Giuly

unread,
Apr 2, 2013, 7:31:13 PM4/2/13
to kurt weiss, cyt...@googlegroups.com

Hi Kurt,

(1)

This section is the one that I was referring to. Note: It's the one
that's *not* in a "if 0" statement, so it's being used. Others are
effectively commented out.


> #print inputVolume.shape
>
> for xOffset in range(-(windowSize+1), windowSize, step):
> for yOffset in range(-(windowSize+1), windowSize, step):
> f['focus_%s_%d_%d' % (key, xOffset, yOffset)] =\
> inputVolume[point[0] + xOffset, point[1] +
> yOffset, point[2]]


(2)

The cleanest way is to change windowSize is to change the "6" to
whatever you want:

if key == 'originalVolume':
windowSize = 6 * scale

A smaller number will make the patch smaller.


-rick
> def getPointFeaturesAt(__inputVolumeDict, volume,
> derivativeVolumesIdentifier, gui, point)
>
>
> As a software engineer, I have to apologize for this code. It's a
> pretty experimental program and not cleaned up how I'd like it. In
> any case, you'd need to "uncomment" these to turn on the eigen
> values of the structure tensor.
>
>
> xGVolume = gui.getVolume('%s_0Gradient___blur%d' %\
> (derivativeVolumesIdentifier, i))
> xG = at(xGVolume, point)
> yGVolume = gui.getVolume('%s_1Gradient___blur%d' %\
> (derivativeVolumesIdentifier, i))
> yG = at(yGVolume, point)
> zGVolume = gui.getVolume('%s_2Gradient___blur%d' %\
> (derivativeVolumesIdentifier, i))
> zG = at(zGVolume, point)
>
>
>
> stAtSelectedPoint = structureTensor(xG,yG,zG)
>
>
> sortedEigAtSelectedPoint =
> numpy.linalg.eigvals(__stAtSelectedPoint)
>
> sortedEigAtSelectedPoint.sort(__)
> send an email to cytoseg+unsubscribe@__googlegroups.com
> <mailto:cytoseg%2Bunsu...@googlegroups.com>.
> To post to this group, send email to cyt...@googlegroups.com
> <mailto:cyt...@googlegroups.com>.
> Visit this group at http://groups.google.com/__group/cytoseg?hl=en
> <http://groups.google.com/group/cytoseg?hl=en>.
> For more options, visit https://groups.google.com/__groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>
>
>
> --
> .
>
> --
> You received this message because you are subscribed to the Google
> Groups "Cytoseg" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to cytoseg+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages