diff --git a/05_ImageJ-macro-cheatsheet.pptx b/05_ImageJ-macro-cheatsheet.pptx new file mode 100644 index 0000000000000000000000000000000000000000..c4e8aaa2c467693a3cda6c7f81db50624c553ba8 Binary files /dev/null and b/05_ImageJ-macro-cheatsheet.pptx differ diff --git a/05_ImageJ-macro_programming.pptx b/05_ImageJ-macro_programming.pptx new file mode 100644 index 0000000000000000000000000000000000000000..ff52b11f5f8ac0166cd5278e60a8b3bc7bc77114 Binary files /dev/null and b/05_ImageJ-macro_programming.pptx differ diff --git a/05_example_code_and_data/analyse_banana.ijm b/05_example_code_and_data/analyse_banana.ijm new file mode 100644 index 0000000000000000000000000000000000000000..e36381307017447f652e4b92cfae5fc5e0619ab2 --- /dev/null +++ b/05_example_code_and_data/analyse_banana.ijm @@ -0,0 +1,43 @@ +// This ImageJ macro analyses a folder of 2D MRI +// images showing a banana slice by slice. It measures +// the position of the banana and writes it in a CSV file. +// +// Usage: run it in Fiji (http://fiji.sc) +// +// Robert Haase, MPI CBG, rhaase@mpi-cbg.de +// April 2019 +// + +folder = "C:/structure/teaching/lecture_applied_bioimage_analysis/05_example_data/banana/" + +// access the folder +filelist = getFileList(folder); + +for (i = 0; i < lengthOf(filelist); i++) { + // get the nth entry from the filelist array + file = filelist[i]; + + if (endsWith(file, ".tif")) { + + // open the image + open(folder + file); + + // segment the object in the image + setAutoThreshold("Default dark"); + setOption("BlackBackground", true); + run("Convert to Mask"); + run("Fill Holes"); + + // measure the position of this one single object + run("Set Measurements...", "centroid redirect=None decimal=3"); + run("Create Selection"); + run("Measure"); + + // close the image + close(); + } +} + +// save the positions as CSV to disc +result_filename = "Position.csv" +saveAs("Results", folder + result_filename); diff --git a/05_example_code_and_data/arrays.ijm b/05_example_code_and_data/arrays.ijm new file mode 100644 index 0000000000000000000000000000000000000000..24470e5139dacafe270cf720d93cfa46797a7a4f --- /dev/null +++ b/05_example_code_and_data/arrays.ijm @@ -0,0 +1,27 @@ +// 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"); + + diff --git a/05_example_code_and_data/banana.zip b/05_example_code_and_data/banana.zip new file mode 100644 index 0000000000000000000000000000000000000000..84a3cf66478249470ff9bc8475310490abfe8abb Binary files /dev/null and b/05_example_code_and_data/banana.zip differ diff --git a/05_example_code_and_data/csv_test.py b/05_example_code_and_data/csv_test.py new file mode 100644 index 0000000000000000000000000000000000000000..0ab9a40491e4f959f5ef813123c4be8f12875da8 --- /dev/null +++ b/05_example_code_and_data/csv_test.py @@ -0,0 +1,14 @@ + +import csv +with open("test.csv", newline='') as csvfile: + reader = csv.reader(csvfile, delimiter=',') + + linecount = 0; + for row in reader: + + if (linecount > 0): + print("The square of " + row[0] + " is " + row[1]); + + linecount = linecount + 1 + + diff --git a/05_example_code_and_data/first_example.ijm b/05_example_code_and_data/first_example.ijm new file mode 100644 index 0000000000000000000000000000000000000000..b326d1aaf7a250dea2e5453cf7585696deb21502 --- /dev/null +++ b/05_example_code_and_data/first_example.ijm @@ -0,0 +1,9 @@ +// +// This program is our first example +// +// Author: Robert Haase, MPI-CBG, +// rhaase@mpi-cbg.de +// July 2015 + +print("Hello world"); + diff --git a/05_example_code_and_data/good_comments.ijm b/05_example_code_and_data/good_comments.ijm new file mode 100644 index 0000000000000000000000000000000000000000..8838c26014f5c086f4c12b01877962a476ffb52e --- /dev/null +++ b/05_example_code_and_data/good_comments.ijm @@ -0,0 +1,20 @@ +// This program is our second example. +// It sums up two numbers. +// +// Usage: +// * Run it in FIJI (www.fiji.sc) +// +// Author: Robert Haase, MPI CBG, +// rhaase@extern.mpi-cbg.de +// July 2016 + +// initialise program +a = 1; +b = 2.5; + +// run complicated algorithm +final_result = a + b; + + +print( final_result ); + diff --git a/05_example_code_and_data/good_comments.py b/05_example_code_and_data/good_comments.py new file mode 100644 index 0000000000000000000000000000000000000000..8da764c3ce5587d910d76cd1c16cf7861cc2746d --- /dev/null +++ b/05_example_code_and_data/good_comments.py @@ -0,0 +1,20 @@ +# +# This program sums up two numbers. +# +# Usage: +# * Run it in Python (python.org) +# +# Author: Robert Haase, MPI CBG, +# rhaase@mpi-cbg.de +# April 2019 + +# initialise program +a = 1 +b = 2.5 + +# run complicated algorithm +final_result = a + b + +# print the final result +print( final_result ) + diff --git a/05_example_code_and_data/image_statistics.ijm b/05_example_code_and_data/image_statistics.ijm new file mode 100644 index 0000000000000000000000000000000000000000..e8c5bdff77e6ca3b1f4765d3b2071bafe92b7aa0 --- /dev/null +++ b/05_example_code_and_data/image_statistics.ijm @@ -0,0 +1,13 @@ +// initialise program +imageFilename = "blobs.gif"; +open( imageFilename ); + +// get image statistics +getStatistics(area, mean, min, max, std); + +// show results +print("The grey value ranges from " + min + " to " + max + ". "); +print("It has an average of " + mean + " +- " + std + ". "); + +close(); + diff --git a/05_example_code_and_data/process_folder.ijm b/05_example_code_and_data/process_folder.ijm new file mode 100644 index 0000000000000000000000000000000000000000..61ee0f372f6d3c83b1a65855a732e791e6ad6a98 --- /dev/null +++ b/05_example_code_and_data/process_folder.ijm @@ -0,0 +1,12 @@ +// 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 < list.length; i++) { + filename = list[i]; + + print( filename ); +} diff --git a/05_example_code_and_data/read_image_properties.ijm b/05_example_code_and_data/read_image_properties.ijm new file mode 100644 index 0000000000000000000000000000000000000000..8cb3add0bd00574a0c6a15d520488a324660b431 --- /dev/null +++ b/05_example_code_and_data/read_image_properties.ijm @@ -0,0 +1,15 @@ +// initialise program +imageFilename = "blobs.gif"; +open( imageFilename ); + +// read image properties +width = getWidth(); +height = getHeight(); +getPixelSize(unit, pixelWidth, pixelHeight); + +// show results +print("The image is " + width + " times " + height + " pixels wide"); +print("Each pixels has a size of " + pixelWidth + + " times " + pixelHeight + " " + unit + "^2"); + +close(); diff --git a/05_example_code_and_data/rounding_assay.zip b/05_example_code_and_data/rounding_assay.zip new file mode 100644 index 0000000000000000000000000000000000000000..862c41887961d2d202a9f50259cfdefa3f7fa2da Binary files /dev/null and b/05_example_code_and_data/rounding_assay.zip differ diff --git a/05_example_code_and_data/string_variables.ijm b/05_example_code_and_data/string_variables.ijm new file mode 100644 index 0000000000000000000000000000000000000000..f146acbf9d7c1bfe228d9bdc52246f0ac71d3a95 --- /dev/null +++ b/05_example_code_and_data/string_variables.ijm @@ -0,0 +1,11 @@ + +// initialise program +firstname = "Robert"; +lastname = "Haase"; + +// run complicated algorithm +name = firstname + " " + lastname; + +// show the result +print("Hello " + name + "!"); + diff --git a/05_example_code_and_data/troubleshooting_tracing.ijm b/05_example_code_and_data/troubleshooting_tracing.ijm new file mode 100644 index 0000000000000000000000000000000000000000..ef1f907d60572d56fa37c1e36f6653fbffaa8a2f --- /dev/null +++ b/05_example_code_and_data/troubleshooting_tracing.ijm @@ -0,0 +1,10 @@ +start = 0; +end = 10; + + +// print numbers +for ( i = start; i < end; i++ ) { + if (i > 5) { + print(i); + } +} diff --git a/05_example_code_and_data/variables.ijm b/05_example_code_and_data/variables.ijm new file mode 100644 index 0000000000000000000000000000000000000000..08fc4f90d1fdb150a348e6c1de78cbdfd294f643 --- /dev/null +++ b/05_example_code_and_data/variables.ijm @@ -0,0 +1,10 @@ + +// initialise program +a = 1; +b = 2.5; + +// run complicated algorithm +c = a + b; + +// show the result +print(c); diff --git a/05_example_code_and_data/yin_yang.ijm b/05_example_code_and_data/yin_yang.ijm new file mode 100644 index 0000000000000000000000000000000000000000..352de6d49ec6838edce955ed4b07bbc3b3b7c6a2 --- /dev/null +++ b/05_example_code_and_data/yin_yang.ijm @@ -0,0 +1,21 @@ +// initialise program +a = 5; +b = 3; +c = 8; + +// execute algorithm +d = (a + b) / c; + +// evaluate result +if (b > 0) { + if (a == 5) { + print("Yin"); + } + else { + if (c < 5) { + } + } + if (d != 0) { + print("Yang"); + } +}