User Tools

Site Tools


Sidebar

Top
Profile
Freelancing
Seminar
Courses -2016
Courses 2018-
Textbooks
Documents
Downloads (-2016)
Downloads (2016-)
Weblog
RSS aggregates
Discussions
Archives
日本語


EMBL BioImage Data Analysis

EuBIAS

NEUBIAS

—- Contact
CMCI Alumni
ALMF
EMBL Heidelberg
EMBL Intranet


Popularity Ranking


Timeline of @cmci_

cmci_ avatar

RT @J_Cell_Sci: Registration is now open for our 2023 Journal Meeting 'Imaging Cell Dynamics', organised by Erika Holzbaur @ErikaHolzbaur,…
About 6 hours, 48 mins ago by: Kota Miura (@cmci_)

cmci_ avatar

RT @joachimgoedhart: This online resource that introduces data visualization using #rstats & ggplot2 has 12 complete protocols available fo…
About 11 hours, 38 mins ago by: Kota Miura (@cmci_)

cmci_ avatar

The code for image analysis is the "provided upon request" style ... it would be much better to have it openly acce… https://t.co/mdEZhFkrF3
About 13 hours, 3 mins ago by: Kota Miura (@cmci_)

cmci_ avatar

RT @SXS_biophysics: Why do cells move faster in higher viscosity environments? Debonil's paper on this question is out: https://t.co/dlpIX7
About 6 days, 2 hours ago by: Kota Miura (@cmci_)

cmci_ avatar

The first day of online “defragmentation” NEUBIAS academy / EOSC-Life ended, lead by @RogerDAntuono . Great job Roc… https://t.co/98YNB7QpOa
About 6 days, 5 hours ago by: Kota Miura (@cmci_)

cmci_ avatar

RT @hpke1980: Our annotator software is coming soon on BiorXiv. Check it out! #napari @napari_imaging #singlecell https://t.co/Irb9i5Qjw8 h…
About 6 days, 7 hours ago by: Kota Miura (@cmci_)
documents:201021ijmacrofragments

ImageJ Macro Fragments

Some notes on ImageJ macro

Getting the number of Cores

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

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')+"RoiSet.zip";
print(path)
exec("curl", "-LJO", "https://github.com/mutterer/weird/raw/master/RoiSet.zip", "--output", path);
roiManager("Open",path);
roiManager("Show All");
File.delete(path);

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