Stardist Limiting Memory Usage?

Hi all,

I’ve been trying to transition over to Stardist for my cell detection needs in Qupath. I’ve gotten it to work in brightfield and am trying to get it to work in fluorescence. I got the script on the Qupath Stardist page.

Script

import qupath.tensorflow.stardist.StarDist2D

// Specify the model directory (you will need to change this!)
def pathModel = '/Users/DGN4/Documents/dsb2018_heavy_augment'

def stardist = StarDist2D.builder(pathModel)
        .threshold(0.5)              // Probability (detection) threshold
        .channels('Blue')            // Specify detection channel
        .normalizePercentiles(1, 99) // Percentile normalization
        .pixelSize(0.5)              // Resolution for detection
        .cellExpansion(5.0)          // Approximate cells based upon nucleus expansion
        .cellConstrainScale(2)     // Constrain cell expansion using nucleus size
        .measureShape()              // Add shape measurements
        .measureIntensity()          // Add cell measurements (in all compartments)
        .includeProbability(true)    // Add probability as a measurement (enables later filtering)
        .doLog()
        .build()

// Run detection for the selected objects
def imageData = getCurrentImageData()
def pathObjects = getSelectedObjects()
if (pathObjects.isEmpty()) {
    Dialogs.showErrorMessage("StarDist", "Please select a parent object!")
    return
}
stardist.detectObjects(imageData, pathObjects)
println 'Done!'

The script runs, but it doesn’t end. Any ideas what could be causing the issues? In checking the memory to see if anything was happening, I noticed it was only allocating 14Gb or so (picture below). Have I messed something up, or is this just how Stardist runs?

Well, I force-quit and restarted the program, tried again, and it detected everything in 8 seconds. Consider the problem fixed, but I’m still curious to know why this happened…

1 Like

I have occasionally had similar things happen with that, other commands, and other scripts. It happens so infrequently that I have never been able to pin anything down. When it gets locked in a loop like that though, it will run for days and never finish.

1 Like