<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236020</link>
    <title>MATLAB Central Newsreader - Find gaussian humps in a 3D dataset</title>
    <description>Feed for thread: Find gaussian humps in a 3D dataset</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 15 Sep 2008 11:18:02 -0400</pubDate>
      <title>Find gaussian humps in a 3D dataset</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236020#600354</link>
      <author>Thomas Clark</author>
      <description>Hi all,&lt;br&gt;
&lt;br&gt;
I have a 3D image (scalar intensity field) of particles in a fluid flow. &lt;br&gt;
&lt;br&gt;
There may be many particles (1&amp;lt;N&amp;lt;1000), in a large domain (up to 400^3 voxels)&lt;br&gt;
&lt;br&gt;
Each particle could be approximately represented by a gaussian hump in intensity, surrounding the centre position. Standard deviation of the gaussian might be ~ 2 voxels.&lt;br&gt;
&lt;br&gt;
So the question is, how best to find the positions of the particles? &lt;br&gt;
&lt;br&gt;
I suspect that an optimisation would be very computationally intensive. I can find local maxima very quickly to the accuracy of a single voxel; but I need to get sub-voxel accuracy - perhaps using some kind of polynomial fitting then a derivative-based approach.&lt;br&gt;
&lt;br&gt;
Has anyone got any ideas?&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
Tom Clark</description>
    </item>
    <item>
      <pubDate>Mon, 15 Sep 2008 11:52:02 -0400</pubDate>
      <title>Re: Find gaussian humps in a 3D dataset</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236020#600358</link>
      <author>John D'Errico</author>
      <description>&quot;Thomas Clark&quot; &amp;lt;t.clarkremove_spam@cantab.net&amp;gt; wrote in message &amp;lt;galg9a$995$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi all,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have a 3D image (scalar intensity field) of particles in a fluid flow. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; There may be many particles (1&amp;lt;N&amp;lt;1000), in a large domain (up to 400^3 voxels)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Each particle could be approximately represented by a gaussian hump in intensity, surrounding the centre position. Standard deviation of the gaussian might be ~ 2 voxels.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; So the question is, how best to find the positions of the particles? &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I suspect that an optimisation would be very computationally intensive. I can find local maxima very quickly to the accuracy of a single voxel; but I need to get sub-voxel accuracy - perhaps using some kind of polynomial fitting then a derivative-based approach.&lt;br&gt;
&lt;br&gt;
No. Don't bother with a polynomial model.&lt;br&gt;
&lt;br&gt;
As long as you are willing to assume there&lt;br&gt;
is no near overlap between humps, find the&lt;br&gt;
local peaks, then grab about 5 pixels in each&lt;br&gt;
direction and fit that with a single gaussian&lt;br&gt;
mode. Go on to the next local peak.&lt;br&gt;
&lt;br&gt;
John</description>
    </item>
    <item>
      <pubDate>Mon, 15 Sep 2008 12:01:14 -0400</pubDate>
      <title>Re: Find gaussian humps in a 3D dataset</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236020#600360</link>
      <author>Peter Perkins</author>
      <description>Thomas Clark wrote:&lt;br&gt;
&amp;gt; Hi all,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have a 3D image (scalar intensity field) of particles in a fluid flow. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; There may be many particles (1&amp;lt;N&amp;lt;1000), in a large domain (up to 400^3 voxels)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Each particle could be approximately represented by a gaussian hump in intensity, surrounding the centre position. Standard deviation of the gaussian might be ~ 2 voxels.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; So the question is, how best to find the positions of the particles? &lt;br&gt;
&lt;br&gt;
Tom, it's possible that the GMDISTRIBUTION function in the Statistics Toolbox, which fits a Gaussian mixture distribution, might be helpful.  I don't know enough about your application, though.&lt;br&gt;
&lt;br&gt;
- Peter Perkins&lt;br&gt;
&amp;nbsp;&amp;nbsp;The MathWorks, Inc.</description>
    </item>
    <item>
      <pubDate>Mon, 15 Sep 2008 14:45:04 -0400</pubDate>
      <title>Re: Find gaussian humps in a 3D dataset</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236020#600400</link>
      <author>Thomas Clark</author>
      <description>Thanks to you both. &lt;br&gt;
&lt;br&gt;
John, I did have some fear that the polynomial approach wouldn't work... so thanks for confirming that. It's a shame, because 'windowing' in such a large number of particles could be computationally expensive. We'll see!&lt;br&gt;
&lt;br&gt;
I'll implement both solutions and see which works best. I'll write back to let you know (might be a while, as I have yet to get any experimental data!).&lt;br&gt;
&lt;br&gt;
Kind Regards&lt;br&gt;
&lt;br&gt;
Tom Clark</description>
    </item>
    <item>
      <pubDate>Mon, 15 Sep 2008 20:13:03 -0400</pubDate>
      <title>Re: Find gaussian humps in a 3D dataset</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236020#600472</link>
      <author>Greg Heath</author>
      <description>On Sep 15, 10:45=A0am, &quot;Thomas Clark&quot; &amp;lt;t.clarkremove_s...@cantab.net&amp;gt;&lt;br&gt;
wrote:&lt;br&gt;
&amp;gt; Thanks to you both.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; John, I did have some fear that the polynomial approach wouldn't work... =&lt;br&gt;
so thanks for confirming that. It's a shame, because 'windowing' in such a =&lt;br&gt;
large number of particles could be computationally expensive. We'll see!&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I'll implement both solutions and see which works best. I'll write back t=&lt;br&gt;
o let you know (might be a while, as I have yet to get any experimental dat=&lt;br&gt;
a!).&lt;br&gt;
&lt;br&gt;
I suggest you start with similated data. This is not an easy&lt;br&gt;
problem because of the difficulty of separating overlapping Gaussians.&lt;br&gt;
&lt;br&gt;
Hope this helps.&lt;br&gt;
&lt;br&gt;
Greg</description>
    </item>
    <item>
      <pubDate>Tue, 16 Sep 2008 07:47:23 -0400</pubDate>
      <title>Re: Find gaussian humps in a 3D dataset</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236020#600520</link>
      <author>tristram.scott@ntlworld.com (Tristram Scott)</author>
      <description>Greg Heath &amp;lt;heath@alumni.brown.edu&amp;gt; wrote:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I suggest you start with similated data. This is not an easy&lt;br&gt;
&amp;gt; problem because of the difficulty of separating overlapping Gaussians.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
That certainly seems like a good idea to me.  It might take quite a bit of&lt;br&gt;
practice to tune your methods here. &lt;br&gt;
&lt;br&gt;
An alternative method of detection might be to first normalise your data,&lt;br&gt;
and then attempt to spot deviations from the norm.&lt;br&gt;
&lt;br&gt;
Take your data set and apply a multi-dimensional smoothing to it, like a&lt;br&gt;
moving average, but in higher dimensions.  You can do this quite&lt;br&gt;
efficiently using convolutions, or equivalently using fftn().&lt;br&gt;
&lt;br&gt;
Once you have the smoothed function, subtract it from your original data&lt;br&gt;
set, and you will be left with the deviations from the local average&lt;br&gt;
levels.  Now you can search the whole data set for places where the&lt;br&gt;
deviation from the average is above your threshold level.&lt;br&gt;
&lt;br&gt;
As Greg said, though, the overlapping Gaussians might cause you some &lt;br&gt;
extra troubles.  You may be able to locate these by noticing greater than&lt;br&gt;
expected intensity, indicating there is more than one particle.  I'm not&lt;br&gt;
sure what the best method of fitting would be, though.  It does sound like&lt;br&gt;
a constrained optimisation problem.&lt;br&gt;
&lt;br&gt;
You said that you have maybe 1000 particles.  I take it that you also have&lt;br&gt;
many data sets, not just the one?&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Dr Tristram J. Scott              &lt;br&gt;
Energy Consultant                  </description>
    </item>
    <item>
      <pubDate>Tue, 16 Sep 2008 08:40:04 -0400</pubDate>
      <title>Re: Find gaussian humps in a 3D dataset</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236020#600525</link>
      <author>Thomas Clark</author>
      <description>Greg,&lt;br&gt;
&lt;br&gt;
Thanks, yes, I'll be starting with simulated data (gaussians plus noise).&lt;br&gt;
&lt;br&gt;
One fortunate feature is that particles don't tend to clump together, and of course they can't be in the same place... so any two peaks will occur at least two standard deviations apart. Hopefully that'll help re. overlapping peaks.&lt;br&gt;
&lt;br&gt;
Tristram,&lt;br&gt;
&lt;br&gt;
Thanks for the additional idea, I'd not come across that before. I'll store it away for the future, but not implement that yet... as I see it, I'd still have to make some kind of fit to detect the exact location of the peak (thresholding could only ever give voxel-scale accuracy, rather than sub-voxel).&lt;br&gt;
&lt;br&gt;
And yes, ~1000 particles per frame, ~1000 frames per test, ~100 tests to get a PhD. It'll need to be relatively quick :( !&lt;br&gt;
&lt;br&gt;
Kind Regards&lt;br&gt;
&lt;br&gt;
Tom Clark&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
tristram.scott@ntlworld.com (Tristram Scott) wrote in message &amp;lt;fwJzk.60139$6Y7.42807@newsfe29.ams2&amp;gt;...&lt;br&gt;
&amp;gt; Greg Heath &amp;lt;heath@alumni.brown.edu&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I suggest you start with similated data. This is not an easy&lt;br&gt;
&amp;gt; &amp;gt; problem because of the difficulty of separating overlapping Gaussians.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; That certainly seems like a good idea to me.  It might take quite a bit of&lt;br&gt;
&amp;gt; practice to tune your methods here. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; An alternative method of detection might be to first normalise your data,&lt;br&gt;
&amp;gt; and then attempt to spot deviations from the norm.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Take your data set and apply a multi-dimensional smoothing to it, like a&lt;br&gt;
&amp;gt; moving average, but in higher dimensions.  You can do this quite&lt;br&gt;
&amp;gt; efficiently using convolutions, or equivalently using fftn().&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Once you have the smoothed function, subtract it from your original data&lt;br&gt;
&amp;gt; set, and you will be left with the deviations from the local average&lt;br&gt;
&amp;gt; levels.  Now you can search the whole data set for places where the&lt;br&gt;
&amp;gt; deviation from the average is above your threshold level.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; As Greg said, though, the overlapping Gaussians might cause you some &lt;br&gt;
&amp;gt; extra troubles.  You may be able to locate these by noticing greater than&lt;br&gt;
&amp;gt; expected intensity, indicating there is more than one particle.  I'm not&lt;br&gt;
&amp;gt; sure what the best method of fitting would be, though.  It does sound like&lt;br&gt;
&amp;gt; a constrained optimisation problem.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; You said that you have maybe 1000 particles.  I take it that you also have&lt;br&gt;
&amp;gt; many data sets, not just the one?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; -- &lt;br&gt;
&amp;gt; Dr Tristram J. Scott              &lt;br&gt;
&amp;gt; Energy Consultant                  </description>
    </item>
    <item>
      <pubDate>Tue, 16 Sep 2008 11:53:25 -0400</pubDate>
      <title>Re: Find gaussian humps in a 3D dataset</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236020#600541</link>
      <author>tristram.scott@ntlworld.com (Tristram Scott)</author>
      <description>Thomas Clark &amp;lt;t.clarkremove_spam@cantab.net&amp;gt; wrote:&lt;br&gt;
&amp;gt; One fortunate feature is that particles don't tend to clump together, and&lt;br&gt;
&amp;gt; of course they can't be in the same place... so any two peaks will occur at&lt;br&gt;
&amp;gt; least two standard deviations apart. Hopefully that'll help re. overlapping&lt;br&gt;
&amp;gt; peaks.&lt;br&gt;
&lt;br&gt;
That is very useful.&lt;br&gt;
&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks for the additional idea, I'd not come across that before. I'll&lt;br&gt;
&amp;gt; store it away for the future, but not implement that yet... as I see it,&lt;br&gt;
&amp;gt; I'd still have to make some kind of fit to detect the exact location of the&lt;br&gt;
&amp;gt; peak (thresholding could only ever give voxel-scale accuracy, rather than&lt;br&gt;
&amp;gt; sub-voxel).&lt;br&gt;
&lt;br&gt;
I am assuming that your intensity data can be interpreted as a probability&lt;br&gt;
density function for the Gaussian.  Assuming that is the case, then your&lt;br&gt;
discrete approximation to the PDF should be usable to find the mean by&lt;br&gt;
looking at the moments of the PDF.&lt;br&gt;
&lt;br&gt;
mean = \int (x.p) .dx&lt;br&gt;
&lt;br&gt;
Presumably for a symmetric distribution of intensities you can do this in&lt;br&gt;
each dimensions independently of the others?&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt; And yes, ~1000 particles per frame, ~1000 frames per test, ~100 tests to&lt;br&gt;
&amp;gt; get a PhD. It'll need to be relatively quick :( !&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
Perhaps it is not so much that the process needs to be fast, but rather&lt;br&gt;
that it needs to operate without manual intervention.&lt;br&gt;
&lt;br&gt;
Drop me an email if you want more details on any of my vague ideas.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Dr Tristram J. Scott               &lt;br&gt;
Energy Consultant                  </description>
    </item>
    <item>
      <pubDate>Fri, 10 Oct 2008 15:33:01 -0400</pubDate>
      <title>Re: Find gaussian humps in a 3D dataset</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236020#604659</link>
      <author>Valentin Magidson</author>
      <description>Peter Perkins &amp;lt;Peter.PerkinsRemoveThis@mathworks.com&amp;gt; wrote in message &amp;lt;galiqa$6es$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Thomas Clark wrote:.....&lt;br&gt;
&amp;gt; &amp;gt; I have a 3D image (scalar intensity field) of particles in a fluid flow. .....&lt;br&gt;
&amp;gt; &amp;gt; Each particle could be approximately represented by a gaussian hump in intensity, surrounding the centre position. .....&lt;br&gt;
&amp;gt; &amp;gt; So the question is, how best to find the positions of the particles? &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Tom, it's possible that the GMDISTRIBUTION function in the Statistics Toolbox, which fits a Gaussian mixture distribution, might be helpful.  I don't know enough about your application, though.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; - Peter Perkins&lt;br&gt;
&amp;gt;   The MathWorks, Inc.&lt;br&gt;
Hello,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;I have a question similar to one Thomas Clark asked (above): I have 3D scalar (intensity) field and I have to find particle centers by fitting mixed Gaussian distribution. &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;gmdistribution.fit you suggested seems like good idea except for one problem: the input data are &amp;#8220;events&amp;#8221; or &amp;#8220;hits&amp;#8221; in XYZ space, which have no value. To convert each Xi,Yi,Zi voxel with intensity Ni to this form, I should  add Ni identical [Xi Yi Zi ] rows to the input, to result in a huge matrix. Is there a better workaround or maybe other function similar to gmdistribution.fit but taking scalar data field as input?&lt;br&gt;
&amp;nbsp;&amp;nbsp;</description>
    </item>
    <item>
      <pubDate>Fri, 10 Oct 2008 19:47:35 -0400</pubDate>
      <title>Re: Find gaussian humps in a 3D dataset</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236020#604703</link>
      <author>Peter Perkins</author>
      <description>Valentin Magidson wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt;     I have a question similar to one Thomas Clark asked (above): I have 3D scalar (intensity) field and I have to find particle centers by fitting mixed Gaussian distribution. &lt;br&gt;
&lt;br&gt;
Valentin, it sounds like you're fitting a (hyper)surface in the sense of a regression model, rather than fitting a probability density.  The latter is what gmdistribution is intended for, not the former.  You may want to look into using nlinfit instead, with a model function that is the sum of several Gaussians, but Gaussian distributions.  You may find&lt;br&gt;
&lt;br&gt;
&amp;lt;&lt;a href=&quot;http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/cfitdfitdemo.html&quot;&gt;http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/cfitdfitdemo.html&lt;/a&gt;&amp;gt;&lt;br&gt;
&lt;br&gt;
helpful in that distinction, though it discusses ting in only one dimension. You will likely need to initialize nlinfit with some reasonable starting values for the components.  Such models are notorious for having many bad local minima of the sum of squares surface.&lt;br&gt;
&lt;br&gt;
Hope this helps.&lt;br&gt;
&lt;br&gt;
- Peter Perkins&lt;br&gt;
&amp;nbsp;&amp;nbsp;The MathWorks, Inc.</description>
    </item>
  </channel>
</rss>

