Introduction to BioImage Analysis using Fiji CellNetworks Math-Clinic core facility Qi Gao Carlo A. Beretta 12.05.2017
Math-Clinic core facility Data analysis services on bioinformatics & bioimage analysis: 1-to-1 consultancies research collaboration courses and workshops internship, MSc/BSc thesis Room 001, BioQuant (INF 267) +49 (0)6221 54 51435 math-clinic@bioquant.uni-heidelberg.de http://math-clinic.bioquant.uni-heidelberg.de/
Agenda Introduction to BioImage Analysis using Fiji 9:00-10:30 Getting to know digital images using Fiji Qi Gao 10:30-11:00 Coffee break 11:00-12:30 Basic bioimage analysis methods Qi Gao 12:30-13:30 Lunch break 13:30-15:00 Automating image analysis (ImageJ Macro) I Carlo Beretta 15:00-15:30 Coffee break 15:30-17:00 Automating image analysis (ImageJ Macro) II Carlo Beretta
Getting to know digital images using Fiji
with slides and figures from Peter Bankhead Kota Miura Chong Zhang Daniel White
1.1 Digital images which are digital images?
Images are composed of pixels each pixel corresponds to a number brighter region - more photons - larger pixel value an image is usually display based on grey scale [figure by PB] 0 255
A pixel is NOT a little square!!! A pixel is a point sample. It exists only at a point. It generally lies on a grid pattern. X X X X X X X X X = 0 1 0 0 0 0 1 0 1 [DW]
Look-Up Table (LUT) pixels representing color is determined by the LUT [figure by PB] 0 255
Look-Up Table (LUT) pixels representing color is determined by the LUT changing the LUT won t affect pixel values [figure by PB] 0 255
The numbers contain all information of an image an image can be displayed arbitrarily what we really care in image analysis are the numbers (pixel values) [figure by PB] 0 255
Do not trust your eyes! What I think I see What is actually there Green and yellow circles? A and B: which is brighter?
Fiji is just imagej The main window [DW]
Fiji is just imagej Overview of the menus Help, Links Selection/ROI handling File input/output Image filters Statistics Visualization parameters Windows Plugins, Macros and Utilities [DW]
Fiji is just imagej The status bar (message & progress) Shows information about long-running processes. Clicking in the status bar shows information about memory consumption. [DW]
Set up memory
Install plugins download the ImageJ plugin files (xxx.jar) put the files (xxx.jar) in the plugins folder of Fiji (ImageJ) without unzip it restart Fiji (ImageJ)
Check updates Check Update Status: [Help > Update ] After confirming to be up-to-date, Click Manage Update Sites : to add optional plugins [KM]
Open an image, check the pixel values 1. [File -> Open -> Cell_Colony.tif] width x height (0,0) x y
Tip: press L to use the Command Finder memorise the menu? not necessary!
Check and change the LUT 1. [File -> Open -> Cell_Colony.tif] 2. [Image -> Color -> Show LUT] 3. Change the LUT by [Image -> Lookup Tables -> Spectrum] 4. Check the LUT again by [Image -> Color -> Show LUT] 5. [Image -> Color -> Display LUTs] Do the pixel values also change? [KM]
Image depth measured intensity by detector [digitization] corresponding level in image digital intensity resolution: 10 9 real analogue intensities digital intensity resolution: 20 19 0 0 [DW]
Bit-depth determines the dynamic range of image pixel values 1bit: 2 1 = 2 steps (segmentation) 2bit: 2 2 = 4 steps 4bit: 2 4 = 16 steps 8bit: 2 8 = 256 steps 16bit: 2 16 = 65,536 steps 32bit: 2 32 = 4,294,967,296 steps (~ limit of human eye) (intensity-based measurements) Images can contain far more different pixel values than our eyes can distinguish!
Image bit-depth A higher bit-depth allows pixels to have more different values 8 bit (256 values) 4 bit (16 values) 2 bit (4 values) 1 bit (2 values) [PB]
Reducing bit-depth will lose information data scaling: pixel values are rescaled and rounded to the nearest valid integer 16-bit image 2 16 = 65536 values 8-bit image 2 8 = 256 values Values changed by rounding [PB]
Choosing bit-depth during image acquisition Exciting, high-risk method Use the minimum bit-depth that gives the accuracy you need Safer method Use the maximum bit-depth you can (but that doesn t make the computer crash) [PB]
Convert bit-depth 16bit 8bit with scaling 1. [File -> Open -> m51.tif] then line of selection tools 2. [Analyze -> Plot Profile..] 3. [Edit -> Option -> Conversion] (ON!) 4. [Image -> Type -> 8-bit] 5. [Analyze -> Plot Profile..] without scaling 1. [File -> Open -> m51.tif] [Edit -> Selection -> Restore..] 2. [Edit -> Option -> Conversion] (OFF!) 3. [Image -> Type -> 8-bit] 4. [Analyze -> Plot Profile..] [KM]
Image dimension image can be multi-dimensional x, y, z coordinate color channel time point 2D: x-y 4D: x-y-z-ch 3D: x-y-ch [figure by PB]
ImageJ makes it (relatively) straightforward to work with images that have up to 5 dimensions Colour channels Time point z-slice [PB]
Stack basics Open listeriacells.stk. [Start Animation] [Stop Animation] [Animation Options] [KM]
Orthogonal view Open mitosis_anaphase_3d.tif [Image > Stacks > Orthogonal Views] Interactive Reslice. Drag the crossing lines. [KM]
3D viewer Open mitosis_anaphase_3d.tif [Plugins > 3D Viewer] rotate and zoom (wheel)! pan: shift-drag [KM]
Color image type composite RGB data from the microscope converted after acquisition # channels any 3 bit-depth any for each channel 8-bit for each channels adaptability special scientific softwares appearance varies most softwares appearance consistent
When converting a composite image to RGB, information is usually lost Convert to RGB Composite RGB 16-bit channels 8-bit channels [PB]
When converting a composite image to RGB, information is usually lost Convert to RGB Composite RGB 16-bit channels 8-bit channels [PB]
RGB image for analysis unless you are really really really sure you have not lost vital information for display journal figures, websites, presentations [PB]
RGB image 1. Open FluorescentCells.tif 2. [Image -> Type -> RGB Color] what is different than the original? 3. [Image -> Color -> Split Channels] [CZ]
Composite image Merge 3 frames [Image -> Color -> Merge Channels ]. [CZ]
Composite image Composite: you could process individual channels. -- Do [Image -> Color -> Channel Tool ] and try unchecking some channels! [KM]
Image format image image file contains 2 parts header: the metadata (data about data) image data: numbers (pixel values) ics_version 1.0 filename 3a-z-stack (cropped) layout parameters 6 layout order bits x y z channels t layout sizes 16 243 236 68 2 1 parameter units relative um um um undefined s parameter scale 1 0.082 0.082 0.15 1 0.03 sensor model Hamamatsu C9100-50 448, 462, 438, 447, 442, 451, 480, 467, 467, 440, 447, 461, 482, 493, 432, 490, 445, 459, 473, 455, 443, 443, 430, 457, 423, 442, 469, 437, 422, 438, 461, 455, 447, 446, 458, 446, 441, 477, 470, 452, 449, 461, 446, 472, 452, 461, 454, 471, 462, 464, 456, 434, 440, 446, 463, 438, 449, 483, 473, 470, 442, 438, 472, 464, 450, 454, 453, 445, 469, 441, 434, 459, 435, 465, 454, 433, 459, 427, 445, 457, 434, 424, 467, 444, 467, 458, 445, 455, 454, 436, 489, 427, 433, 466, 474, 461, 458, 449, 458, 467, 456, 464, 487, 496, 463, 453, 460, 465, 456, 464, 448, 458, 455, 476, 494, 444, 491, 420, 478, 451, 468, 465, 467, 456, 450, 460, 450, 496, 430, 486, 481, 468, 453, 477, 458, 470, 436, 476, 446, 471, 455, 440, 454, 462, 466, 463, 459, 446, 441, [figure by PB]
Image format in some formats, image data is compressed lossy compression may make the image no longer suitable for quantitative analysis original filtered original jpeg compressed filtered compressed [PB]
Metadata [open > mitosis.tif] [image -> show info ] [image -> properties ] [figure by PB]
Image format always keep your original files and metadata avoid using lossy compression (eg, jpeg format) save your images using tiff format
Draw scale bar 1. [Open > hela-cell.tif] 2. [Analysis > Tools > Scale Bar] 3. Click OK! [KM]
Sometimes there is no scale information
Adding real world scale 1. [open -> micrometer.jpg] 2. Draw line between large bars. (50µm). 3. [Analysis > Set Scale ] known distance: 50. Unit of length: µm 4. Click OK [KM]
1.2 Image quality good quality of images always benefit analysis images need not only proper storage high bit-depth multi-channel lossless file format but also proper acquisition high resolution low noise and blur properly distributed pixel values fast acquisition
Pixel size how big a structure in my image? = how big is a pixel? a pixel is a sample of intensity of a point in space pixel size is pixel spacing distance not the imaginary pixel edge length y x Yes! A pixel is NOT a little square!!! No! [DW]
Resolution / pixel size # of pixels in unit length Pixel size = 64.2 µm / 600 = 0.107 µm 64.2 µm 600 px [figure by PB]
Resolution / pixel size # of pixels in unit length resolution affects spatial information Pixel size = 64.2 µm / 75 = 0.856 µm 64.2 µm 75 px [figure by PB]
Higher resolution, more details 4 x 4 pixels 16 x 16 pixels 512 x 512 pixels 64 x 64 pixels 256 x 256 pixels [PB]
128 x 128 pixels 256 x 256 pixels 512 x 512 pixels 1024 x 1024 pixels But increasing resolution doesn t add more details indefinitely 8 x 8 pixels 16 x 16 pixels 32 x 32 pixels 64 x 64 pixels
Why? An image we can record is the result of replacing each point with a corresponding PSF Point PSF [PB]
Why? An image we can record is the result of replacing each point with a corresponding PSF Point PSF [PB]
Noise adds randomness to the pixel values 2 main sources of noise in fluorescence microscopy photon noise - from the random emission of photons read noise - from sources in the detector (microscope) detecting more light helps to overcome both noise 1 10 100 1000 exposure time (ms) [PB]
Extra light can be obtained with costs longer exposure time loses temporal information beware of over-exposure increase the pixel size loses spatial information [PB]
Understanding histograms Find the corresponding histograms! 1. Open images 2D_Gel.tif and gel_inv.tif 2. Do [Analyze -> histogram] 3. Compare the pixel value in the image and the histogram.
under-/over-exposure occur when storing values too low/high for the bit-depth don t know what happens in the darkest/brightest regions
Which image is better? a wider and evener distributed histogram means more details stored and good contrast
1.3 ROI (region of interest) & measurements selection tools Oval Polygon Freehand Rectangular Rounded rectangle Elliptical Line Segmented Freehand Brush Arrow
ROI Open any image and then Cropping. [image -> Crop]. Masking. Select a region by rectangular ROI. [Edit -> Clear outside]. [Edit -> Fill]. ( same as [Edit -> Selection -> Create Mask]) Invert ROI. [Edit -> Selection -> Make Inverse]. Redirecting ROI. Open any two images. In one of the image, select a region by rectangular ROI. Then activate the other image [Edit -> Selection -> Restore Selection]. ROI manager. [Analysis -> Tools -> Roi Manager]. Click Add button to store ROI information. Stored ROI can be saved as a file, and could be loaded again when you restart the ImageJ. [KM]
Intensity measurements 1. [Analyze -> Set measurements] 2. Open cells_actin.tif 3. Use Polygon ROI and select a cell. 4. [Analyze -> Measure] 5. Measure also the background. Measure Background as well Intensity = Cell - Background [KM]
Intensity measurements 1. [Analyze > Tools > ROI manager] 2. Open [cells_actin.tif] zoom up! ( + key) 3. Use Polygon ROI and select a cell. 4. In ROI manager, click Add. 5. Use Rectangular ROI and select background. 3. In ROI manager, click Add. Measure Background as well 7. Click Measure! Intensity = Cell - Background [KM]
Creating tricky ROIs Marking a whole cell in hela-cell.tif, excluding the nucleus Draw 2 ROIs & add to the ROI Manager (press t) a polygon around the cell an ellipse around the nucleus under More >>, remove the nucleus ROI from the cell ROI, using XOR [Edit -> Selection -> Create Mask] [CZ]
Combination of ROIs (binary images) roi1 roi2 AND OR XOR exclusive or