Skip to content

Instantly share code, notes, and snippets.

View lacan's full-sized avatar
🤝

Olivier Burri lacan

🤝
View GitHub Profile
@lacan
lacan / Replace detections as cells via erosion and add measurements.groovy
Created February 12, 2024 08:36
[Replace detections as cells via erosion and add measurements] Erodes existing detection objects to create cells and adds all compartment measurements #qupath #groovy #detections
/**
* Reduce Detection size to create new cell objects and add measurements
* @author Olivier Burri
* @date 20240212
*/
// By how much should the existing detections be reduced to create the new "nucleus"
def erosionDistancePx = -5
// Should the intensities be measured on a downsampled image?
@lacan
lacan / resave-as-pyramid-with-fixed-bit-depth.groovy
Last active November 1, 2023 09:26
[Resave pyramid with fixed bit depth] Resaves the current image entry as an ome.tiff #qupath #groovy
// Resave image as a pyramidal ome.tiff at the desired downsample and bit depth
// @author Olivier Burri
// 16-bit magic trick inspired from
// https://forum.image.sc/t/software-recommendations-converting-a-32bit-ome-tiff-to-an-8bit-ome-tiff/43043
// But did not use scaling parameter
// ****** PARAMETERS *********
// Output downsample (1 for full-resolution)
def outputDownsample = 1
@lacan
lacan / Example_RNG.groovy
Last active October 30, 2023 12:28
[Relative Neighborhood Graph Algorithm] Simple RNG graph thanks to ChatGPT #groovy #chatgpt #fiji
// DISCLAIMER: The algorithm was taken from a ChatGPT prompt "What is the Groovy implementation of the 2D Relative Neighborhood Graph Algorithm"
// It is merey an alpha version of the code and has not been thorougly tested at all, nor has the code been optimized.
// The original prompt has been slightly modifided to make better use of ImageJ methods to display the graph
// Create a list of points for testing
def rand = new Random()
// Or to make it reproducible
//def rand = new Random( 1000 )
@lacan
lacan / Fix_unmapped_image_entry_uris.groovy
Created August 24, 2023 07:29
[Fix Unmapped Image Entry URIs] Fix overly long times to reach "Update URIs" when the server address changed #groovy #qupath #project #uri #server
/*
* Update QuPath URIs
* After the migration of our EPFL servers from svfasX to sv-nas1.rcp, some projects fail to open in a timely manner,
* especially under Windows when the full path to the server is used (instead of a networked drive).
* The reason seems to be that QuPath is waiting for a response from the server, and the timeouts are long, so it takes a
* really long time before the "Update URIs" window pops up
*
* This script aims to assist in fixing that by at least changing the host name (svfasX) to a valid host (sv-nas1.rcp)
* that way, QuPath will immediately either find or fail to find the file, restoring normal behavior
*
@lacan
lacan / Create_progress_monitor.groovy
Created August 3, 2023 12:49
[Create Progress Monitor in QuPath] Build a progress monitor that is either command line or graphical #qupath #groovy
// Example creating a dialog to run tasks in a script.
// We need to discern between headless and non-headless manually so far
// @author Olivier Burri
//
import qupath.lib.plugins.CommandLinePluginRunner
import qupath.lib.gui.PluginRunnerFX
// Define the runner, in this case we will not use it but it is quite powerful
def runner
@lacan
lacan / Cluster detections by distance and different classes.groovy
Last active April 25, 2023 10:44
[Cluster detections by distance and different classes] Clusters detections with different classifications into clusters based on distance #qupath #groovy
// Define Clusters based on distance and from cells with different classifications
// This script works for images wehre multiple cell signals are segmented as detections
// The detections must be children of annotations objects
// And then a clustering step is used to get multi-classification cells
// The clustering results are provided as circles withg name "Cluster" so you can filter from the original detections
// Works in QuPAth 0.4.3
//
// @author Olivier Burri
// @date 20230425
@lacan
lacan / Rename_VSI_files_from_csv.groovy
Last active September 5, 2023 12:29
[Rename VSI files and folders from CSV] This script helps rename VSI images and folders that have incorrect names #svi #slidescanner #groovy #fiji
#@File originalDir (label="Directory with original VSI Files", style="directory")
#@File csvFile (label="CSV File with full VSI file path in columns 1 and new name in column 2")
#@String sep (label="CSV separator", value=";")
/*
* Rename VSI images based on CSV reference file
*/
println sep
def csvImages = csvFile.readLines()*.split(sep)
@lacan
lacan / Threshold_HDAB_regions_using_ImageJ.groovy
Last active February 17, 2023 11:33
[Threshold HDAB regions using ImageJ] Uses ImageJ's Thresholder to create a selection that gets passed to QuPath as an Annotation or Detection #QuPath #ImageJ #Groovy
import java.awt.Color
import ij.process.ColorProcessor
import ij.process.AutoThresholder
import ij.plugin.filter.ThresholdToSelection
import ij.IJ
// modified from :
// https://petebankhead.github.io/qupath/scripting/2018/03/08/script-imagej-to-qupath.html
// This scripts allow threholding of a color deconvoltuion channel ('DAB', 'Hematoxylin',...)
@lacan
lacan / Assess_Bleach.ijm
Created January 25, 2023 09:57
[Quickly Assess Bleaching] Quick tool for assessing bleaching in Fiji from a copied XY data table from ZEN or LAS-X #Fiji #Macro #Bleaching #ZEN #LASX
macro "Assess Bleaching [F2]" {
// Measure Half time and relate it to number of frames
run("Close All");
// Get the contents of the clipboard as text
text = String.paste;
// Split the lines and then the rows so as to get the X and Y coordinates
line = split(text, "\n");
n = line.length;
@lacan
lacan / Complex Workflow Demo.groovy
Created September 29, 2022 09:01
[Complex Workflow Demo] A demonstration of how a a QuPath workflow can become a script for complex analysis of multiplex data #QuPath #workflow #demo
// This workflow represents the end result that can be obtain by following Dr. Sara McArdle's "Running a complex project in QuPath" tutorial at https://www.youtube.com/watch?v=7AvuzAgHk5o
// @author Olivier Burri
// Prepare the image type
setImageType('FLUORESCENCE')
// Clean up the current image data, as we assume we will be starting from scratch
clearAllObjects()
// Directly create detections from a previously created pixel classifier called "Ck"