image analysis basics using imagej/fiji - squarespace · 2nd bit of talk - introduction to imagej...
TRANSCRIPT
MRC Institute of Genetics & Molecular Medicine at the University of Edinburgh
www.ed.ac.uk/igmm
Image analysis basics using ImageJ/FIJI
Laura Murphy10th May 2017
What we’ll cover today
1st bit of talk - Basics of digital images
Pixels, bit depth, histograms and LUTs
2nd bit of talk - Introduction to ImageJ and FIJI
Tour of GUI
Opening your images
Changing display of your image
3rd bit of talk – Simple image analysis tasks
Thresholding
Measuring/ analyse particles
Batch processing simple tasks (intro to macro writing)
Using scripts provided by the facility
Any FIJI commands used on a slide will be listed at the bottom of said slide with “>” separating each menu option
Your pretty picture is really just a set of numbers.
0 0 0 0 0 0 0
0 0 0 120 0 0 0
0 0 100 130 120 0 0
0 100 255 255 255 255 0
0 90 255 255 255 255 0
0 88 255 255 255 255 0
0 0 110 255 255 0 0
0 0 0 90 0 0 0
0 0 0 0 0 0 0
The beauty is IN the numbers!
Where do the numbers come from?
Light given off by your sample is picked up each grid point of the camera and an intensity value is stored for each position in your field of view
This is dependent on how much light there is hitting each point of the camera (how strong your signal is there)
Saturated
Light from sample
Pixels?
Pretty images are patterns of numbers representing light intensities
Think of your images as data(pixel values) and display(the coloured squares that make up your image)
Each channel (or time point or Z-position) you captured with is a separate collection of pixel values
Bit Depth?
Pixels can’t have ANY numerical value. It is constrained by “bit-depth”.
This is essentially sensitivity of the camera to different levels of light – how many gray scales!
Each pixel can carry from 1 to 32-bits
For a 8-bit (monochrome) camera each pixel has a possible 256 greyscale values
Pure black = 0
Pure white = 255 (saturation)
For a normal 14-bit (most of the epifluorescence microscopes here)
Pure black = 0
Pure white = 16,384 (saturation)
8-bit 14-bit
Histograms?
It is often useful to consider the range of intensity values within your image which we can see on a histogram
X-axis is the intensity values from 0 -> 255 (8-bit)
0 = black, 255= white and the rest is the grayscale values in-between.
Y-axis the number of pixels in each of those tones
Big peak is the dark background of the image
Don’t lose your data
In general, more bit depth is better. You want all that information when you are analyzing.
Additionally some file formats (e.g. JPEG), squish these numbers to make a smaller file size. This is irreversible so don’t use these file formats.
These are referred to as “lossy” – we want “lossless”.
TIFFs are a lossless file format.
Take away message while analysing leave bit depth alone and keep things as TIFFs
Numbers to colourful images
But I don’t like looking at grey images!
Warning: before you start your experiment!
When you are planning your experiment, you should already have planned how to analyse it.
For true comparison, all settings at the time of imaging need to be the same (i.e. your exposure times between slides).
Additionally, sample preparation needs to be the same!
Need appropriate controls – positive AND negative.
Are you using the correct microscope to answer your scientific question?
If in doubt -> speak to the imaging staff ([email protected])
Why ImageJ/FIJI?
• Image analysis software that understand most image formats.
• Provides a Graphical User Interface with robust functionalities.
• Platform independent.• Open-source so free
Extensible via plugins.• Active community (can
find a solution for most scenarios).
Tour
Fiji Is Just ImageJ
Menu bar
Tool bar
Status bar
<Tip: hover over image and the status bar will return X,Y co-ordinates and pixel value>
Additional windows will pop for other things – images, histograms, line profiles.
Opening a file in FIJI
File > Open
Or Drag and drop the file on to the tool bar.
Different dimensions such as channels or time points or Z positions can be accessed by moving the slider bar at the bottom of the open image
Any commands you do will be performed on the “active” window or slice
Open “S-Shaped nephron.tif” by drag and drop or by finding it in the dialogue box when you go to File > OpenGo to Image > Show Info to see the metadata FIJI reads about your imageGo to Image > Type to see the bit-type
Brightness and contrast
Contrast and brightness can be used to ease the viewing of your image. In FIJI if you use the sliders to adjust the contrast and brightness you will see the minimum and maximum settings change.
Auto – FIJI optimises brightness and contrast for your image
Reset makes sure Minimum and Maximum match with the actual minimum and maximum pixel values in the image (or 0 and 255 for an 8-bit image)
Set allows you to input their values manually
NEVER PRESS APPLY – this DOES change your underlying numbers
Change the brightness and contrast of the image –Image> Adjust > Brightness/ContrastShortcut (on windows) = Ctrl+Shift+C
Other basic functions
Crop Use tool bar to make a
shape and then Image > Crop
Split channels Image > Colour > Split
channels
Merge channels Image > Colour > Merge
channels
Look up tables Image > Lookup tables
Duplicate Image > Duplicate..
Selection of the LUTs available
Other basic functions
Z- projection (e.g. Max) Image > Stacks > Z-
Project
Histogram! Analyze > Histogram
Plot profile Draw a line using this icon
on tool bar and then go to Analyze > Plot profile
Now to start analysing…
What is binarization and why do I want to do it?
As the word suggests, binarization divides your image into two parts usually referred to as foreground and background. This is the simplest method of image segmentation
The simplest method is to set one or two (upper and lower) cut-off value(s) separating specific pixel intensities from each other.
This is referred to as a threshold
Thresholding
Different thresholding algorithms in drop-down menu. Good option is Otsu – chooses the
threshold to minimize the intraclass variance of the thresholded black and white pixels.
Can manually adjust it using the sliders, BUT should you?
Manual vs. automatic thresholding
Manual
high user bias
time-consuming fiddling-around finding "appropriate" cut-off value
incompatibility with automatic processing
high intra- and inter-user variability
Automated
fully reproducible (on the same image they will always lead to the same binarization result)
no user bias during thresholding
fast (no fiddling) and can be automated (e.g., in macros, plugins, batch jobs – back to that later)
So automated thresholding is better but which one should I use?
16 different thresholding algorithms come as standard
Can try them all and see which one works best for your images.
Image> Adjust > Auto ThresholdSet drop down menu to “Try all” and press okay
None of the thresholding options work to segment my objects of interest!
Process> Filter > Gaussian Blur
Process> Binary >Watershed
Measuring what has been thresholded
File > Open samples > Blobs (set a threshold)Analyze > Set measurementsAnalyze > Measure
Analyse particles
File > Open samples > Blobs (set a threshold)Analyze > Analyze particles (also subject to set measurements options)
Batch processor
FIJI has an in-built batch processor
Allows you to select an input directory (make this a folder containing only your images) and an output directory (make this a different folder)
Process > Batch > Macro..
Macro recorder
Plugins > Macros > Record…
Records what you are doing in the macro language
Menu commands I used here:Image > Adjust > Threshold (Otsu)Analyse > Set measurementsAnalyse > Measure This was all recorded in the macro recorder
Macro commands I use the most (which the macro recorder won’t give me)
getTitle()
E.g. imgname=getTitle()
selectWindow()
Example use
Want to select one channel in your image
imgname=getTitle()
run (“Split Channels”)
selectWindow("C1-"+imgName);
Using already-made scripts from the facility
We store scripts written by the facility on our Githubhttps://github.com/IGMM-AIR/
You can get there via the “Bioimage Analysis section on the facility website: http://www.igmm-imaging.com
On the page you should see a link entitled “scripts and macros”
Okay, so I have a script. What do I do with it?
Drag and drop file (.ijm) on to FIJI window to open Macro tool dialogue
Plugins > new > macro
Copy and paste (or to try and write your own!)
Run button at the bottom of window.
Lines of commands preceded with “//” indicates comments or notes
Tips, tricks and oddities
Know the name of the command but not where it is in the menu? CTRL+L to see (and search) list of commands
Undo is very limited in FIJI so don’t rely on having it. (can sometimes use File>Revert but good to get into habit of Image>Duplicate before you start making changes)
Shortcuts (and create own in plugins-> shortcuts)
Space bar for grabber (little hand symbol)
There’s too many windows and I’ve lost the main window! – Press Enter key on keyboard
Can use the batch processor as a batch file format changer (e.g. ND2 files to TIFFs)
Finally…
The facility staff are here to help BUT the website has a lot of information that might answer your question.
If you have stuff that you think could be added to the website, let me know.
For Loops
You have a box with 10 toys in it, and you want to take all of them out of the box.
You start the count of toys removed from the box at 0, and you keep taking toys out of the box until you have 10 of them. That looks like this:
for (toys removed = 0; toys removed < 10; toys removed ++)
{
remove toy from box
}
The ++ after toys removed signifies that it increases by 1 after each time through the loop. The {} contain the loop (commands)
Batch processer as a macro