Quantitative Big Imaging

Kevin Mader (mader@biomed.ee.ethz.ch)
13 March 2014

Advanced Segmentation and Component Labeling

Exercises

Tools for the Exercise

  • Basic Exercises
  • Advanced Exercises
    • Isosurface Function in Matlab
    • MeVisLab available for Windows, Mac, and Linux is medical image processing tool built on top of VTK and ITK

Objectives

  1. Move images easily between Matlab and FIJI for different post-processing steps
  2. Use a tool to simulate data so analysis methods can be tested and verified
  3. Implement automatic thresholding routine
  4. Understand limitations of segmenting and thresholding on real data
  5. Apply K-Means to Color Image Data

Setting up the Computers

Once you have logged in

Open Matlab

Type in the following commands exactly!

This will start Fiji

Setting up the Computers

In Matlab run the following code Copy / Paste from Here

cd('~')
unzip('http://jenkins.imagej.net/job/Stable-Fiji/lastSuccessfulBuild/artifact/fiji-nojre.zip','./')

addpath 'Fiji.app/scripts'
Miji % start Miji
cd('~')
% to test if it works
% Miji_Test

Changing Java Heap

If the Java Heap Space is not high enough strange error messages may appear. Increase the Java Heap Space using the preferences (in this movie)

MIJ (MIJ)

Tools provide an interface between Matlab and FIJI

Pushing Matlab Images to ImageJ

% random 500 x 500 array
imData=rand(500); 
MIJ.createImage('test',imData,true);

Reading Images from FIJI to Matlab

MIJ.run('Embryos (42K)');
imData = MIJ.getCurrentImage;
% take the sum of red, green, and blue
imSum = sum(double(imData(:,:,1)),3); 
subplot(1,2,1)
imagesc(imSum);
subplot(1,2,2);
imagesc(imSum<150)

Cell Exercise

Download the function and save it in your home directory image_generator.m to generate images with varying number of cells(5-1000) illumination (0.5-2) and noise (0-2)

  • Perform a threshold
  • Write a routine to use the IsoData method to calculate the threshold automatically
    • Test the IsoData function with different images
  • As the cell count gets higher the intensity histogram may show multiple peaks, what does this mean?

  • Perform component labeling on the image and count the number of components (hint: the same as the maximum label in the image, \( max(imData(:)) \))

    • Does the maximum value always agree with the input number of cells? If not why?
  • Hints

    Cells in Fiji

    Use FIJI to perform the other automatic threshold techniques (try them all) on the images and discuss which works best for

    • high noise levels
    • varying illumination

    Finally use the 3D object counter and compare the number of cells found with the number Matlab found and the number you put in for the same image.

    Hint: you can load images into fiji using

    curCellIm=image_generator(100,0,255);
    MIJ.createImage('testCellImage1',curCellIm,true);
    

    K-Means Exercise

    We start with the color image of embryos but instead of summing all channels we keep them to use in K-Means analysis. The following code runs k-means on the image for 3 groups.

    MIJ.run('Embryos (42K)');
    imData = double(MIJ.getCurrentImage);
    % raster scan image to 3 , 1D arrays 
    imList=reshape(imData,[],3); 
    %peform k-means
    [groupList,centers]=kmeans(imList,3);
    % reshape into an image
    groupIm=reshape(groupList,size(imData,1),size(imData,2));
    imagesc(groupIm);
    

    K-Means Exercise

    Modify the code so it works with 5 groups, does this make sense?

    Modify the code so the red channel (:,:,1) is valued twice as much as the other (green and blue channels)

    Modify the code so each channel is normalized to its own variance.

    Which produces the best results?

    3D Exercise (Advanced)

    % load the sample image
    MIJ.run('Confocal Series (2.2MB)');
    stackImage = double(MIJ.getCurrentImage);
    % show a slice
    imagesc(stackImage(:,:,25));pause(2);
    % show a histogram of the image
    hist(stackImage(stackImage>0));pause(2);
    % create slices
    xv=yv=[1,200,400];
    zv=[1,25,50];
    slice(stackImage,xv,yv,zv);
    % create isosurface
    isosurface(stackImage,100);pause(2);
    
    1. Show an isosurface for just a region of interest in the image (the first 20 slices)
    2. What does an isosurface represent? How is it similar to a threshold?

    LiveWire Contouring in MeVisLab

    A free tool called MeVisLab offers LiveWire 3D contouring tools which work similar to the Photoshop version with much more flexibility. A tool and sample contour has been provided by David Haberthuer from PSI demonstrating and visualizing this contouring on a human brain image. A video is available here

    Module Reference and CSO Reference