Difference between revisions of "Assignment 4 part 3: Track microspheres over time"

From Course Wiki
Jump to: navigation, search
(Stability of microscope for particle tracking)
Line 91: Line 91:
  
 
{{Template:Assignment Turn In|message=
 
{{Template:Assignment Turn In|message=
 +
'''Individually,'''
 
Turn in the code you developed and a plot of MSD for sum and difference tracks versus time interval.}}
 
Turn in the code you developed and a plot of MSD for sum and difference tracks versus time interval.}}
  

Revision as of 00:13, 25 January 2018

20.309: Biological Instrumentation and Measurement

ImageBar 774.jpg

This is Part 3 of Assignment 4.

Overview

In this part of the assignment, you will develop code to track fluorescent microspheres in a sequence of frames. To characterize the performance of your microscope for particle tracking, you will make a 180 s movie of fixed, 0.84 μm microspheres with your microscope and plot the mean squared displacement of pairs of particles in the movie.

Next week, you will use the same code to characterize the diffusive motion of particles in different rheological environments (including live cells).

Develop particle tracking code

Use the function SimulatedBrownianMotionMovie below to generate a synthetic movie of diffusing microspheres. You can use the synthetic movie and functions you developed in parts 1 and 2 to help you write code that will find centroids of the particles in each frame. Make sure to use the WeightedCentroid property instead of Centroid (and be sure you understand the difference between the two). Your function should return an N x 3 matrix of values where the first column is the Y coordinate, the second column is the X coordinate, and the third column is the frame number.

function SimulatedMovie = SimulatedBrownianMotionMovie( varargin )
    % this is a fancy way to take care of input arguments
    % all of the arguments have default values
    % if you want to change a default value, call this function with name/value pairs like this:
    % foo = SimulatedBrownianMotionMovie( 'NumerOfParticles', 10, 'ParticleDiameter' 3.2E-6 );
    % it's safe to not understand this, if you like.
    p = inputParser();
    p.addParameter( 'NumberOfParticles', 5 );
    p.addParameter( 'ParticleDiameter', 1E-6 );
    p.addParameter( 'PixelSize', 7.4E-6 / 40 );
    p.addParameter( 'ImageSize', [ 300 300 ] );
    p.addParameter( 'FrameInterval', 1/10 );
    p.addParameter( 'TemperatureKelvin', 293 );
    p.addParameter( 'Viscosity', 1.0E-3 );
    p.addParameter( 'BoltzmannConstant', 1.38e-23 );
    p.addParameter( 'NumberOfFrames', 100 );
    p.addParameter( 'ShowImages', true );
    p.parse( varargin{:} );
    
    assignLocalVariable = @( name, value ) assignin( 'caller', name, value );
    allParameters = fields( p.Results );
    
    for ii = 1:numel(allParameters)
        assignLocalVariable( allParameters{ii}, p.Results.(allParameters{ii}) ); 
    end
    % at this point, there will be local scope variables with the names of
    % each of the parameters specified above
    
    close all
    
    diffusionCoefficient = BoltzmannConstant * TemperatureKelvin / ( 3 * pi * Viscosity * ParticleDiameter );
    displacementStandardDeviation = sqrt( diffusionCoefficient * 2 * FrameInterval );
    
    % create initial particle table with random positions
    particleRadiusInPixels = ParticleDiameter / 2 / PixelSize;
    Position = bsxfun( @times, rand( NumberOfParticles, 2 ), ImageSize );
    Radius = particleRadiusInPixels * ones( NumberOfParticles, 1 );
    TotalPhotonNumber = sqrt(2) * particleRadiusInPixels^2 * 4095 * ones( NumberOfParticles, 1 );
    particleTable = table( Position, Radius, TotalPhotonNumber );
    
    SimulatedMovie = zeros( ImageSize(1), ImageSize(2), NumberOfFrames );
    figure
    
    for ii = 1:NumberOfFrames
        ii
        SimulatedMovie(:,:,ii) = SyntheticFluorescentMicrosphereImageWithNoise( particleTable, ImageSize ) / 4095;
        if( ShowImages )
            imshow( SimulatedMovie(:,:,ii) );
            drawnow
        end
        
        % update the particle position according to the diffusion
        
        oldPosition = table2array( particleTable(:, 'Position') );
        Position = oldPosition + displacementStandardDeviation / PixelSize * randn( size( oldPosition ) );
        
        % coefficient
        particleTable(:, 'Position') = table( Position );
    end
end

Once you have your N x 3 matrix, use the track function to add a fourth column to the matrix containing a unique identifier for each particle. The N x 4 matrix is an input to this function for calculating MSD values and diffusion coefficients.

Stability of microscope for particle tracking

Your stability plot should look something like this.

Once you have developed and tested your code, use the following procedure to measure the location precision of your microscope:

  1. Bring a slide with fixed beads into focus.
    • Choose a field of view in which you can see at least 3 beads using the 40× objective.
    • Limit the field of view to only those beads by choosing a region of interest (ROI) in UsefulImageAcquisition tool. (Otherwise, you will have a gigantic movie that is hard to work with.)
  1. Acquire a movie of beads for 3 minutes at a frame rate of at least 10 fps.
  2. Use the code you developed to track the particles and plot MSD versus time interval.

The MSD for the difference trajectory of two fixed particles (why the difference trajectory?) should start out less than 100 nm2 and still be less than 1000 nm2 for t = 180 s. If the MSD is larger than that, refine your apparatus and methodology until you achieve that goal.


Pencil.png

Individually, Turn in the code you developed and a plot of MSD for sum and difference tracks versus time interval.


Navigation

Back to 20.309 Main Page