Skip to content

Instantly share code, notes, and snippets.

View NicoKiaru's full-sized avatar

Nicolas Chiaruttini NicoKiaru

View GitHub Profile
@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
/**
* 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)
#@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
@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
/**
@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 / 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 / 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 / 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{