QuPath Max Annotation Limit

Hello,

Hope you’re doing well. I have a GeoJSON file of point objects that I’m looking to visualize as annotations over an image using Qupath. I’m able to import the points into QuPath using the Groovy editor, but noticed only 10,000 of the points are imported from the geojson.

I was wondering if this 10,000 was a hard limit, and if not, is there is a way to increase this bound?

Thanks!
Druv

It’s not a hard limit in terms of the number of points QuPath can handle.

Can you share one of your GeoJSON files and the script you’re using to import? There are other places it could potentially go wrong (e.g. hitting the hard limit for a string length in Java), but I’m not sure what is most likely here.

Oh ok, thanks! That’s good to hear. It is quite a large GeoJSON file, so maybe that could be the issue.

Here’s the GeoJSON (qupath_geojson.json - Google Drive) and here’s the script I’m using to import:

import qupath.lib.io.GsonTools
import static qupath.lib.gui.scripting.QPEx.*

// Name of the subdirectory containing the TMA grid
def subDirectory = "Manual points"

// If true, don't check for existing points
boolean ignoreExisting = false

// Check we have an image open from a project
def hierarchy = getCurrentHierarchy()
if (hierarchy == null) {
    println "No image is available!"
    return
}
def name = getProjectEntry()?.getImageName()
if (name == null) {
    println "No image name found! Be sure to run this script with a project and image open."
    return    
}
    
// Resist adding (potentially duplicate) points unless the user explicitly requests this
def existingPoints = getAnnotationObjects().findAll {it.getROI()?.isPoint()}
if (!ignoreExisting && !existingPoints.isEmpty()) {
    println "Point annotations are already present! Please delete these first, or set ignoreExisting = true at the start of this script."
    return
}

def imageData = getCurrentImageData()
def filename = GeneralTools.getNameWithoutExtension(imageData.getServer().getMetadata().getName()) 


def path = buildFilePath("/Users/druv/Documents/qupath_geojson.json")
def file = new File(path)
if (!file.exists()) {
    println "{$file} does not exist! Please ensure the points are available for import."
    return
}

def text = file.text


def type = new com.google.gson.reflect.TypeToken<List<qupath.lib.objects.PathObject>>() {}.getType()
def points = GsonTools.getInstance().fromJson(file.text, type)
hierarchy.insertPathObjects(points)

I opened the GeoJSON is Atom and ran a search for PathAnnotationObject and geometry – it appears both occur exactly 10,000 times. So perhaps it’s an issue with writing rather than importing?

3 Likes

Ah, thanks for this! I didn’t realize until now there was an unneeded max limit set in our pipeline for testing, so this was on our end.

The import is running now! I also compressed like-classifications into a single MultiPoint Object which really helped speed things up. Thanks again for your help!

Druv

3 Likes