User Tools

Site Tools


Courses -2016
Courses 2018-
Downloads (-2016)
Downloads (2016-)
RSS aggregates

EMBL BioImage Data Analysis



—- Contact
CMCI Alumni
EMBL Heidelberg
EMBL Intranet

Popularity Ranking

Timeline of @cmci_

cmci_ avatar

RT @mycroscopy: 📢📢📢It's time for our next Neubias Academy @ home webinar: CellPose Date: 25.1.2022 15:30-17:00 CET Registration and more in…
About 1 day, 6 hours ago by: Kota Miura (@cmci_)

cmci_ avatar

RT @RogerDAntuono: The video of "Introduction to ImJoy: AI-powered image analysis on the web" - [NEUBIAS Academy@Home] Webinar held by @wei
About 1 day, 13 hours ago by: Kota Miura (@cmci_)

cmci_ avatar

RT @haesleinhuepf: Jeey! 🥳 Big thanks to Anna @APoetsch for this joint #BioImageAnalysis / #BioStatistics / #Python / #MachineLearning teac…
About 1 day, 13 hours ago by: Kota Miura (@cmci_)

cmci_ avatar

RT @i3S_UPorto: General introduction to ImageJ/Fiji & methods to extract quantitative data. Design of typical workflows to automate image a…
About 3 days, 1 hour ago by: Kota Miura (@cmci_)

cmci_ avatar

@vdneuro download the unix version, unpack .tar file and then copy the jar file to the plugin folder. I believe it…
About 3 days, 1 hour ago by: Kota Miura (@cmci_)

cmci_ avatar

Beautiful work
About 4 days, 6 hours ago by: Kota Miura (@cmci_)

ImageJ Macro Fragments

Some notes on ImageJ macro

Getting the number of Cores

th = eval("script","Runtime.getRuntime().availableProcessors();");

Loading ROIs from a file in Internet

shell command “curl” should be available in your local machine. See here for installation.

run("Blobs (25K)");
path = getDirectory('imagej')+"";
exec("curl", "-LJO", "", "--output", path);
roiManager("Show All");

Getting Pixel Coordinates within a Polygon ROI

Roi.getContainedPoints(xps, yps); 
for(i=0; i<xps.length; i++) {
	xpos = xps[i];
	ypos = yps[i];
	pixval = getPixel(xpos, ypos);
	print("("+ xpos + ", " + ypos + ") ", pixval);

Ways of getting the file basename

filepath = "/my/path/to/great_image.tif";

//Method 1, string indexing
basename = substring(filepath, lastIndexOf(filepath, "/")+1, lastIndexOf(filepath, "."));
print("Method 1: ", basename);

//Method 2, regular expression
basename = replace(filepath, "(.*\\/)(.*)\\..{3,5}$", "$2");
print("Method 2: ", basename);
//... in this case, it's also possible to get the parent directry just with a small modification
parent = replace(filepath, "(.*\\/)(.*)\\..{3,5}$", "$1");
print(".... parent: ", parent);

//Method 3, use a specific command
//from ver. 1.52r
basename = File.getNameWithoutExtension(filepath);
print("Method 3: ", basename);
//... it's also possible to get the parent directory with a command. 
parent = File.getDirectory(filepath);
print(".... parent: ", parent);

Convert black pixels to white in RGB image

for (j =0; j<getHeight();j++){
	for (i=0; i<getWidth();i++){
		pix =  getPixel(i, j);
		sum = sumRGB(pix);
		if (sum == 0){
			setPixel(i, j, 0xffffff);

function sumRGB(RGBpixval){
	sum = getR(pix) + getG(pix) + getB(pix);
	return sum;

function getR(RGBpixval){
	rf = (RGBpixval & 0xff0000)>>16;
	return rf;       
function getG(RGBpixval){
	gf = (RGBpixval & 0x00ff00)>>8;
	return gf; 
function getB(RGBpixval){
    bf = (RGBpixval & 0x0000ff); 
    return bf;        

documents/201021ijmacrofragments.txt · Last modified: 2021/12/07 09:09 by kota