<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>That's Funny... &#187; science microscopy viruses</title>
	<atom:link href="http://staff.washington.edu/rec3141/wordpress/archives/tag/science-microscopy-viruses/feed" rel="self" type="application/rss+xml" />
	<link>http://staff.washington.edu/rec3141</link>
	<description>the website of Eric Collins, grad student</description>
	<lastBuildDate>Wed, 11 Nov 2009 18:25:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Automated bacteria or virus counts in ImageJ</title>
		<link>http://staff.washington.edu/rec3141/wordpress/archives/505</link>
		<comments>http://staff.washington.edu/rec3141/wordpress/archives/505#comments</comments>
		<pubDate>Tue, 29 Sep 2009 01:36:03 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[none]]></category>
		<category><![CDATA[science microscopy viruses]]></category>

		<guid isPermaLink="false">http://staff.washington.edu/rec3141/wordpress/archives/505</guid>
		<description><![CDATA[THIS IS EXPERIMENTAL, UNPUBLISHED SOFTWARE. USE AT YOUR OWN RISK.
I&#8217;ve written a free, open source script for ImageJ (free, open source) to count viruses (or bacteria, but not both at the same time) automatically from JPEG image files. If you have TIFFs you can batch convert them to JPEG using ImageMagick (free, open source) with [...]]]></description>
			<content:encoded><![CDATA[<p>THIS IS EXPERIMENTAL, UNPUBLISHED SOFTWARE. USE AT YOUR OWN RISK.</p>
<p>I&#8217;ve written a free, open source script for <a href="http://rsbweb.nih.gov/ij/">ImageJ (free, open source)</a> to count viruses (or bacteria, but not both at the same time) automatically from JPEG image files. If you have TIFFs you can batch convert them to JPEG using <a href="http://www.imagemagick.org/">ImageMagick (free, open source)</a> with the following command:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mogrify <span style="color: #660033;">-format</span> jpg <span style="color: #000000; font-weight: bold;">*</span>.tif</div></div>
<p>You can download the script here as a text file (<a href='http://staff.washington.edu/rec3141/wordpress/wp-content/uploads/2009/03/JVirusCount.txt'>JVirusCount</a>), or the full source is written below. Opened in ImageJ (after opening any image in the desired directory), it will iteratively adjust the noise threshold and use the &#8220;Find Maxima&#8221; command to count the number of dots in every image file in the desired directory. </p>
<div id="attachment_668" class="wp-caption aligncenter" style="width: 310px"><a href="http://staff.washington.edu/rec3141/wordpress/wp-content/uploads/2009/03/20071213-4-51.jpg"><img src="http://staff.washington.edu/rec3141/wordpress/wp-content/uploads/2009/03/20071213-4-51-300x240.jpg" alt="20071213-4-5" title="20071213-4-5" width="300" height="240" class="size-medium wp-image-668" /></a><p class="wp-caption-text">viruses in Arctic seawater</p></div>
<p>The output of the script is a tab-delimited text file for each image summarizing the number of dots detected at each threshold, which can be input into a <a href="http://www.mathworks.com">Matlab (not free, closed source)</a> script (<a href='http://staff.washington.edu/rec3141/wordpress/wp-content/uploads/2009/03/MVirusCount.m'>MVirusCount</a>) using an external function, <a href="http://staff.washington.edu/aganse/mpregression/mpregression.html">regress2lines (free, open source)</a>. I haven&#8217;t tried using it with <a href="http://www.gnu.org/software/octave/">Octave (free, open source)</a> but if you get it to work let me know. What I&#8217;ve found is that there is a significant change in the slope of this curve during the transition from measuring &#8216;noise&#8217; to &#8216;particles&#8217;, but that it depends on the quality, brightness, and contrast of the image; MVirusCount determines the intersection of those two lines and the abundance of dots at that point. A program finding the maximum of the first derivative of the curve would likely work just as well or better.</p>
<div id="attachment_673" class="wp-caption aligncenter" style="width: 512px"><a href="http://staff.washington.edu/rec3141/wordpress/wp-content/uploads/2009/03/example1.png"><img src="http://staff.washington.edu/rec3141/wordpress/wp-content/uploads/2009/03/example1.png" alt="Example graph of output" title="example" width="502" height="382" class="size-full wp-image-673" /></a><p class="wp-caption-text">Example graph of output</p></div>
<p>As seen below, the program has the lowest relative error at high concentrations of viruses, and should probably not be used at concentrations less than 100 viruses per field without further testing. I should also note that the samples shown above are field samples from an extreme environment, so usage in a laboratory setting may be more precise.</p>
<a href="http://staff.washington.edu/rec3141/wordpress/wp-content/uploads/2009/03/humancomp.jpg"><img src="http://staff.washington.edu/rec3141/wordpress/wp-content/uploads/2009/03/humancomp.jpg" alt="computer counting of viruses" title="humancomp" width="502" height="382" class="size-full wp-image-504" /></a>
<p><a href='http://staff.washington.edu/rec3141/wordpress/wp-content/uploads/2009/03/JVirusCount.txt'>JVirusCount</a></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">list = getFileList(File.directory);<br />
<br />
for (i=0; i&lt;list.length; i++) {<br />
run(&quot;Clear Results&quot;);<br />
run(&quot;Set Measurements...&quot;, &quot; &nbsp;decimal=9&quot;);<br />
<br />
for (noise=1; noise&lt;42; noise++) {<br />
&nbsp;run(&quot;Find Maxima...&quot;, &quot;noise=&quot; + noise + &quot; output=Count&quot;);<br />
&nbsp;rows = nResults-1;<br />
&nbsp;setResult(&quot;Noise&quot;, rows, noise);<br />
&nbsp;counts = getResult(&quot;Count&quot;, rows);<br />
&nbsp;setResult(&quot;logcount&quot;, rows, log(counts));<br />
}<br />
<br />
title = getTitle();<br />
saveAs(&quot;Measurements&quot;, File.directory + title +&quot;.csv&quot;);<br />
run(&quot;Open Next&quot;);<br />
}</div></div>
<p><a href='http://staff.washington.edu/rec3141/wordpress/wp-content/uploads/2009/03/MVirusCount.m'>MVirusCount</a></p>
<div class="codecolorer-container matlab default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:300px;"><div class="matlab codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/clear.html"><span style="color: #0000FF;">clear</span></a> <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/all.html"><span style="color: #0000FF;">all</span></a>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
d=<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/dir.html"><span style="color: #0000FF;">dir</span></a><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'*jpg.csv'</span><span style="color: #080;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
<br />
<span style="color: #0000FF;">for</span> k=1:<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/length.html"><span style="color: #0000FF;">length</span></a><span style="color: #080;">&#40;</span>d<span style="color: #080;">&#41;</span>;<br />
<br />
&nbsp; fname=d<span style="color: #080;">&#40;</span>k<span style="color: #080;">&#41;</span>.<span style="">name</span>;<br />
counts = <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/dlmread.html"><span style="color: #0000FF;">dlmread</span></a><span style="color: #080;">&#40;</span>fname,<span style="color:#A020F0;">'\t'</span>,1,0<span style="color: #080;">&#41;</span>;<br />
counts<span style="color: #080;">&#40;</span><span style="color: #0000FF;">end</span>,:<span style="color: #080;">&#41;</span>=<span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
counts<span style="color: #080;">&#40;</span>:,<span style="color: #0000FF;">end</span><span style="color: #080;">&#41;</span>=<span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
<br />
<span style="color: #228B22;">% from 10:end because it has sigmoidal shape screwing things up</span><br />
<span style="color: #080;">&#91;</span>m, R, idiv, G<span style="color: #080;">&#93;</span> = regress2lines<span style="color: #080;">&#40;</span>counts<span style="color: #080;">&#40;</span>10:<span style="color: #0000FF;">end</span>,3<span style="color: #080;">&#41;</span>,counts<span style="color: #080;">&#40;</span>10:<span style="color: #0000FF;">end</span>,4<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;<br />
<br />
xy = <span style="color: #080;">&#91;</span>1, m<span style="color: #080;">&#40;</span>5<span style="color: #080;">&#41;</span>; <span style="color: #080;">&#40;</span>m<span style="color: #080;">&#40;</span>1<span style="color: #080;">&#41;</span>*1+m<span style="color: #080;">&#40;</span>2<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>, <span style="color: #080;">&#40;</span>m<span style="color: #080;">&#40;</span>1<span style="color: #080;">&#41;</span>*m<span style="color: #080;">&#40;</span>5<span style="color: #080;">&#41;</span>+m<span style="color: #080;">&#40;</span>2<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>; m<span style="color: #080;">&#40;</span>5<span style="color: #080;">&#41;</span>, <span style="color: #33f;">40</span>; <span style="color: #080;">&#40;</span>m<span style="color: #080;">&#40;</span>3<span style="color: #080;">&#41;</span>*m<span style="color: #080;">&#40;</span>5<span style="color: #080;">&#41;</span>+m<span style="color: #080;">&#40;</span>4<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>, <span style="color: #080;">&#40;</span>m<span style="color: #080;">&#40;</span>3<span style="color: #080;">&#41;</span>*40+m<span style="color: #080;">&#40;</span>4<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;<span style="color: #080;">&#93;</span>;<br />
<br />
store_fname<span style="color: #080;">&#123;</span>k,1<span style="color: #080;">&#125;</span> = fname;<br />
store_intercept<span style="color: #080;">&#40;</span>k,1<span style="color: #080;">&#41;</span> = m<span style="color: #080;">&#40;</span>5<span style="color: #080;">&#41;</span>;<br />
store_count<span style="color: #080;">&#40;</span>k,1<span style="color: #080;">&#41;</span> = <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/exp.html"><span style="color: #0000FF;">exp</span></a><span style="color: #080;">&#40;</span><span style="color: #080;">&#40;</span>m<span style="color: #080;">&#40;</span>1<span style="color: #080;">&#41;</span>*m<span style="color: #080;">&#40;</span>5<span style="color: #080;">&#41;</span>+m<span style="color: #080;">&#40;</span>2<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;<br />
<br />
<span style="color: #228B22;">% &nbsp;subplot(1,length(d),k)</span><br />
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/hold.html"><span style="color: #0000FF;">hold</span></a> off<br />
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/plot.html"><span style="color: #0000FF;">plot</span></a><span style="color: #080;">&#40;</span>counts<span style="color: #080;">&#40;</span>:,<span style="color: #33f;">3</span><span style="color: #080;">&#41;</span>,counts<span style="color: #080;">&#40;</span>:,<span style="color: #33f;">4</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'bs'</span><span style="color: #080;">&#41;</span><br />
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/hold.html"><span style="color: #0000FF;">hold</span></a> on<br />
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/plot.html"><span style="color: #0000FF;">plot</span></a><span style="color: #080;">&#40;</span>xy<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>,:<span style="color: #080;">&#41;</span>,xy<span style="color: #080;">&#40;</span><span style="color: #33f;">2</span>,:<span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'b-'</span><span style="color: #080;">&#41;</span><br />
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/plot.html"><span style="color: #0000FF;">plot</span></a><span style="color: #080;">&#40;</span>xy<span style="color: #080;">&#40;</span><span style="color: #33f;">3</span>,:<span style="color: #080;">&#41;</span>,xy<span style="color: #080;">&#40;</span><span style="color: #33f;">4</span>,:<span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'r-'</span><span style="color: #080;">&#41;</span><br />
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/title.html"><span style="color: #0000FF;">title</span></a><span style="color: #080;">&#40;</span><span style="color: #080;">&#123;</span>fname<span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>;<br />
<br />
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/drawnow.html"><span style="color: #0000FF;">drawnow</span></a><br />
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/pause.html"><span style="color: #0000FF;">pause</span></a><br />
<br />
<span style="color: #0000FF;">end</span><br />
<br />
fid = <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fopen.html"><span style="color: #0000FF;">fopen</span></a><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'output.csv'</span>,<span style="color:#A020F0;">'a'</span><span style="color: #080;">&#41;</span>;<br />
<span style="color: #0000FF;">for</span> k=1:<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/length.html"><span style="color: #0000FF;">length</span></a><span style="color: #080;">&#40;</span>store_fname<span style="color: #080;">&#41;</span>;<br />
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fprintf.html"><span style="color: #0000FF;">fprintf</span></a><span style="color: #080;">&#40;</span>fid,<span style="color:#A020F0;">'%s\t%0.5g\t%0.5g\n'</span>, store_fname<span style="color: #080;">&#123;</span>k<span style="color: #080;">&#125;</span>, store_intercept<span style="color: #080;">&#40;</span>k<span style="color: #080;">&#41;</span>, store_count<span style="color: #080;">&#40;</span>k<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;<br />
<span style="color: #228B22;">% &nbsp;sprintf('%s\t%0.5g', store_fname{k}, store_intercept(k))</span><br />
<span style="color: #0000FF;">end</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://staff.washington.edu/rec3141/wordpress/archives/505/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
