📄 icstutorial.html
字号:
<html xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--This HTML is auto-generated from an M-file.To make changes, update the M-file and republish this document. --> <title>MATLAB ICS Tutorial</title> <meta name="generator" content="MATLAB 7.0.1"> <meta name="date" content="2006-02-27"> <meta name="m-file" content="ICSTutorial"><style>body { background-color: white; margin:10px;}h1 { color: #990000; font-size: x-large;}h2 { color: #990000; font-size: medium;}p.footer { text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray;}pre.codeinput { margin-left: 30px;}span.keyword {color: #0000FF}span.comment {color: #228B22}span.string {color: #A020F0}span.untermstring {color: #B20000}span.syscmd {color: #B28C00}pre.showbuttons { margin-left: 30px; border: solid black 2px; padding: 4px; background: #EBEFF3;}pre.codeoutput { color: gray; font-style: italic;}pre.error { color: red;}/* Make the text shrink to fit narrow windows, but not stretch too far in wide windows. On Gecko-based browsers, the shrink-to-fit doesn't work. */ p,h1,h2,div { /* for MATLAB's browser */ width: 600px; /* for Mozilla, but the "width" tag overrides it anyway */ max-width: 600px; /* for IE */ width:expression(document.body.clientWidth > 620 ? "600px": "auto" );} </style></head> <body> <h1>MATLAB ICS Tutorial</h1> <introduction> <p>February 27, 2006</p> <p>By David Kolin</p> </introduction> <h2>Contents</h2> <div> <ul> <li><a href="#1">INTRODUCTION</a></li> <li><a href="#2">SIMULATOR</a></li> <li><a href="#4">SPATIAL ICS (ICS)</a></li> <li><a href="#14">TEMPORAL ICS (TICS)</a></li> <li><a href="#22">SPATIO-TEMPORAL ICS (STICS)</a></li> <li><a href="#34">IMAGE SERIES IMPORTING AND MANIPULATION</a></li> <li><a href="#35">REFERENCES</a></li> </ul> </div> <h2>INTRODUCTION<a name="1"></a></h2> <p>These notes are meant to serve as a very brief introduction to the accompanying MATLAB image correlation spectroscopy code. They are not intended to be a comprehensive lesson on the underlying theory of ICS, or an introduction to MATLAB. For those details, see the references given at the end of this webpage. </p> <p>The MATLAB code in this tutorial is in a <tt>monospaced font</tt>. It can simply be copied from this page to the command window. All of the ICS .m files in the unzipped directory should be added to the MATLAB path: File --> Set Path... --> Add with Subfolders... You'll need the Optimization and Image Processing Toolboxes to use all of the included .m files. </p> <p>Most of the included ICS .m files have a (small!) help section, which can be called by <tt>'help filename'</tt>. All comments and suggestions are very much appreciated, and can be sent to <a href="mailto:david.kolin@gmail.com">david.kolin@gmail.com</a>. </p> <h2>SIMULATOR<a name="2"></a></h2> <p>A simulation of fluorescently labeled particles imaged on a confocal microscope can be generated using simul8tr.m, which has the following syntax: </p> <p><tt>simulation = simul8tr(sizeX,sizeY,sizeT,density,bleachType,bleachDecay,qYield,pixelsize, timesize,PSFType,PSFSize,PSFZ,noBits,diffCoeff,flowX,flowY,flowZ, countingNoise,backgroundNoise);</tt></p> <p>where:</p> <p><tt>sizeX</tt> and <tt>sizeY</tt> are the dimensions of the simulation, in pixels. </p> <p><tt>density</tt> is the particle density in particles per um^2. </p> <p><tt>bleachType</tt> determines if the fluorophores bleach, and is either <tt>'none'</tt> for no bleaching or <tt>'mono'</tt> for a monoexponential decay in average intensity. </p> <p><tt>bleachDecay</tt> determines how quickly particles bleach. It is the rate constant for the monoexponential bleaching, in the same units at the time step (usually between 0 and 0.05, given 1 Hz imaging rate). </p> <p><tt>qYield</tt> is the quantum yield of the fluorophores (usually 1). </p> <p><tt>pixelsize</tt> is the size of a pixel, in um (usually ~0.1). </p> <p><tt>timesize</tt> is the time between frames, in seconds (usually ~1). </p> <p><tt>PSFType</tt> gives the shape of the point spread function of the imaging system. It is either <tt>'g'</tt> for a 2D Gaussian, or <tt>'a'</tt> for an airy disk. </p> <p><tt>PSFSize</tt> is the e^-2 radius, in um, for a Gaussian PSF, or the distance to the first zero of the airy disk, in um. </p> <p><tt>PSFZ</tt> is the size, in um, for the Z dimension of the PSF. For 2D simulations, set this to 0. The PSF in Z is always a Gaussian, regardless of <tt>PSFType</tt>. </p> <p><tt>noBits</tt> is the number of bits used in the image normalization, imitating a A/D converter (usually 12). </p> <p><tt>diffCoeff</tt> is the diffusion coefficient, in um^2/s. </p> <p><tt>flowX</tt>, <tt>flowY</tt>, and <tt>flowZ</tt> are the flow speeds in each of the directions, in um/s. </p> <p><tt>countingNoise</tt> is the noise associated with the PMT amplification electronics (see the August 2005 Costantino BJ paper for details). Usually between 1 and 20. </p> <p><tt>backgroundNoise</tt> is the noise associated with spurious background counts (see the same paper). Usually between 0 and 0.3. </p> <p>As an example, let's create a simulated image series with the following characteristics: 256 x 256 pixels with 100 images, 10 particles per um^2, 1 s per image, 0.1 um/pixel, particles with a quantum yield of 1, a Gaussian convolving function with an e^-2 radius of 0.4 um, with particles diffusing at 0.01 um^2/s, and no noise </p><pre class="codeinput">imageSeriesDiff = simul8tr(256,256,100,10,<span class="string">'none'</span>,0,1,0.1,1,<span class="string">'g'</span>,0.4,0,12,0.01,0,0,0,0,0);</pre><p>The first image in the series should look something like this:</p><pre class="codeinput">imagesc(imageSeriesDiff(:,:,1))axis <span class="string">image</span>colormap(gray)</pre><img vspace="5" hspace="5" src="ICSTutorial_01.png"> <h2>SPATIAL ICS (ICS)<a name="4"></a></h2> <p>We can determine number densities and aggregation states using ICS. First, we calculate a 2D spatial autocorrelation function (SACF) for each image in the simulation which we created earlier: </p><pre class="codeinput">ICS2DCorr = corrfunc(imageSeriesDiff);</pre><p>The SACF of an image should be a 2D Gaussian. We can view the SACF for first image:</p><pre class="codeinput">s=surf(ICS2DCorr(:,:,1));axis <span class="string">tight</span>colormap(jet)xlabel(<span class="string">'\eta'</span>,<span class="string">'FontSize'</span>,12)ylabel(<span class="string">'\xi'</span>,<span class="string">'FontSize'</span>,12)zlabel(<span class="string">'r(\xi,\eta)'</span>,<span class="string">'FontSize'</span>,12)set(s,<span class="string">'LineStyle'</span>,<span class="string">'none'</span>)title(<span class="string">'Spatial Autocorrelation Function for First Image'</span>)</pre><img vspace="5" hspace="5" src="ICSTutorial_02.png"> <p>Next, we crop the stack of SACFs around the central peak, since the fitting algorithms work better when the noise at higher spatial lags is removed. </p><pre class="codeinput">ICS2DCorrCrop = autocrop(ICS2DCorr,12);</pre><p>As an example, let's look at the SACF of the first image to see how much was cropped:</p><pre class="codeinput">s=surf(ICS2DCorrCrop(:,:,1));axis <span class="string">tight</span>colormap(jet)xlabel(<span class="string">'\eta'</span>,<span class="string">'FontSize'</span>,12)ylabel(<span class="string">'\xi'</span>,<span class="string">'FontSize'</span>,12)zlabel(<span class="string">'r(\xi,\eta)'</span>,<span class="string">'FontSize'</span>,12)set(s,<span class="string">'LineStyle'</span>,<span class="string">'none'</span>)title(<span class="string">'Cropped Spatial Autocorrelation Function for First Image'</span>)</pre><img vspace="5" hspace="5" src="ICSTutorial_03.png"> <p>These cropped SACFs are fit to a 2D Gaussian:</p> <p><img vspace="5" hspace="5" src="ICSTutorial_eq441477.png"> </p> <p>which can be accomplished by:</p><pre class="codeinput">a = gaussfit(ICS2DCorrCrop,<span class="string">'2d'</span>,0.1,<span class="string">'n'</span>);</pre><p>returing the fit parameters in <tt>a</tt>. Recall that 0.1 is the pixel size set in the simulation above, and the <tt>'n'</tt> refers to no whitenoise (there would be whitenoise with real data). We can now plot the fitted Gaussian as well as the raw correlation function for the first image: </p><pre class="codeinput">plotgaussfit(a(1,1:6),ICS2DCorrCrop(:,:,1),0.1,<span class="string">'n'</span>)</pre><img vspace="5" hspace="5" src="ICSTutorial_04.png"> <p>Finally, we can calculate the average cluster density using the amplitudes of the fitted Gaussians:</p><pre class="codeinput">particlesPerBeamArea = 1/(mean(a(:,1)))beamArea = pi*mean(a(:,2))*mean(a(:,3))density = particlesPerBeamArea/beamArea</pre><pre class="codeoutput">particlesPerBeamArea = 4.9948beamArea = 0.5091density = 9.8104</pre><p><tt>density</tt> should be close to the 10 particles/um^2 which we set in the simulation. </p> <h2>TEMPORAL ICS (TICS)<a name="14"></a></h2> <p>We can extract diffusion coefficients and flow rates using TICS. First, we calculate the temporal autocorrelation function (TACF) for our diffusion simulation, given 1 second time sampling </p><pre class="codeinput">GtDiff = tics(imageSeriesDiff,1);</pre><p>For samples undergoing 2D diffusion, the TACF has the following analytical form:</p> <p><img vspace="5" hspace="5" src="ICSTutorial_eq516464.png"> </p> <p>Let's fit the first 20 lags of the temporal autocorrelation function to the 2D diffusion model</p><pre class="codeinput">diffCoeff = difffit(GtDiff(1:20,1),GtDiff(1:20,2));</pre><pre class="codeoutput">Optimization terminated: relative function value changing by less than OPTIONS.TolFun.</pre><img vspace="5" hspace="5" src="ICSTutorial_05.png"> <p>The diffusion coefficient can be calculated from the fitted parameter in <tt>diffCoeff</tt> and the beam waist of the laser: </p> <p><img vspace="5" hspace="5" src="ICSTutorial_eq60534.png"> </p> <p>Or, in MATLAB:</p><pre class="codeinput">w = mean(a(:,2))D = w^2/(4*diffCoeff(2))</pre><pre class="codeoutput">w = 0.4062D =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -