Skip to content

Instantly share code, notes, and snippets.

@lacan
Created September 6, 2022 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lacan/8367dee9875c72d9ac1166b81cc1d3c9 to your computer and use it in GitHub Desktop.
Save lacan/8367dee9875c72d9ac1166b81cc1d3c9 to your computer and use it in GitHub Desktop.
[Convert Images to Pyramids using QuPath in Parallel] this is pretty fast and works for RGB images. To run in Fiji #fiji #qupath #ome-tiff
#@ File imagesDirectory (label="Directory with images", style="directory")
#@ String extension (label="Image extension", value="tif")
#@ String quPathExe (label="Path to QuPath Executable", value="C:/QuPath-0.3.2/QuPath-0.3.2 (console).exe")
import groovyx.gpars.GParsPool
def folder = imagesDirectory
def convertedFolder = new File( folder.getParent(), "converted")
convertedFolder.mkdirs()
def fileList = folder.listFiles().findAll{ it.getName().endsWith(extension) && !it.getName().contains("Overview") }
GParsPool.withPool(6) {
fileList.eachParallel{ file ->
println file
def cmd = quPathExe
def outputFile = new File (folder, file.getName() + "_info.txt")
def pb = new ProcessBuilder(cmd, "convert-ome", file.getAbsolutePath(), new File( convertedFolder, file.getName()+".ome.tiff").getAbsolutePath(), "-p", "-t", "1")
.redirectErrorStream(true)
.redirectOutput(outputFile)
println pb.command()
pb.start().waitFor()
}
}
//"QuPath-0.3.2 (console).exe" convert-ome Y:\temp-Oli\weird_tif\15936.tif Y:\temp-Oli\weird_tif\15936.ome.tiff -p -t 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment