Difference between revisions of "Assignment 5, Part 1: MSD difference tracking and microscope stability"

From Course Wiki
Jump to: navigation, search
m (MSD of Sum and Difference Trajectories)
(Develop sum and difference trajectory code)
Line 20: Line 20:
  
 
Modify your code from Assignment 4 to be able to track the ''sum'' and ''difference'' trajectories of particles in a movie.
 
Modify your code from Assignment 4 to be able to track the ''sum'' and ''difference'' trajectories of particles in a movie.
 +
 +
Steve actually generously shared his code with you!
 +
<pre>
 +
function [ DifferenceTrajectories, SumTrajectories ] = CalculateSumAndDifferenceTrajectories( Trajectories )
 +
 +
  numberOfParticles = max( Trajectories(:,4) );
 +
  allCombinations = nchoosek( 1:numberOfParticles, 2 );
 +
  numberOfCombinations = size( allCombinations, 1 );
 +
 +
  SumTrajectories = cell( numberOfCombinations, 1 );
 +
  DifferenceTrajectories = cell( numberOfCombinations, 1 );
 +
 +
  virtualParticleNumber = 1;
 +
 +
  for ii = 1:numberOfCombinations
 +
    firstParticleIndex = allCombinations( ii, 1 );
 +
    secondParticleIndex = allCombinations( ii, 2 );
 +
    firstTrajectory = Trajectories( Trajectories(:, 4) == firstParticleIndex, : );
 +
    secondTrajectory = Trajectories( Trajectories(:, 4) == secondParticleIndex, : );
 +
 +
    framesInCommon = intersect( firstTrajectory(:, 3), secondTrajectory(:, 3 ) );
 +
 +
    if( ~isempty( framesInCommon ) )
 +
      firstTrajectory = firstTrajectory(ismember(firstTrajectory(:, 3 ), framesInCommon), :);
 +
      secondTrajectory = secondTrajectory(ismember(secondTrajectory(:, 3 ), framesInCommon), :);
 +
      thisDifference = firstTrajectory - secondTrajectory;
 +
      thisDifference(:,3) = framesInCommon';
 +
      thisDifference(:,4) = virtualParticleNumber;
 +
      DifferenceTrajectories{ii} = thisDifference;
 +
      thisSum = firstTrajectory + secondTrajectory;
 +
      thisSum(:,3) = framesInCommon';
 +
      thisSum(:,4) = virtualParticleNumber;
 +
      SumTrajectories{ii} = thisSum;
 +
      virtualParticleNumber = virtualParticleNumber + 1;
 +
    end
 +
  end
 +
 +
  DifferenceTrajectories = vertcat( DifferenceTrajectories{:} );
 +
  SumTrajectories = vertcat( SumTrajectories{:} );
 +
 +
end
 +
</pre>
  
 
==Stability of microscope for particle tracking==
 
==Stability of microscope for particle tracking==

Revision as of 19:45, 12 March 2019

20.309: Biological Instrumentation and Measurement

ImageBar 774.jpg


This is Part 1 of Assignment 5.

Overview

Last week you developed some code to track particles as they jiggled about through frames of a movie. You used this information to measure their mean squared displacement (MSD), which enabled you to calculate their diffusion coefficient and the viscosity of the solution the particles were in. This week, you'll be tracking particles that have been endocytosed into NIH 3T3 cells. Bye eye, the particles will look like they're barely moving at all. How do we know whether our microscope is even capable of measuring such small motions? Could we only be measuring artifacts (like vibrations of the microscope, or drifting of the stage)?

By measuring the MSD of particles that have been glued down to a slide, we can actually diagnose what types of noise sources are contributing to our measurement, and thus what is the actual smallest motion (not due to noise) that we can measure. Some noise sources (like shot noise) are unavoidable, but others, (like mechanical vibrations and drift) we may be able to correct for.

MSD of sum and difference trajectories

When assessing the stability of one's microscope, it is helpful to look at the mean squared displacements (MSDs) of sum trajectories compared to those of difference trajectories.

Given two trajectories $ r_A $ and $ r_B $, the sum trajectory is given by $ r_A(t) + r_B(t) \over \sqrt 2 $, while the difference trajectory is given by $ r_A(t) - r_B(t) \over \sqrt 2 $

Here, we consider trajectory A, with its independent displacement $ \epsilon_A $, and trajectory B, with its independent displacement $ \epsilon_B $. Since these two trajectories come from particles that are glued well to the same slide (the slide you used for your stability measurements), they share the same mechanical noise that comes from vibrations and movements of the microscope stage. We will denote this mechanical noise as $ \epsilon_M $. Thus, the total error, or calculated displacement, from trajectory A would be $ \epsilon_A + \epsilon_M $, while that of trajectory B would similarly be $ \epsilon_B + \epsilon_M $. Note that we define displacement as the change in position over a time interval $ \tau $, as when we are calculating the MSD $ \left \langle {\left | r(t+\tau)-r(t) \right \vert}^2 \right \rangle $ . With this in mind, we can show that the difference between the two types of MSDs turns out to be two times the square of the mechanical noise as demonstrated below.

MSDofSumDiffTrajectories.png

As you can see, measuring the MSD of the difference trajectories for two particles completely cancels out the mechanical noise. We can use the sum trajectories for two particles to diagnose the amount of mechanical noise initially present in your system: the difference between the MSDs of sum and difference trajectories is equal to (twice) the mechanical noise.

Develop sum and difference trajectory code

Modify your code from Assignment 4 to be able to track the sum and difference trajectories of particles in a movie.

Steve actually generously shared his code with you!

function [ DifferenceTrajectories, SumTrajectories ] = CalculateSumAndDifferenceTrajectories( Trajectories )

  numberOfParticles = max( Trajectories(:,4) );
  allCombinations = nchoosek( 1:numberOfParticles, 2 );
  numberOfCombinations = size( allCombinations, 1 );

  SumTrajectories = cell( numberOfCombinations, 1 );
  DifferenceTrajectories = cell( numberOfCombinations, 1 );

  virtualParticleNumber = 1;

  for ii = 1:numberOfCombinations
    firstParticleIndex = allCombinations( ii, 1 );
    secondParticleIndex = allCombinations( ii, 2 );
    firstTrajectory = Trajectories( Trajectories(:, 4) == firstParticleIndex, : );
    secondTrajectory = Trajectories( Trajectories(:, 4) == secondParticleIndex, : );

    framesInCommon = intersect( firstTrajectory(:, 3), secondTrajectory(:, 3 ) );

    if( ~isempty( framesInCommon ) )
      firstTrajectory = firstTrajectory(ismember(firstTrajectory(:, 3 ), framesInCommon), :);
      secondTrajectory = secondTrajectory(ismember(secondTrajectory(:, 3 ), framesInCommon), :);
      thisDifference = firstTrajectory - secondTrajectory;
      thisDifference(:,3) = framesInCommon';
      thisDifference(:,4) = virtualParticleNumber;
      DifferenceTrajectories{ii} = thisDifference;
      thisSum = firstTrajectory + secondTrajectory;
      thisSum(:,3) = framesInCommon';
      thisSum(:,4) = virtualParticleNumber;
      SumTrajectories{ii} = thisSum;
      virtualParticleNumber = virtualParticleNumber + 1;
    end
  end

  DifferenceTrajectories = vertcat( DifferenceTrajectories{:} );
  SumTrajectories = vertcat( SumTrajectories{:} );

end

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.)
  2. Acquire a movie of beads for 3 minutes at a frame rate of at least 10 fps.
  3. Use the code you developed to track the particles, and calculate the sum and difference trajectories.


Pencil.png

Plot the MSD versus time interval of

  1. the sum trajectories, and
  2. the difference trajectories.


The motion of particles endocytosed by 3T3 cells requires an extremely stable microscope, otherwise the real motion of the beads will be obscured by noise. Your microscope will be considered stable enough if the MSD for the difference trajectory of two fixed particles starts out less than 500 nm2 and remains less than 1000 nm2 up to t = 180 s. If the MSD is larger than that, refine your apparatus and methodology until you achieve that goal.



Navigation

Back to 20.309 Main Page