Skip to content

Commit c97945e

Browse files
author
Olivier Burri
committed
adds week 7
1 parent b92331a commit c97945e

File tree

2 files changed

+167
-0
lines changed

2 files changed

+167
-0
lines changed

Week-07/Min_Projection_Use_Case.ijm

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/**
2+
* Minimum Projection Use Case
3+
* ----------------------------------------------
4+
*
5+
* In standard fluorescence imaging, the minimum intensity projection is seldom used
6+
* It is more often used in tomography data where the background is bright and not dark
7+
*
8+
* There are, however interesting use cases where a Minimum Intensity Projection can make sense
9+
*
10+
* Due to the simple nature of this code, no copyright is applicable
11+
*
12+
* The dataset used for this code is a small crop of a dataset under Creative Commons Attribution
13+
* Burri, Olivier, Wolf, Benita, Seitz, Arne, & Gönczy, Pierre. (2017).
14+
* TRACMIT Demo Dataset: http://doi.org/10.5281/zenodo.232218
15+
* Link to Article: https://www.ncbi.nlm.nih.gov/pubmed/28746386
16+
*
17+
* Code created for Image Processing and Analysis For Life Scientists MOOC on EdX
18+
* https://www.edx.org/course/image-processing-and-analysis-for-life-scientists
19+
*
20+
* 2018 - Olivier Burri, EPFL - SV - BIOP
21+
* https://biop.epfl.ch
22+
*/
23+
24+
// This variable defines whether the user sees all the comments appearing as the macro runs.
25+
var show_comments = true;
26+
27+
// Check that the "Trajectories.tif" image is open
28+
if( !isOpen("ASMIT Raw Data Sample.tif") ) {
29+
waitForUser("Please Open ASMIT Raw Data Sample.tif, then press OK.");
30+
} else {
31+
selectImage("ASMIT Raw Data Sample.tif");
32+
if ( getZoom() == 1.0 ) zoomIn();
33+
}
34+
35+
// Some cleanup
36+
close("\\Others");
37+
38+
// Keep the image name for later use
39+
image_name = getTitle();
40+
41+
// This command starts the playing the time series
42+
doCommand("Start Animation");
43+
44+
45+
showComment("This dataset consists of cells undergoing division on L shaped fibronectin patterns." );
46+
showComment("Unfortunately the pattern is on the same channel as the cells.\nBut because it does not move, a Min Projection..." );
47+
48+
49+
// This runs the min projection
50+
run("Z Project...", "projection=[Min Intensity]");
51+
rename("Min - " + image_name);
52+
zoomIn();
53+
min_projection_name = getTitle();
54+
55+
showComment("...Can help us keep ONLY the pattern and not the cells, which are brighter.");
56+
57+
// Subtracting the background
58+
imageCalculator("Subtract create stack", image_name, min_projection_name);
59+
zoomIn();
60+
showComment("Which we can then subtract from the original image to get the cells only");
61+
62+
doCommand("Start Animation");
63+
64+
run("Tile");
65+
showComment("Note that this is not perfect (Bottom left and top right)\n but works well when the cell is highly mobile (Bottom right)");
66+
67+
68+
// ==== Custom functions used above ====
69+
70+
// Convenience function to show comments if the user wishes so, based on the value
71+
// of the global variable "show_comments" (at the top of this script)
72+
function showComment(comment) {
73+
if(show_comments) {
74+
waitForUser(comment);
75+
}
76+
}
77+
78+
// Just a more readable function name that allows us to zoom in the active image
79+
function zoomIn() {
80+
run("In [+]");
81+
}
82+

Week-07/Projection_Methods.ijm

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
* Projection Methods
3+
* ----------------------------------------------
4+
*
5+
* In this short macro we showcase how to call ImageJ's Z Projector with a Macro
6+
* And show an example use case with background subtraction
7+
*
8+
* Due to the simple nature of this code, no copyright is applicable
9+
*
10+
* Code created for Image Processing and Analysis For Life Scientists MOOC on EdX
11+
* https://www.edx.org/course/image-processing-and-analysis-for-life-scientists
12+
*
13+
* 2018 - Olivier Burri, EPFL - SV - BIOP
14+
* https://biop.epfl.ch
15+
*/
16+
17+
// This variable defines whether the user sees all the comments appearing as the macro runs.
18+
var show_comments = false;
19+
20+
// Check that the "Trajectories.tif" image is open
21+
if( !isOpen("Trajectories.tif") ) {
22+
waitForUser("Please Open Trajectories.tif, then press OK.\nThis macro works with any image stack however, results may vary.");
23+
} else {
24+
selectImage("Trajectories.tif");
25+
}
26+
27+
28+
image_name = getTitle();
29+
30+
// Cleaup
31+
close("\\Others");
32+
33+
34+
// ==== Show multiple projection methods ====
35+
36+
// showComment is a custom function defined at the end of the script
37+
showComment("We are going to showcase how to perform different projection methods");
38+
39+
// projectImage is a custom function defined ad the end of the script
40+
projectImage(image_name, "Max Intensity");
41+
42+
// Keep the title, for use later in the code
43+
max_projected_original = getTitle();
44+
45+
showComment("Max Intensity Projection or MIP\nIs very often used and yields dense information with fluorescence data");
46+
47+
projectImage(image_name, "Average Intensity");
48+
showComment("Average Intensity Projection\nYields a 32-bit image with the mean of each x,y pixel along time/depth");
49+
50+
projectImage(image_name, "Sum Slices");
51+
showComment("Sum Slices Projection\nYields a 32-bit image with the sum value of each x,y pixel along time/depth");
52+
53+
54+
// ==== Using a median projection to remove uneven background in a fluorescence image ====
55+
showComment("Let us use the median projection to remove the uneven background");
56+
57+
projectImage(image_name, "Median");
58+
median_image = getTitle();
59+
60+
imageCalculator("Subtract create stack", image_name, median_image);
61+
rename("Median Projection-Subtracted "+image_name);
62+
showComment("You can observe the use of the median filter to clean the background of the image\nWe can compare the result by performing a MIP of the original and subtracted images");
63+
projectImage("Median Projection-Subtracted "+image_name, "Max Intensity");
64+
max_projected_corrected = getTitle();
65+
66+
selectImage(max_projected_original);
67+
showComment("Compare "+max_projected_corrected+"\nand "+max_projected_original);
68+
69+
70+
// ==== Custom functions used above ====
71+
72+
// Convenience function to show comments if the user wishes so, based on the value
73+
// of the global variable "show_comments" (at the top of this script)
74+
function showComment(comment) {
75+
if(show_comments) {
76+
waitForUser(comment);
77+
}
78+
}
79+
80+
// Shortcut to perform the projection on the desired image and rename it accordingly
81+
function projectImage( image, method ) {
82+
selectImage( image );
83+
run("Z Project...", "projection=["+method+"]");
84+
rename(method + " - " + image);
85+
}

0 commit comments

Comments
 (0)