Questions about DilateAnnotationPlugin()

qupath

#1

Hi all,

I’m using this function to actually erode muscle fibers (with a negative radius) and I have 2 questions about it:

  • Is it normal that it’s taking more than 1 hour to run on 2 to 3k annotations ?
  • I’m getting some QuPath exception because of fibers that are too small and give a one pixel result when eroding, is there a way to discard those ?

Thanks.


#2

When selecting the annotations you might try a findAll where you check if it.getROI().getArea() is over a certain size.

Not sure about the speed.


#3
//create the class for the outer ring, which you first apply to all original glomeruli
def FullSizedFibers = PathClassFactory.getPathClass("FullSizedFibers")

//Create the class you want to apply to the original glomerulus annotation.
def ErodedFibers    = PathClassFactory.getPathClass("Fibers for erosion")

//get all annotations in the image
originalAnnotations = getAnnotationObjects()
originalAnnotations.each {it.setPathClass(ErodedFibers)}
//selectAnnotations needed to provide a target for the dilate plugin, maybe can use an each statement instead?
selectAnnotations();

runPlugin('qupath.lib.plugins.objects.DilateAnnotationPlugin', '{"radiusMicrons": '+ erosionRadius +',  "removeInterior": false,  "constrainToParent": true}')
//Rename the original annotations to the Glomerulus
originalAnnotations.each {it.setPathClass(FullSizedFibers)}

Here is the code I’m using.

Should I switch the getAnnotations() by getAnnotations().findAll {it.getROI().getArea() > fixedValue} ?


#4

That seems like a good first test. I am not sure how you want to handle the small annotations/cells in regards to your experiment though.


#5

Ok I’ll try that thanks.

The small annotations will be discarded and counted as negative in the second part of the script, so it should work. I’m just affraid of the selectAnnotations() that would reselect everything here…

Another question, do you know how to save .qpdata via script ? I have multiple steps in my script and would love to have the results of each steps…

Thanks a lot !


#6

I noticed the speed issues yesterday (don’t know if they are new) & re-wrote the command to use Java Topology Suite. Seems much faster in my (very limited) test. This will be in the next milestone.


#7

That sounds awesome, thanks ! :slight_smile:

Btw, is there a QuPath groovy script to save qpdata ? I couldn’t find anything…


#8

Afraid I don’t know about saving qpdata files, though I would be curious for CLI runs of QuPath, but you can absolutely save all of the objects from a particular point in the script.


Is an example, where the intention is that you can run cell detections with two sets of parameters and then remove overlaps. You can use a similar type of script to write out both detections and annotations to files at each point where you want to save them. I haven’t tried it for complex structures (cell with subcellular detections, etc), but it might work.

Not sure if it is the best solution, but it should work…


#9

That looks like something I can work with :slight_smile:.

As long as I still keep all the info about those objects, then it should be fine, thanks a lot !


#10

Hi @petebankhead,

Indeed ! It was taking an hour before and now done under 10 minutes, that’s effective ! :smiley: