Commit 3fefb9b4 authored by nadar's avatar nadar
Browse files

Merge branch 'master' into 'master'

added the ImageJ macro course from January 2017

See merge request !1
parents 0dc24bb5 fdae4c09
*.DS_Store
*.ppt
*.pptx
\ No newline at end of file
print("\\Clear");
array = newArray(0, 1, 2);
// print (array);
// save as ijm
Array.print(array)
array[0] = 5
Array.print(array)
sum = array[0] + array[1] + array[2];
print(sum)
animals = newArray("dog", "cat");
conc = Array.concat(array, animals);
Array.print(conc);
// ----------------------------
\ No newline at end of file
start = 5;
end = 25;
print("\\Clear");
// ... many empty lines
for (i = start; i >= end; i++) {
if (i > 5) {
print("i was " + i);
}
}
\ No newline at end of file
print("\\Clear");
firstname = "Robert";
lastname = "Haase";
name = firstname + " " + lastname;
print (name);
//------------------------------------------
a = "1";
b = 1;
sumAB = a + b;
sumBA = b + a;
print(sumAB);
print(sumBA);
//------------------------------------------
print("\\Clear");
text = "Hello world!";
text = replace(text, "world", "universe");
print(text);
\ No newline at end of file
Sentence = "Can you can a can as a canner can can a can?";
if (startsWith(Sentence, "Can") {
print(sentence);
}
\ No newline at end of file
start = 0;
end = 10;
// print numbers
for ( i = start; i < end; i++ ) {
if (i > 5) {
print(i);
}
}
// numeric arrays
v = newArray(3, -4, 0);
Array.print(v);
// create an array with three elements containing zeros
v = newArray(3);
Array.print(v);
// manipulate arrays
v[0] = 3.5
Array.print(v);
// access array elements
print( v[2] );
// string arrayss
animals = newArray("dog", "cat", "mouse");
// combining arrays
mixed = Array.concat(v, animals);
Array.print(mixed);
// get length of an array
numberOfElements = lengthOf(v);
print("v has " + numberOfElements + " elements");
a = 5;
b = 7;
sum = a + b;
ratio = a / b;
print("The sum is + sum);
print("The ratio is " + ratio);
// point 1
x1 = 3;
y1 = 5;
// point 2
x2 = 7;
y2 = 8;
// point 3
x3 = 14;
y3 = 3;
printDistance(x1, y1, x2, y2, "between 1 and 2");
printDistance(x2, y2, x3, y3, "between 2 and 3");
printDistance(x1, y1, x3, y3, "between 1 and 3");
function printDistance(xA, yA, xB, yB, description) {
d = sqrt(pow(xA - xB, 2) + pow(yA - yB, 2));
print("The distance " + description + " is " + d);
}
// initialise program
foldername = "/Users/rhaase/temp/";
// get all files in the folder as list
list = getFileList( foldername );
// print out the list; item by item
for (i = 0; i < lengthOf(list); i++) {
filename = list[i];
if (endsWith(filename, ".tif") ||
endsWith(filename, ".gif")) {
open(foldername + filename);
// analyse FOV
getDimensions (imageWidth, imageHeight,
channels, slices, frames);
getPixelSize (physicalUnitName,
pixelWidth, pixelHeight);
// calculate FOV size
FOVwidth = (imageWidth * pixelWidth);
FOVheight = (imageHeight * pixelHeight);
// show results
print(filename);
print("FOV width: " + FOVwidth + physicalUnitName);
print("FOV height: " + FOVheight + physicalUnitName);
close();
}
}
// call build-in function
variable1 = pow(2, 3);
// call custom function
variable2 = cubicRoot(variable1);
print(variable2);
// call build-in function
variable1 = pow(2, 3);
// call custom function
variable2 = cubicRoot(variable1);
print(variable2);
// define a self-made custom function
function cubicRoot(x) {
return pow(x, 1 / 3);
}
print("\\Clear");
foldername = "/Users/rhaase/temp/";
filelist = getFileList(foldername);
for ( i = 0; i < lengthOf(filelist); i++) {
imagefilename = filelist[i];
if (endsWith(imagefilename, ".tif")) {
print(imagefilename);
}
}
// initialisation
input_num = getNumber("Input a number", 5);
// print 10 numbers
for( i = input_num; i >= 0 ; i-- ){
print(i);
}
// initialise program
numberOfTotalPoints = 50;
numberOfReachedPoints_Robert = 40;
// calculate percentage
percentage = numberOfReachedPoints_Robert / numberOfTotalPoints * 100;
// print out grade
if (percentage >= 90) {
print("very good");
}
if (percentage >= 80 && percentage < 90) {
print("good");
}
if (percentage >= 65 && percentage < 80) {
print("satisfactory");
}
if (percentage >= 50 && percentage < 65) {
print("sufficient");
}
if (percentage > 0 && percentage < 50) {
print("insufficient");
}
if (percentage == 0) {
print("failed");
}
sentence = "Text processing is a pain.";
words = split(sentence, " ");
words[0] = "Image";
words[4] = "big fun.";
sentence = join(words, " ");
print(sentence);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment