Skip to content

Instantly share code, notes, and snippets.

@NicoKiaru
Last active October 13, 2022 06:51
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 NicoKiaru/b91f9f3f0069b765a49b5d4629a8b1c7 to your computer and use it in GitHub Desktop.
Save NicoKiaru/b91f9f3f0069b765a49b5d4629a8b1c7 to your computer and use it in GitHub Desktop.
Test Fiji / Elastix bridge of BigDataViewer-Playground
/**
* BIOP, EPFL, Nicolas Chiaruttini, 18th April 2021
* Simple script for a simple registration test
*/
import ij.IJ
import ch.epfl.biop.wrappers.elastix.ij2commands.Elastix_Register
import ch.epfl.biop.wrappers.transformix.ij2commands.Transformix_TransformImgPlus
import ij.gui.WaitForUserDialog
#@CommandService cs
(new WaitForUserDialog(
"The PTBIOP update site should be enabled.\n"+
"Elastix and Transformix should be installed and work in a command line interface.")).show();
(new WaitForUserDialog("Set the location of elastix and transformix executable file")).show();
IJ.run("Set and Check Wrappers","");
// Test images : blobs and rotated blobs
(new WaitForUserDialog("Click 'OK' to start a registration test, which should take about 10 seconds ...")).show();
IJ.run("Blobs (25K)");
IJ.run("Duplicate...", "title=blobs-rot15.gif");
IJ.run("Rotate... ", "angle=8 grid=1 interpolation=Bilinear");
// Get transformation
rh = cs.run(Elastix_Register.class, true,
"movingImage", "blobs.gif",
"fixedImage", "blobs-rot15.gif",
"rigid",false,
"fast_affine",true,
"affine",false,
"spline",false,
"splineGridSpacing",40
).get().getOutput("rh")
// Transform image
transformed_image = cs.run(Transformix_TransformImgPlus.class, true,
"img_in", "blobs.gif",
"rh", rh
).get().getOutput("img_out")
transformed_image.show()
IJ.run("Tile");
(new WaitForUserDialog("The test is successful if the last and the next-to.last images look identical.")).show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment