Skip to content

Instantly share code, notes, and snippets.

View tferr's full-sized avatar

Tiago Ferreira tferr

View GitHub Profile
//@LogService log
//@UIService ui
import ij.IJ
import ij.gui.Overlay
import features.ComputeCurvatures
import tracing.TracerThread
import tracing.Path
@tferr
tferr / GL_Convex_Hull_Plus.groovy
Created May 18, 2017 17:24
A Groovyfied version of [Gabriel Landini Convex Hull Plus](http://www.mecourse.com/landinig/software/software.html). It is a work in progress
//@ImagePlus imp
// Obtains the 2D Convex Hull ROI from a 2D binary image
// TODO: Use imagej.ops / net.imglib2.roi.geometric.Polygon
import ij.process.ImageProcessor;
import ij.gui.PolygonRoi;
def run(ImageProcessor ip) {
ImageJ 2.0.0-rc-56/1.51j; Java 1.8.0_66 [x86_64]
-- Application: ImageJ --
Title = ImageJ
Version = 2.0.0-rc-56/1.51j
groupId = net.imagej
artifactId = imagej
Archiver-Version = Plexus Archiver
Build-Jdk = 1.8.0_111
Built-By = jenkins-maven
# @ImageJ ij
# @Dataset data
# @String(label="Projection Type",choices={"Max","Mean","Median","Min", "StdDev", "Sum"}) proj_type
from net.imagej.axis import Axes
from net.imagej.ops import Ops
def proj_method(method):
@tferr
tferr / Convert_Traces_to_SWC.py
Created October 27, 2016 17:26 — forked from mhl/Convert_Traces_to_SWC.py
Batch convert Simple Neurite Tracer's .traces files to SWC format
import os
import re
from tracing import PathAndFillManager
# An example script showing how to convert all the .traces
# files in a directory to SWC files. (The .traces format
# is the native file format of Simple Neurite Tracer.)
def run():
d = IJ.getDirectory("Choose your directory of .traces files...")
@tferr
tferr / Polar_Plot_Demo.bsh
Created September 15, 2016 13:12
A Demo Polar Plot Rendered in ImageJ
/* Polar_Plot_Demo.bsh
* IJ BAR: https://github.com/tferr/Scripts#scripts
*
* Beanshell implementation of JFreeChart[1] PolarChartDemo[2]
*
* [1] http://www.jfree.org/jfreechart/api/javadoc/
* [2] http://www.java2s.com/Code/Java/Chart/JFreeChartPolarChartDemo.htm
*/
import ij.gui.GUI;
@tferr
tferr / getRadioCheckbox.java
Last active August 29, 2015 14:27
Get checkbox of RadioButtonGroup
/**
* Retrieves the Checkbox of a RadioButtonGroup() in an ImageJ1
* GenericDialog associated with the specified label.
*/
Checkbox getRadioCheckbox(ij.gui.GenericDialog gd, String label) {
Component[] gdComponents = gd.getComponents();
for (Component c1 : gdComponents) {
if (c1 instanceof Panel) {
Component[] c1Components = ((Panel) c1).getComponents();
for (Component c2 : c1Components) {
@tferr
tferr / Random_String.ijm
Created January 6, 2015 16:39
ImageJ1 macro function to generate random string
function randomString(length, spacers) {
template = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
nChars = lengthOf(template);
string = "";
for (i=0; i<length; i++) {
idx = maxOf(0, round(random()*nChars-1));
string += substring(template, idx, idx+1);
if (spacers && i%5==0) string += "_";
}
return string;
@tferr
tferr / ValidateFileExtension.java
Created January 6, 2015 16:14
Validate file extensions using regex
import java.util.regex.Matcher;
import java.util.regex.Pattern;
boolean validFile(String filename) {
String FILE_PATTERN = "(.*(\\.(?i)(stk|tif))$)";
Pattern pattern = Pattern.compile(FILE_PATTERN);
Matcher matcher = pattern.matcher(filename);
return matcher.matches();
}
@tferr
tferr / Mirror_Selection.ijm
Created December 8, 2014 13:27
ImageJ1 macros that create X/Y mirrors of the active ROI
// ImageJ1 macros that create X/Y mirrors of the active ROI
// http://thread.gmane.org/gmane.comp.java.imagej/35570
macro "Contralateral in X [F1]" {
mirrorROI(-1, 1);
}
macro "Contralateral in Y [F2]" {
mirrorROI(1, -1);
}