<?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>Jeff Mather&#039;s Dispatches &#187; MATLAB</title>
	<atom:link href="http://jeffmatherphotography.com/dispatches/category/matlab/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeffmatherphotography.com/dispatches</link>
	<description>The Post-9-to-5 Life of an International Playboy</description>
	<lastBuildDate>Mon, 06 Feb 2012 19:01:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Visual Acuity and Color Confusion</title>
		<link>http://jeffmatherphotography.com/dispatches/2011/06/visual-acuity-and-color-confusion/</link>
		<comments>http://jeffmatherphotography.com/dispatches/2011/06/visual-acuity-and-color-confusion/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 19:41:52 +0000</pubDate>
		<dc:creator>Jeff Mather</dc:creator>
				<category><![CDATA[Color and Vision]]></category>
		<category><![CDATA[MATLAB]]></category>

		<guid isPermaLink="false">http://jeffmatherphotography.com/dispatches/?p=2305</guid>
		<description><![CDATA[I&#8217;ve been working on a project at work that involves visual acuity. We&#8217;re basically asking the question, &#8220;How easy is it to notice the difference between two parts of an image with the assistance of color?&#8221; As part of the &#8230; <a href="http://jeffmatherphotography.com/dispatches/2011/06/visual-acuity-and-color-confusion/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a project at work that involves visual acuity.  We&#8217;re basically asking the question, &#8220;How easy is it to notice the difference between two parts of an image with the assistance of color?&#8221;  As part of the process, we take two grayscale images and make a false-color composite from them.  Similar regions of the image are gray (which includes black and white), while the differences show up as one hue or another.</p>
<p>There is an almost infinite number of colors we could use for the false coloring by spinning the color wheel, but it&#8217;s easiest to pick a primary color (red, green, or blue) and use its complementary color for the opposite.  Some colors are harder to distinguish against bright backgrounds; think about picking out a bright yellow object against a bright white background.  While other colors are harder to pick out against dark backgrounds; blue on black, for example.  Is there an optimal choice that&#8217;s also inexpensive to compute?</p>
<p>Let&#8217;s find out.  Here&#8217;s what happens when you perform the &#8220;What&#8217;s different?&#8221; test using the three obvious choices of red/cyan, green/magenta, and blue/yellow:</p>
<p><a href="http://jeffmatherphotography.com/dispatches/2011/06/visual-acuity-and-color-confusion/diff1/" rel="attachment wp-att-2306"><img src="http://jeffmatherphotography.com/dispatches_wp/wp-content/uploads/2011/06/diff1-776x500.png" alt="" title="Visual discrimination, normal vision" width="640" height="412" class="alignnone size-large wp-image-2306" /></a></p>
<p><a href="http://jeffmatherphotography.com/dispatches/2011/06/visual-acuity-and-color-confusion/diff2/" rel="attachment wp-att-2307"><img src="http://jeffmatherphotography.com/dispatches_wp/wp-content/uploads/2011/06/diff2-779x500.png" alt="" title="Visual discrimination, normal vision" width="640" height="410" class="alignnone size-large wp-image-2307" /></a></p>
<p><i>(Click any image to see it larger and/or full-size.)</i></p>
<p>The blue/yellow version is not very good because it suffers from the problems listed above, while the green/magenta and red/cyan false colorings seem to produce fairly equivalent results.  What to do?  The ever-practical <a href="http://blogs.mathworks.com/loren/">Loren</a> suggested that we see what happens if we ask people with <strike>color-blindness</strike> color confusion.  Turns out, we know a couple of such folks, but they were in meetings.  What to do?</p>
<p>Oh, that&#8217;s right!! A while back, I wrote some <a href="http://jeffmatherphotography.com/dispatches/2008/02/electronic-imaging-2008-color-universal-design-and-a-matlab-based-simulator/">MATLAB code that simulates the two most common forms of anomalous color vision</a>.  Let&#8217;s run that and see what happens.  (The speckling in the images is an artifact of the conversion and doesn&#8217;t represent how they actually look to people with protanopia or deuteranopia.)</p>
<p><a href="http://jeffmatherphotography.com/dispatches/2011/06/visual-acuity-and-color-confusion/deut_1/" rel="attachment wp-att-2310"><img src="http://jeffmatherphotography.com/dispatches_wp/wp-content/uploads/2011/06/deut_1-776x500.png" alt="" title="Visual Discrimination, Deuteranopia Vision" width="640" height="412" class="alignnone size-large wp-image-2310" /></a></p>
<p><a href="http://jeffmatherphotography.com/dispatches/2011/06/visual-acuity-and-color-confusion/deut_2/" rel="attachment wp-att-2311"><img src="http://jeffmatherphotography.com/dispatches_wp/wp-content/uploads/2011/06/deut_2-779x500.png" alt="" title="Visual Discrimination, Deuteranopia Vision" width="640" height="410" class="alignnone size-large wp-image-2311" /></a></p>
<p><a href="http://jeffmatherphotography.com/dispatches/2011/06/visual-acuity-and-color-confusion/prot_1/" rel="attachment wp-att-2308"><img src="http://jeffmatherphotography.com/dispatches_wp/wp-content/uploads/2011/06/prot_1-776x500.png" alt="" title="Visual Discrimination, Protanopia Vision" width="640" height="412" class="alignnone size-large wp-image-2308" /></a></p>
<p><a href="http://jeffmatherphotography.com/dispatches/2011/06/visual-acuity-and-color-confusion/prot_2/" rel="attachment wp-att-2309"><img src="http://jeffmatherphotography.com/dispatches_wp/wp-content/uploads/2011/06/prot_2-779x500.png" alt="" title="Visual Discrimination, Protanopia Vision" width="640" height="410" class="alignnone size-large wp-image-2309" /></a></p>
<p>The results are a no-brainer!  (Sorry about the pun.)  While the red/cyan and green/magenta images are very similar for the majority of us with normal color vision, the red/cyan images become very difficult to use for people with any kind of anomalous color vision.  Even though the green/magenta starts to look a lot like the blue/yellow row, which has its own issues of color discrimination, it makes a very good compromise.  Green/magenta it is.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffmatherphotography.com/dispatches/2011/06/visual-acuity-and-color-confusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Advocating for the Artificial Pancreas</title>
		<link>http://jeffmatherphotography.com/dispatches/2010/11/advocating-for-the-artificial-pancreas/</link>
		<comments>http://jeffmatherphotography.com/dispatches/2010/11/advocating-for-the-artificial-pancreas/#comments</comments>
		<pubDate>Fri, 12 Nov 2010 05:00:25 +0000</pubDate>
		<dc:creator>Jeff Mather</dc:creator>
				<category><![CDATA[101 in 1001]]></category>
		<category><![CDATA[Diabetes]]></category>
		<category><![CDATA[Health Care]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[NaBloPoMo]]></category>
		<category><![CDATA[NaBloPoMo 2010]]></category>

		<guid isPermaLink="false">http://jeffmatherphotography.com/dispatches/?p=1416</guid>
		<description><![CDATA[Editor&#8217;s note: A few weeks ago, Kim at Texting My Pancreas let me know that she would be writing a skeptical assessment of the Artificial Pancreas Project (APP), after I expressed some similar skepticism. What appears below is me being &#8230; <a href="http://jeffmatherphotography.com/dispatches/2010/11/advocating-for-the-artificial-pancreas/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><i><b>Editor&#8217;s note:</b> A few weeks ago, Kim at <a href="http://textingmypancreas.blogspot.com/" target="_blank">Texting My Pancreas</a> let me know that she would be writing a skeptical assessment of the Artificial Pancreas Project (APP), after I expressed some similar skepticism.  What appears below is me being the <a href="http://en.wikipedia.org/wiki/Devil's_advocate" target="_blank">devil&#8217;s advocate</a> <b>for</b> the artificial pancreas.  While I hold most of these views, I&#8217;m not in 100% agreement.  Because the APP, if successful, may have an enormous impact on the lives of people with diabetes, Kim and I both think it&#8217;s important to weigh the pros and cons seriously.  This is just the beginning of the debate.  Please chime in by leaving a comment with your thoughts here and on <a href="http://diabetessocmed.com/2010/guest-post-my-take-on-the-app-by-kim/">Kim&#8217;s opposing viewpoint post</a>.</i></p>
<p><i><b>Conflict of interest statement:</b> I work at a company whose software is used to design, simulate, and (possibly) control various parts of the automated pancreas, but I have no personal involvement in the APP&nbsp;.&nbsp;.&nbsp;. although I&#8217;m willing to help out in any way I can.  (I also contribute money to JDRF, which is funding the APP.)  In addition, among the MathWorks&#8217; various technology offerings are products that can be used for controller design; I make no claims about their fitness for use in a clinical setting.  These opinions are my own and may not reflect those of my employer.</i></p>
<p>Kim has given a very accurate description of the Artificial Pancreas Project (APP) and raised some very valid concerns about it.  It&#8217;s important to be realistic about what the APP is and is not.  We agree that, although it has the ability to change the lives of people with diabetes for the better, it is most definitely not a cure; and it does have a significant amount of risk.</p>
<p>But I don&#8217;t think the risks should keep us from moving forward with the APP and seeing it as an important therapy until an actual cure is available.  I will lay out why I think it&#8217;s important to keep moving forward and trying to get as many people on an AP as safely possible.  But first, let&#8217;s look at Kim&#8217;s three main objections:</p>
<ol>
<li>She doesn&#8217;t want to give up control over her personal treatment actions, especially to a system she doesn&#8217;t completely trust.</li>
<li>Neither CGM nor pumps are &#8220;fool-proof or absent of errors.&#8221;</li>
<li>Faster acting insulins leave little room for error and may lead to more rapid overdose if the algorithms miscalculate or the devices malfunction.</li>
</ol>
<p>Before I get to each of these, let&#8217;s look at why we should welcome an artificial pancreas into our lives.  The AP can prevent lows and dampen postprandial excursions.  It will get us closer to normoglycemia until researchers develop a true cure to type 1 diabetes.  As I understand it, the expectation isn&#8217;t perfectly tight &#8220;control&#8221; &mdash; I don&#8217;t think that&#8217;s realistic to expect from anything other than correctly functioning islets.  The goal is to smooth out spikes, eliminate lingering highs, and prevent lows.</p>
<p>Essentially an AP will make the &#8220;glucoaster&#8221; go away and take most of the burden for balancing insulin and food off the shoulders of people with diabetes (PWDs).  We have too many variables to consider when making insulin delivery decisions.  In fact, we have heuristics (rules of thumb) instead of rules specifically because we&#8217;re treating ourselves without all of the information about the hundred different factors that affect blood glucose (BG), and no one can reasonably expect us to make all of the minute-by-minute decisions required by all those things that affect blood glucose.</p>
<p>Most of us just aren&#8217;t as good at achieving our BG targets as we want to be, no matter how earnestly we endeavor to hit them.  I&#8217;m not being judgmental or suggesting that&#8217;s a sign of failure.  It&#8217;s just a testament to the difficulty of this disease.  I think the AP will help reduce the emotional toll of diabetes by helping us get more BG and A1c values that we and our healthcare providers hope to see and by removing a lot of the guilt and despair when our decisions don&#8217;t work out as we would like.</p>
<p>It&#8217;s natural to be skeptical or hesitant before making big changes, especially when they&#8217;re related to our health.  But we need to accept our own limitations and fallibility and to accept help from technology when it&#8217;s available and reliable.</p>
<p>I don&#8217;t want anyone to think that I&#8217;m sugar-coating or downplaying the very real risks associated with the AP hardware and with more-or-less removing people from the loop.  Every treatment option has risks.*  Both multiple daily injection (MDI) and conventional pump therapy have risks.  It&#8217;s possible to draw up the wrong amount of insulin.  Pumps can fail, giving too much insulin or too little.  BG meters and CGM sensors can give incorrect information or we can miscalculate the number of carbs in a meal, leading us to incorrect dosing.  It&#8217;s currently too early to say there is any evidence that the AP has a larger risk exposure than MDI or open-loop pumping.</p>
<p>An AP won&#8217;t be any more (or less) fallible than a human pumper.  If a pump is going to fail, it&#8217;s going to fail.  I&#8217;ve personally had three pumps fail in about ten years of pumping, one of which led to an overdose of about 40 or 50 extra units of insulin during an infusion set change and two of which led to inoperative pumps.  Clearly these are unacceptable events.  Every AP pump should be built with even more fault-tolerance and redundancy than the current generation of devices.  And it&#8217;s likely that some automatic decisions may still require confirmation.  For example, if the pump exceeds a certain number of units per hour, the wearer may be required to confirm that they ate or provide an estimate of the number of carbs in the meal.</p>
<p>Based on the kind of questions that the FDA regulators were asking at yesterday&#8217;s public workshop, I think the level of testing and validation by the FDA is going to be agonizingly thorough.  PWDs will eventually grumble about all the delays getting the AP into our hands.  And the legal departments of medical device manufacturers are going to be very reticent to give a thumbs up to any device where &#8220;normal use&#8221; would cause more risk &mdash; and therefore bigger lawsuit costs &mdash; than the options currently available.</p>
<p>Furthermore, there&#8217;s no requirement that the pumps use the fastest acting insulin available.  Patients hopefully will be able to choose whether to use it after consultation with their endocrinologists and gathering feedback from those who are using it.  And putting glucose or glucagon in the second chamber of the pump should help reduce the possibility of accidental overdose during normal operation.</p>
<p>Finally, there&#8217;s the issue of CGM accuracy.  This is the trickiest problem, and the one where I most agree with Kim.  I think it&#8217;s correct to be skeptical of anything that&#8217;s currently in clinical trials &mdash; anything that uses CGMS, in fact.  Having looked at my own data when I wore a CGM sensor for a week, I saw too many deviations from my BG meter and from how my body felt.  Clearly this part of the technology is not sufficient for the fully closed loop that defines the APP.</p>
<p>Does this mean that I&#8217;m packing it in?  Do I doubt the promise of the whole artificial pancreas project?  No.  It <b>does</b> mean that I wouldn&#8217;t volunteer for a closed-loop trial right now.</p>
<p>But I do think it&#8217;s wrong to judge the value of the AP, which is at least 2-3 years away from being submitted to the FDA, using today&#8217;s options.  What is eventually submitted will have to be much more awesome.  Fortunately, CGM technology will continue to improve, and the APP offerings will have to include the most-reliable options or it will likely not be approved.</p>
<p>Is the AP perfect? No.  Is it riskier than MDI or open-loop pump therapy.  Maybe, maybe not &mdash; but that&#8217;s not a bad assessment for technology that&#8217;s still in the prototype and clinical trials stage.  The first regulator-approved offerings (hopefully) will be both more robust and much more accurate.</p>
<p>While it&#8217;s important to reiterate that the AP is not a cure &mdash; and I sincerely hope that companies selling AP devices never try to market it that way &mdash; I think it holds enough promise that I&#8217;m willing to set aside my fears about mechanical failures and losing control over the minutiae of a disease that I can&#8217;t really control on my own.</p>
<p><br clear="all" />* &mdash; Remember <i><a href="http://en.wikipedia.org/wiki/Risk" target="_blank">risk</a></i> is <i>magnitude</i> of a possible problem combined with the <i>likelihood</i> of that problem occurring.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffmatherphotography.com/dispatches/2010/11/advocating-for-the-artificial-pancreas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An Invitation to Diabetes Researchers</title>
		<link>http://jeffmatherphotography.com/dispatches/2010/10/an-invitation-to-diabetes-researchers/</link>
		<comments>http://jeffmatherphotography.com/dispatches/2010/10/an-invitation-to-diabetes-researchers/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 02:12:42 +0000</pubDate>
		<dc:creator>Jeff Mather</dc:creator>
				<category><![CDATA[101 in 1001]]></category>
		<category><![CDATA[Book Notes]]></category>
		<category><![CDATA[Diabetes]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://jeffmatherphotography.com/dispatches/?p=1271</guid>
		<description><![CDATA[I just finished reading Michael Bliss&#8217;s excellent The Discovery of Insulin about the amazing work at the University of Toronto in 1921-1923 by Banting, Best, Collip, and Macloed. For most readers, it&#8217;s surely a story about discovery and rivalry and &#8230; <a href="http://jeffmatherphotography.com/dispatches/2010/10/an-invitation-to-diabetes-researchers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just finished reading Michael Bliss&#8217;s excellent <i>The Discovery of Insulin</i> about the amazing work at the University of Toronto in 1921-1923 by <a href="http://nobelprize.org/educational/medicine/insulin/discovery-insulin.html">Banting, Best, Collip, and Macloed</a>.  For most readers, it&#8217;s surely a story about discovery and rivalry and collaboration in medicine, culminating in the first effective treatment of diabetes and (very quickly thereafter) the Nobel Prize for Medicine.</p>
<p>For me it was also a history of what I avoided by being diagnosed with type 1 diabetes after 1922.  Bliss includes a small sample of the lives of some of the people afflicted with diabetes before the discovery of insulin.  I was truly inspired by those who were fortunate enough to receive this &#8220;miracle drug,&#8221; but I was heartbroken by all of the people of that age who didn&#8217;t make it because the only treatment was to survive on a meager 500-or-so calories for intolerable months until slipping into the coma of ketoacidosis and then (eventually) death.</p>
<p>It&#8217;s been almost 89 years since the first successful clinical use of insulin, but we still don&#8217;t have a cure.  At best, insulin is the key part of a hormone replacement therapy where people with diabetes try to mimic a pancreas. At worst, insulin is a fickle treatment that is difficult to use, expensive, and out of reach of millions of people worldwide.</p>
<p>While I&#8217;m so grateful for what I have &mdash; a treatment that gives life &mdash; what we need now is a cure&nbsp;.&nbsp;.&nbsp;. even if it&#8217;s only useful for people who are not yet sick or are newly diagnosed.</p>
<p><b>If you&#8217;re working on a cure or a new therapy for diabetes, the rest of this post is for you.</b></p>
<p>I will help you with any technical software aspects of your research that you need.  If you have questions about MATLAB or C++, I will do my very best to answer them.  If you need help with software design or object-oriented analysis/design, I can help you structure your solution.  If you require some help with the non-development aspects of software development &mdash; such as project management or using tools &mdash; I will help you there, too.</p>
<p>My particular areas of expertise are MATLAB, C++, medical imaging formats (such as DICOM), some familiarity with image processing, and multithreaded programming using Intel&#8217;s TBB.  I also know my fair share about life with diabetes.  I can&#8217;t promise that I&#8217;ll have all of the answers to your particular question, but I&#8217;ll work with you as much as I can.  And I&#8217;ll connect you with my coworkers as much as I can, if it comes down to that.  Finding a cure that&#8217;s safe, effective, and universally accessible isn&#8217;t my day job, but moving into the third era of diabetes where no one dies from it and no one has to impersonate a pancreas is something I&#8217;d love to be a small (even anonymous) part of.</p>
<p>You can e-mail me at <a href="mailto:jeff.mather@mathworks.com">work</a> or <a href="mailto:jeffmather@verizon.net">home</a>, and you can <a href="http://twitter.com/jeffmather/">hit me up on Twitter</a>, too.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffmatherphotography.com/dispatches/2010/10/an-invitation-to-diabetes-researchers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading a Freestyle Blood Glucose Meter with MATLAB</title>
		<link>http://jeffmatherphotography.com/dispatches/2010/09/reading-a-freestyle-blood-glucose-meter-with-matlab/</link>
		<comments>http://jeffmatherphotography.com/dispatches/2010/09/reading-a-freestyle-blood-glucose-meter-with-matlab/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 19:54:30 +0000</pubDate>
		<dc:creator>Jeff Mather</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Data-betes]]></category>
		<category><![CDATA[Diabetes]]></category>
		<category><![CDATA[Fodder for Techno-weenies]]></category>
		<category><![CDATA[MATLAB]]></category>

		<guid isPermaLink="false">http://jeffmatherphotography.com/dispatches/?p=1111</guid>
		<description><![CDATA[Here&#8217;s some MATLAB code that will read data from a Freestyle blood glucose meter that is attached to your computer via serial cable. (Be sure to replace the &#8220;smart&#8221; quotes with appropriate single quotes. And the &#8220;&#8230;&#8221;, too. Sorry.) % &#8230; <a href="http://jeffmatherphotography.com/dispatches/2010/09/reading-a-freestyle-blood-glucose-meter-with-matlab/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s some MATLAB code that will read data from a Freestyle blood glucose meter that is attached to your computer via serial cable.  <strike>(Be sure to replace the &#8220;smart&#8221; quotes with appropriate single quotes.  And the &#8220;&#8230;&#8221;, too.  Sorry.)</strike></p>
<pre>
<div class="codesnip-container" >
<div class="matlab codesnip" style="font-family:monospace;"><span class="co1">% Jeff Mather - 3 October 2001</span>
<span class="co1">% Connect to meter.</span>
s = serial<span class="br0">&#40;</span><span class="co2">'com1'</span>, <span class="co2">'baudrate'</span>, <span class="nu0">19200</span>, <span class="sy0">...</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co2">'FlowControl'</span>, <span class="co2">'Software'</span><span class="br0">&#41;</span>;
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fopen.html"><span class="kw2">fopen</span></a><span class="br0">&#40;</span>s<span class="br0">&#41;</span>;

<span class="co1">% Initiate communication.</span>
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fprintf.html"><span class="kw2">fprintf</span></a><span class="br0">&#40;</span>s, <span class="co2">'mem'</span><span class="br0">&#41;</span>;
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fprintf.html"><span class="kw2">fprintf</span></a><span class="br0">&#40;</span>s, <span class="co2">'log250'</span><span class="br0">&#41;</span>;

<span class="co1">% Read diagnostics.</span>
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fgetl.html"><span class="kw2">fgetl</span></a><span class="br0">&#40;</span>s<span class="br0">&#41;</span>; &nbsp; <span class="co1">% First line is empty.</span>
meter_ID &nbsp; &nbsp; = <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fgetl.html"><span class="kw2">fgetl</span></a><span class="br0">&#40;</span>s<span class="br0">&#41;</span>;
software_ver = <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fgetl.html"><span class="kw2">fgetl</span></a><span class="br0">&#40;</span>s<span class="br0">&#41;</span>;
current_time = <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fgetl.html"><span class="kw2">fgetl</span></a><span class="br0">&#40;</span>s<span class="br0">&#41;</span>;
num_readings = <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/str2num.html"><span class="kw2">str2num</span></a><span class="br0">&#40;</span><a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fgetl.html"><span class="kw2">fgetl</span></a><span class="br0">&#40;</span>s<span class="br0">&#41;</span><span class="br0">&#41;</span>;

<span class="kw1">for</span> p = 1:num_readings

&nbsp; &nbsp; reading = <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fgetl.html"><span class="kw2">fgetl</span></a><span class="br0">&#40;</span>s<span class="br0">&#41;</span>;
&nbsp; &nbsp; <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/sprintf.html"><span class="kw2">sprintf</span></a><span class="br0">&#40;</span>reading<span class="br0">&#41;</span>
&nbsp; &nbsp; 
&nbsp; &nbsp; <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/pause.html"><span class="kw2">pause</span></a><span class="br0">&#40;</span>0.25<span class="br0">&#41;</span>;
&nbsp; &nbsp; 
<span class="kw1">end</span>

<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fclose.html"><span class="kw2">fclose</span></a><span class="br0">&#40;</span>s<span class="br0">&#41;</span>;</div>
</div>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jeffmatherphotography.com/dispatches/2010/09/reading-a-freestyle-blood-glucose-meter-with-matlab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why I Love My Job</title>
		<link>http://jeffmatherphotography.com/dispatches/2010/01/why-i-love-my-job/</link>
		<comments>http://jeffmatherphotography.com/dispatches/2010/01/why-i-love-my-job/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 19:32:17 +0000</pubDate>
		<dc:creator>Jeff Mather</dc:creator>
				<category><![CDATA[Diabetes]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[This is who we are]]></category>

		<guid isPermaLink="false">http://jeffmatherphotography.com/dispatches/2010/01/why-i-love-my-job/</guid>
		<description><![CDATA[So you already know that I ♥ my pancreas. I hope that soon I&#8217;ll be able to ♥ both my real and &#8220;artificial&#8221; pancreases. Kerri at Six Until Me has a great write-up of an announcement between JDRF, Johnson &#038; &#8230; <a href="http://jeffmatherphotography.com/dispatches/2010/01/why-i-love-my-job/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So you already know that <a href="http://jeffmatherphotography.com/dispatches/2009/11/i/">I ♥ my pancreas</a>.  I hope that soon I&#8217;ll be able to ♥ both my real and &#8220;artificial&#8221; pancreases.  Kerri at <a href="http://sixuntilme.com/">Six Until Me</a> has a great write-up of <a href="http://sixuntilme.com/blog2/2010/01/jdrf_jj_and_dexcom_walk_into_a.html">an announcement between JDRF, Johnson &#038; Johnson, and DexCom</a> which should speed my new love&#8217;s arrival.  (<i>Update: The Diabetes Mine has <a href="http://www.diabetesmine.com/2010/01/news-flash-jdrf-joins-with-animas-dexcom-to-build-first-generation-artificial-pancreas.html">even more details and an interview</a>.</i>)</p>
<p>And I ♥ my job.  I won&#8217;t try to take credit for any of the hard work that JDRF-funded scientists and industry R&#038;D folks are doing to make an artificial pancreas a reality.  They deserve all of the credit and so much more.  But I <b>know</b> for certain that many people at those institutions and others are using our tools as part of the day-to-day toil of making this a reality.  (MATLAB&#8217;s graphics have a very *ahem* <i>distinctive</i> appearance, which I&#8217;ve seen in presentations about the artificial pancreas and diabetes self-management findings.)</p>
<p><a href="http://www.mathworks.com/">The MathWorks</a>&#8216; mission statement is that we &#8220;accelerate the pace of engineering and science worldwide.&#8221;  Although it might just sound like nice words on a web site or T-shirt, at times like this it makes me very proud to know that we really do make great things happen faster.  And knowing that &mdash; even as a peripheral actor &mdash; I help with progress, well, that inspires me to do my job that much better, by putting a little more care and polish into my features (especially those related to medical imaging), by rooting out all of the hidden software defects that I might otherwise overlook, and by working hard to get as many of those customer-requested features into the product that I can.  That may sound a little corny, but I know that everything I do to accelerate the development of our products helps other people accelerate the creation of their products.  And I&#8217;m not the only one in the office who feels this way.</p>
<p>Now, back to (indirectly) helping other people fight the good fight.&nbsp;.&nbsp;.&nbsp;.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffmatherphotography.com/dispatches/2010/01/why-i-love-my-job/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Diabetes Application &#8211; A Sample Report</title>
		<link>http://jeffmatherphotography.com/dispatches/2009/08/diabetes-application-a-sample-report/</link>
		<comments>http://jeffmatherphotography.com/dispatches/2009/08/diabetes-application-a-sample-report/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 02:37:41 +0000</pubDate>
		<dc:creator>Jeff Mather</dc:creator>
				<category><![CDATA[Data-betes]]></category>
		<category><![CDATA[Diabetes]]></category>
		<category><![CDATA[Historical Record]]></category>
		<category><![CDATA[Life Lessons]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://jeffmatherphotography.com/dispatches/2009/08/diabetes-application-a-sample-report/</guid>
		<description><![CDATA[A couple weeks ago, I presented a teaser of my diabetes application. I&#8217;ve been working on it a lot lately, creating GUIs to enter most of the data on my insulin pump and blood glucose meter. But mostly I&#8217;ve been &#8230; <a href="http://jeffmatherphotography.com/dispatches/2009/08/diabetes-application-a-sample-report/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A couple weeks ago, I presented <a href="http://jeffmatherphotography.com/dispatches/2009/08/what-im-doing-now/">a teaser of my diabetes application</a>.  I&#8217;ve been working on it a lot lately, creating GUIs to enter most of the data on my insulin pump and blood glucose meter.  But mostly I&#8217;ve been creating charts and reports.  (Putting data in is much less interesting than analyzing it, in an effort to improve my &#8220;control.&#8221;)</p>
<p>Here&#8217;s <a href="/html_ver1/webReport.html">one of the reports</a>.  It has a bit of everything, including the kitchen sink.  The one I&#8217;m taking with me to my endocrinologist tomorrow is much more focused.  Visualizing all of the data associated with diabetes is kind of tricky, so I&#8217;m working on that.  More features to come.&nbsp;.&nbsp;.&nbsp;.</p>
<p>(Please, don&#8217;t judge me based on my readings. :^)  Right now I&#8217;m using food to cover my insulin, which is the opposite of how it should work &mdash; it seems I never really got switched from the NPH mindset.  Getting past that is one of the main reasons why I&#8217;m doing in this project.)</p>
<p>I&#8217;m committed to releasing everything under some kind of open source license.  Everything, that is, except the data and anything that would involve a diagnosis or recommend a particular kind of treatment.  I don&#8217;t want to be on the hook for FDA approval and all that involves.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffmatherphotography.com/dispatches/2009/08/diabetes-application-a-sample-report/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MATLAB and Greenspun&#8217;s 10th Rule</title>
		<link>http://jeffmatherphotography.com/dispatches/2009/06/matlab-and-greenspuns-10th-rule/</link>
		<comments>http://jeffmatherphotography.com/dispatches/2009/06/matlab-and-greenspuns-10th-rule/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 19:24:52 +0000</pubDate>
		<dc:creator>Jeff Mather</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Life Lessons]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://jeffmatherphotography.com/dispatches/2009/06/matlab-and-greenspuns-10th-rule/</guid>
		<description><![CDATA[Just to get this disclaimer out of the way, let&#8217;s remind everyone that this is my personal website. Even though I may write some of the articles at work about things I&#8217;ve done at work, they aren&#8217;t in anyway supervised &#8230; <a href="http://jeffmatherphotography.com/dispatches/2009/06/matlab-and-greenspuns-10th-rule/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><i>Just to get this disclaimer out of the way, let&#8217;s remind everyone that this is my personal website.  Even though I may write some of the articles at work about things I&#8217;ve done at work, they aren&#8217;t in anyway supervised or endorsed by my employer.  I&#8217;m only including this disclaimer because this article is meant to be self-deprecating in that &#8220;I had the best of intentions, but now I feel a little silly&#8221; way.</i></p>
<p>Several years ago I read <a href="http://c2.com/cgi/wiki?GreenspunsTenthRuleOfProgramming">Greenspun&#8217;s Tenth Rule of Programming</a>: &#8220;Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.&#8221;  Basically it&#8217;s a joke about feature creep in software.  I was reminded of this quotation today when I started reading Joshua Kerievsky&#8217;s <i>Refactoring to Patterns</i>.  He describes the perils of over-engineering, which is basically the same as wasting money.</p>
<p>You see, about seven or eight years ago, I added a Lisp parser to a feature in MATLAB&#8217;s Image Processing Toolbox.  If you have the toolbox, just take a look in <tt>toolbox/images/iptformats/private/dicom_create_IOD.m</tt>.  There you&#8217;ll see a part of the code that looks like this:</p>
<pre>
<div class="codesnip-container" >
<div class="matlab codesnip" style="font-family:monospace;"><span class="kw1">function</span> tf = check_condition<span class="br0">&#40;</span>expr, metadata<span class="br0">&#41;</span>
<span class="co1">%CHECK_CONDITION &nbsp;Determine whether a condition is true.</span>
<span class="co1">%</span>
<span class="co1">% &nbsp; Conditions are LISP-style cell arrays. &nbsp;The first element</span>
<span class="co1">% &nbsp; is a conditional operator, remaining cells are arguments</span>
<span class="co1">% &nbsp; to the operator.</span>
<span class="co1">%</span>
<span class="co1">% &nbsp; Conditions can be nested. &nbsp;Each cell array in expr indicates</span>
<span class="co1">% &nbsp; a new conditional expression.</span>

<span class="co1">%[snip]</span>

<span class="co1">%</span>
<span class="co1">% Process conditional expressions recursively.</span>
<span class="co1">%</span>
<span class="kw1">switch</span> <span class="br0">&#40;</span><a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/lower.html"><span class="kw2">lower</span></a><span class="br0">&#40;</span>operator<span class="br0">&#41;</span><span class="br0">&#41;</span>
<span class="kw1">case</span> <span class="co2">'and'</span>
&nbsp; &nbsp; 
&nbsp; &nbsp; <span class="co1">% This AND short circuits.</span>
&nbsp; &nbsp; <span class="kw1">for</span> p = 1:numel<span class="br0">&#40;</span>operands<span class="br0">&#41;</span>
&nbsp; &nbsp; &nbsp; &nbsp; tf = check_condition<span class="br0">&#40;</span>operands<span class="br0">&#123;</span>p<span class="br0">&#125;</span>, metadata<span class="br0">&#41;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>~tf<span class="br0">&#41;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span>
&nbsp; &nbsp; <span class="kw1">end</span>

<span class="br0">&#91;</span>snip<span class="br0">&#93;</span></div>
</div>
</pre>
<p>So why did I do this?  The DICOM file format has conditional elements, which only show up in the file if other elements are present, are absent, or have a particular value.  I wanted to create a general-purpose, reusable, extensible mechanism for describing these conditions so that I didn&#8217;t actually have to write code for all of those conditionals.  Moreover, I wanted our customers to be able to write the conditions in a nice tabular form rather than writing code, because &mdash; you know &mdash; one day they would want to write more of the dozens of kinds of DICOM information objects from scratch than we supported right out of the box.</p>
<p>You probably see where this is going.  We ended up extending the product in a different direction after we learned more about how our customers actually wanted to use the DICOM export functionality.  So, if you need a Lisp-like algebraic Boolean logic parser in MATLAB, just go look in the previously mentioned file.  (Also take a look at the <tt>dicom_modules.m</tt> file in the same directory to see how to express those conditions.)  But for g-d&#8217;s sake, ask yourself if you really, really need that, or if you aren&#8217;t just fooling yourself into over-engineering your code.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffmatherphotography.com/dispatches/2009/06/matlab-and-greenspuns-10th-rule/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Electronic Imaging: 3D</title>
		<link>http://jeffmatherphotography.com/dispatches/2009/01/matlab-in-3d/</link>
		<comments>http://jeffmatherphotography.com/dispatches/2009/01/matlab-in-3d/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 05:45:09 +0000</pubDate>
		<dc:creator>Jeff Mather</dc:creator>
				<category><![CDATA[Color and Vision]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://jeffmatherphotography.com/dispatches/2009/01/matlab-in-3d/</guid>
		<description><![CDATA[I am attending Electronic Imaging 2009 in San Jose. Well, today was my last day here. Tomorrow I return to snowy Massachusetts. (It&#8217;s currently about 60º here.) But I&#8217;ve had my fish taco fix for another year, and I&#8217;m excited &#8230; <a href="http://jeffmatherphotography.com/dispatches/2009/01/matlab-in-3d/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am attending Electronic Imaging 2009 in San Jose.  Well, today was my last day here. Tomorrow I return to snowy Massachusetts. (It&#8217;s currently about 60º here.) But I&#8217;ve had my fish taco fix for another year, and I&#8217;m excited to get back to Lisa and the kitty.</p>
<p>As usual, I learned something new and talked to a lot of people about imaging and MATLAB.  Last year, the new-to-me things concerned <a href="http://jeffmatherphotography.com/dispatches/2008/01/electronic-imaging-2008-megapixels-matter/">image quality for mobile devices</a> and <a href="http://jeffmatherphotography.com/dispatches/2008/01/electronic-imaging-digital-image-forensics/">image forensics</a>. This year&#8217;s big surprises were 3-D imaging, which apparently is going mainstream. (According to <a href="http://www.3d.curtin.edu.au/">Andrew Woods</a>, the chair of the Stereoscopic Displays and Applications conference, there are already two million televisions in people&#8217;s homes which are capable of displaying 3D video.) Every year that I attend, I seem to get a different view of the conference; so I&#8217;m cautious to read too much into any given year. But somehow, 3D felt different this time.</p>
<p>The exhibitors behind us were demonstrating their more advanced 3D displays and video capture systems, and the person across from us was <a href="http://terryfic3d.com/">selling 3D notecards and prints</a>. So my coworker and I thought we&#8217;d get in on the action during the waning hours of the exhibit.  We decided to try our hand at making an anaglyph, one of the easier kinds of 3D images to make (along with stereograms, which are a bit lo-fi for MATLAB, after all).</p>
<p>The recipe calls for combining two images of the same scene from slightly different perspectives using a simple function that combines the red channel from the left image and the green and blue channels from the right image. And of course, you need the funny glasses.  First, the images that we made with my camera phone:</p>
<p><a href="/images/21-01-09_1216.jpg"><img src="http://www.jeffmatherphotography.com/phpThumb/phpThumb.php?src=/images/21-01-09_1216.jpg&#038;w=460&#038;q=90" title="Left image" border="0" /></a><br clear="all" /><a href="/images/21-01-09_1216.jpg">Left image</a></p>
<p><a href="/images/21-01-09_1217.jpg"><img src="http://www.jeffmatherphotography.com/phpThumb/phpThumb.php?src=/images/21-01-09_1217.jpg&#038;w=460&#038;q=90" title="Right image" border="0" /></a><br clear="all" /><a href="/images/21-01-09_1217.jpg">Right image</a></p>
<p>Using <a href="http://www.mathworks.com/matlabcentral/fileexchange/4977">some MATLAB code</a> that we found on MATLAB Central, you get the following image:</p>
<p><img src="/images/holga_anaglyph.jpg"><br clear="all" />The anaglyph</p>
<p>(Unfortunately, I can&#8217;t help you with the funny glasses. Go get yer own.)</p>
<p>I am told the results are &#8220;okay for a <a href="http://www.3dculture.com/occ/StereoAlignArticle.htm">cha-cha picture</a>.&#8221; I don&#8217;t have binocular vision, so what do I know?</p>
<p>Have fun.  (And don&#8217;t be like the guy who said that the 1.57% of the population with monocular vision aren&#8217;t really worth worrying about.)</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffmatherphotography.com/dispatches/2009/01/matlab-in-3d/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Article on High Dynamic Range Imaging and MATLAB</title>
		<link>http://jeffmatherphotography.com/dispatches/2008/09/article-on-high-dynamic-range-imaging-and-matlab/</link>
		<comments>http://jeffmatherphotography.com/dispatches/2008/09/article-on-high-dynamic-range-imaging-and-matlab/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 19:29:09 +0000</pubDate>
		<dc:creator>Jeff Mather</dc:creator>
				<category><![CDATA[Color and Vision]]></category>
		<category><![CDATA[Fodder for Techno-weenies]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://jeffmatherphotography.com/dispatches/2008/09/article-on-high-dynamic-range-imaging-and-matlab/</guid>
		<description><![CDATA[Peter Webb, one of my coworkers, published an article entitled &#8220;Rendering High Dynamic Range Images on the Web&#8221; in the July 2008 issue of the MATLAB Digest. Enjoy!]]></description>
			<content:encoded><![CDATA[<p>Peter Webb, one of my coworkers, published an article entitled &#8220;<a href="http://www.mathworks.com/company/newsletters/digest/2008/july/hdri.html">Rendering High Dynamic Range Images on the Web</a>&#8221; in the July 2008 issue of the <a href="http://www.mathworks.com/company/newsletters/digest/2008/july/">MATLAB Digest</a>.  Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffmatherphotography.com/dispatches/2008/09/article-on-high-dynamic-range-imaging-and-matlab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quickly Finding Numeric Patterns in MATLAB</title>
		<link>http://jeffmatherphotography.com/dispatches/2008/09/quickly-finding-numeric-patterns-in-matlab/</link>
		<comments>http://jeffmatherphotography.com/dispatches/2008/09/quickly-finding-numeric-patterns-in-matlab/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 19:23:38 +0000</pubDate>
		<dc:creator>Jeff Mather</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[MATLAB]]></category>

		<guid isPermaLink="false">http://jeffmatherphotography.com/dispatches/2008/09/quickly-finding-numeric-patterns-in-matlab/</guid>
		<description><![CDATA[Comrade programmers! About five years ago I wrote a little program to help me find numeric patterns in arrays. Basically I needed to find byte patterns like 0xFFFE 0xE000 in the data from DICOM files. Something like MATLAB&#8217;s strfind function, &#8230; <a href="http://jeffmatherphotography.com/dispatches/2008/09/quickly-finding-numeric-patterns-in-matlab/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Comrade programmers!</p>
<p>About five years ago I wrote a little program to help me find numeric patterns in arrays.  Basically I needed to find byte patterns like 0xFFFE 0xE000 in the data from DICOM files.  Something like MATLAB&#8217;s <tt>strfind</tt> function, except more general than looking for substrings in strings.</p>
<p>So I wrote a rather naïve algorithm to do just that.  It wasn&#8217;t very fast, but it worked for exploratory use.  But then today I needed to do something like that in production code.  So I asked <a href="http://blogs.mathworks.com/loren/">one of my coworkers</a> for tips with a faster implementation.</p>
<p>Turns out the <tt>strfind</tt> works just as well on numeric arrays as it does on strings.  And it&#8217;s really fast, too.</p>
<pre>
<div class="codesnip-container" >
<div class="matlab codesnip" style="font-family:monospace;"><span class="co1">% &quot;data&quot; is a 1,200,000 element UINT8 array.</span>
<span class="co1">% It contains 29 instances of the pattern.</span>
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/tic.html"><span class="kw2">tic</span></a>; offsetTable = strfind<span class="br0">&#40;</span>data, <span class="br0">&#91;</span>254 255 0 224<span class="br0">&#93;</span><span class="br0">&#41;</span>; <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/toc.html"><span class="kw2">toc</span></a>

<span class="co1">% Elapsed time is 0.027390 seconds.</span></div>
</div>
</pre>
<p><b>Update</b>: Loren Shure <a href="http://blogs.mathworks.com/loren/2008/09/08/finding-patterns-in-arrays/">posted an even better solution</a> on her blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffmatherphotography.com/dispatches/2008/09/quickly-finding-numeric-patterns-in-matlab/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

