Skip to content

Instantly share code, notes, and snippets.

View NicoKiaru's full-sized avatar

Nicolas Chiaruttini NicoKiaru

View GitHub Profile
@NicoKiaru
NicoKiaru / CmdExampleWithPreliminaryScript.java
Last active March 13, 2018 14:56
How to launch a script before testing an IJ2 Command during development
import org.scijava.command.Command;
import org.scijava.command.DynamicCommand;
import org.scijava.log.LogService;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;
import ij.ImagePlus;
import net.imagej.ImageJ;
@Plugin(type = Command.class, menuPath = "Plugins>MyCommand>Say Hello")
public class CmdTest extends DynamicCommand{
@NicoKiaru
NicoKiaru / LabelImageToRoiManager.groovy
Created December 12, 2018 09:23
Transforms a label image (in fact any imageplus) into a list ot ROI contained in the ROI Manager
#@ImagePlus imp
import ij.ImagePlus;
import ij.gui.Roi;
import java.util.HashSet;
import ij.process.ImageProcessor;
import ij.plugin.filter.ThresholdToSelection;
import ij.plugin.frame.RoiManager;
import ij.process.FloatProcessor
@NicoKiaru
NicoKiaru / CachedBorders.groovy
Last active April 27, 2019 13:30
Lazy and cached border computation of a Label Image with BigDataViewer
/**
* GROOVY SCRIPT COMPUTING ON THE FLY EDGES OF A LABEL IMAGE
* -----
* - Computes a sample label image
* - Computes lazily with a disk cached cell img an image which finds the border of the labels in 3D
* - Displays both images in BigDataViewer
*
* Code to create the label image mainly copied from:
* - https://imagej.net/ImgLib2_Examples#Example_8_-_Working_with_sparse_data
* - And https://github.com/imglib/imglib2-cache-examples
@NicoKiaru
NicoKiaru / ListFIJIOps.groovy
Created March 23, 2020 15:16
List Ops Available in FIJI
import net.imagej.ops.OpUtils
opsByNS = [:]
#@ImageJ ij
ij.op().ops().each{op ->
ns = OpUtils.getNamespace(op)
name = OpUtils.stripNamespace(op)
if (!opsByNS.containsKey(ns)) {
@NicoKiaru
NicoKiaru / DemoBdvPlayground.groovy
Created April 1, 2020 13:37
Script which displays files in big dataviewer and then output a slice as an imageplus
import ch.epfl.biop.bdv.bioformats.command.OpenFilesWithBigdataviewerBioformatsBridgeCommand
import ch.epfl.biop.bdv.bioformats.command.BioformatsBigdataviewerBridgeDatasetCommand
import sc.fiji.bdvpg.services.SourceAndConverterServices
import bdv.viewer.SourceAndConverter
import ij.gui.WaitForUserDialog
import ch.epfl.biop.scijava.command.BdvViewToImagePlusExportCommand
import sc.fiji.bdvpg.scijava.command.bdv.BdvSourcesAdderCommand
/**
#@ImagePlus stack
#@Integer(label = "Channel DAPI") chDAPI = 1
//Integer(label = "Channel Cytoplasm") chCyto = 3
#@Integer(label = "Channel Measured") chAnalyzed = 2
#@Integer(label = "Nucleus Enlargement in Pixel") enlarge_nucleus_px = 30
#@Boolean(label = "Load Previous ROIS") loadPreviousRois = false
#@Boolean(label = "Save ROIS") saveDetectedRois = false
#@Boolean(label = "Erase previously existing ROIS") erase = false
#@Boolean(label = "Test mode") testMode = false
/**
* Diana analysis for Selene :
* Requirements:
* - An image which contains associated ROIs for nuclei and cytoplasm
* - ROI names should follow the pattern:
* - Cyto_#index_of_cell < Cytoplasm ROI
* - Nucleus_#index_of_cell < Nucleus ROI
* so Cyto_0, Nucleus_0, Cyto_1, Nucleus_1, ...
*
* - DiAna plugin installed (follow instructions https://imagejdocu.tudor.lu/plugin/analysis/distance_analysis_diana_2d_3d/start)
@NicoKiaru
NicoKiaru / DemoFunctionRandomAccessibleAndShearing.groovy
Created May 24, 2020 13:22
Demo of procedural image generation in FIJI using Imglib2 + shearing
import net.imglib2.position.FunctionRandomAccessible
import net.imglib2.type.numeric.integer.UnsignedShortType
import java.util.function.BiConsumer
import bdv.util.BdvFunctions
import bdv.util.BdvOptions
import net.imglib2.FinalInterval
import net.imglib2.view.Views
import net.imglib2.realtransform.AffineTransform3D
import net.imglib2.type.numeric.ARGBType
@NicoKiaru
NicoKiaru / DisplayRoisInBdv.groovy
Last active November 30, 2020 13:44
[Display ROIs in BigDataViewer] Display ROIs of the RoiManager linked to an ImagePlus using BigDataViewer ( ImageJ / FIJI ) #Fiji #ROI #BigDataViewer #BIOP
/**
* Allows to visualize the rois of a RoiManager linked to an ImagePlus
* into bigdataviewer.
*
* REQUIREMENT : install the bigdataviewer-playground update site ( still in development! expect things to break!! )
* Update site : https://biop.epfl.ch/Fiji-Bdv-Playground/
* Source code : https://github.com/bigdataviewer/bigdataviewer-playground
*
*
* A lazy image is generated which display a small square region around each ROI
@NicoKiaru
NicoKiaru / IJMeasureLifeTimeBasic.ijm
Created November 23, 2020 16:54
[Simple Life Time Measurement in ImageJ] Estimate lifetime of ROIs based on single exponential fits ( ImageJ / FIJI ) #Fiji #ROI #FLIM #BIOP
/**
* Allows to compute in a simple manner different regions of a lifetime stack image
*
* REQUIREMENT : For Picoquant file reading, install PTU-Reader (https://github.com/ekatrukha/PTU_Reader)
*
* How to use the script:
* 0 open a PTU file
* 1 make regions of interest and store them into the ROI Manager
* 2 select the lifetime stack
* 3 execute the script and provide the necessary parameters