Export measurements for multiple images in project

I’m running a QuPath script for multiple images in a project. The last part of the script (see below) contains ‘saveDetectionMeasurements’ to export custom measurements as a .txt file. This works fine when calling the script for an individual file. However, when I use “Run -> Run for project” on several files, no text output is being generated (although it correctly saves the .qpdata file). Any idea about what I’m doing wrong here? Many thanks!

runPlugin('qupath.imagej.detect.tissue.SimpleTissueDetection2', \
'{"threshold": 1,  "requestedPixelSizeMicrons": 20.0,  "minAreaMicrons": 10000.0, \
 "maxHoleAreaMicrons": 1000000.0,  "darkBackground": true,  "smoothImage": false,  \
 "medianCleanup": false,  "dilateBoundaries": false,  "smoothCoordinates": true, \
  "excludeOnBoundary": false,  "singleAnnotation": true}');


runPlugin('qupath.imagej.detect.cells.WatershedCellDetection', '{"detectionImage": "DAPI", \
 "requestedPixelSizeMicrons": 0.5,  "backgroundRadiusMicrons": 10.0,  "medianRadiusMicrons": 0.0,\
   "sigmaMicrons": 1.5,  "minAreaMicrons": 10.0,  "maxAreaMicrons": 400.0,  "threshold": 2.0,\
     "watershedPostProcess": true,  "cellExpansionMicrons": 1.0,  "includeNuclei": true, \
       "smoothBoundaries": true,  "makeMeasurements": true}');

runPlugin('qupath.imagej.detect.cells.SubcellularDetection', '{"detection[Channel 1]": -1.0, \
 "detection[Channel 2]": -1.0,  "detection[Channel 3]": 0.15,  "detection[Channel 4]": 0.15, \
  "detection[Channel 5]": 0.15,  "detection[Channel 6]": 0.15,  "detection[Channel 7]": -1.0, \
   "doSmoothing": false,  "splitByIntensity": true,  "splitByShape": true,  "spotSizeMicrons": 0.5, \
     "minSpotSizeMicrons": 0.2,  "maxSpotSizeMicrons": 7.0,  "includeClusters": false}');


saveDetectionMeasurements('/C:/Users/kohlj/Desktop/Analysis_Crick/QuPath/exported_text/test.txt', 'Image', 'Name', 'Class', 'Parent', 'ROI', 'Centroid X µm', 'Centroid Y µm', 
'Subcellular: Channel 3: Num single spots', 'Subcellular: Channel 4: Num single spots', 'Subcellular: Channel 5: Num single spots', 'Num spots', 
'Subcellular cluster: Channel 3: Area', 'Subcellular cluster: Channel 3: Mean channel intensity', 'Subcellular cluster: Channel 4: Area', 
'Subcellular cluster: Channel 4: Mean channel intensity', 'Subcellular cluster: Channel 5: Area', 'Subcellular cluster: Channel 5: Mean channel intensity')```

I don’t see any obvious problems as far as writing out a single file, but the file will keep overwriting itself for each image since you have not adjusted the name per image. See Pete’s posts as far as the structure to write out measurements for a project:

Great, thanks for pointing out that blog entry - that works well!

1 Like