Category Archives: Computing

The Ultimate Blood Glucose Meter

Let’s talk gadgets.

Usually I can hold off getting things with buttons and displays. I’m a guy whose “smartphone” is an unlocked multi-band phone from the middle of the last decade that we took to India and that now mostly sits in my bag uncharged unused. It has a camera and Bluetooth, and I can play Monopoly on it (using a Java virtual machine) but that’s pretty much it. Fancy MacBook Pro laptop (from 2006)? Yes. 4th-gen iPod (ca. 2007)? Also yes. iPad/iPhone/Android/everything else? Not so much. After that decision to get an overpriced HP iPAQ hx4700 with a short shelf-life in early 2005, I’ve been reluctant to get many expensive, shiny things.

I’m definitely not opposed to gadgets, though. After thinking about the experience of recording my diabetes events at the end of last month, I’ve decided that I would like one shiny, new thing. Unfortunately, what I want — an awesome, new blood glucose meter — doesn’t exist yet. What would such a sugasheen have?

First off, it would be part of an integrated system. It would work with my pump, sending BG readings to it, similar to the way my OneTouch Ultra Link does with my Minimed Paradigm pump. It would also accept sensor data from a CGMS.

It would be easy to get data off of it. We’re talking as simple as docking an MP3 player, preferably using a standard USB connector. The data should be open and sharable. I hate that Medtronic’s software lets me download all of my pump’s events — including suspensions, temporary basals and bolus wizard suggestions — but then stores them in a password-protected Microsoft Access database that I can’t open because they won’t share the password or let me change it. And unlike the Freestyle connection cable, Medtronic won’t provide the API calls that I could use as an application developer to retrieve the data from my pump/meter. It’s my data. They don’t own it. It’s my life I’m trying to improve. Meter manufacturers should help me do that, right?

It would be open. There are lots of ways to slice and dice and visualize data if you have access to it. I should be able review my data, get averages, display events, and plot my activity in a billion different ways: time series, modal day, statistical box plots, histograms, even pie charts. Basically, if you can think of something to do with BG data, it should be possible to get the data and do it. That doesn’t have to happen on the meter itself, but it could. Wouldn’t that be sweet?

It would have lots of metadata. My Freestyle meter didn’t have any metadata at all. My OneTouch has two axes: before/after meals and a limited set of comments. But I find the events don’t often describe the reading I’ve just taken. “Not enough food” and “too much food” might describe the experience of people with type 2 or those unfortunate souls still on NPH, but I find myself wanting something like “miscalculated carbs” and “infusion set change.” I would love to be able to define my own events — especially a “WTF?!” comment — and be able to tag particular readings for follow-up with my endocrinologist or her nurse.

I would love to be able to type short, free-form notes to myself about my BG and bolus events: “Bolus wizard said 5.0 units, but I took 4.0 because of exercise” or “Had some ketones.” We’re talking Twitter-length here (140 characters) not Anna Karenina. Since a lot of diabetes is tweaking things, the perfect meter software would let me remember what I’ve tried and try it again or change it up next time.

As long as we’re talking about notes and readings and metadata, let’s talk sharing. I would love to be able to e-mail a portion or all of my log to my healthcare team for consultation. There’s no need to post my results to Twitter, but then again, why not?

Switching to the nuts-and-bolts, getting-the-BG-reading level, let’s try to think beyond blood and consumables: The ultimate BG meter would take blood and test strips out of the picture. Strips are expensive and have to be disposed. Pricking fingers isn’t exactly painful for me (I know it is for some people) but it is a bit 20th century. How about something that uses subcutaneous light scattering or UV “tattoos” that change depending on BG levels? However it might work, we’re talking about something noninvasive that doesn’t require another trip to the pharmacy every month in order to buy something I’m going to bleed on and (responsibly) throw away.

And, of course, it would be very accurate. None of this ±10% nonsense. We’re occasionally making life-or-death decisions with those BG readings, especially when deciding how to treat a high BG. The values should be precise and accurate enough that we can’t overcorrect because we’re in the margin of error.

It would also be possible to use this meter at night. LEDs are cheap. Use them. Put one in the front so that I can see my finger and another behind the display so that I can read the results w/o blinding myself at 4:00AM.

And for the love of g-d, if you’re going to require batteries, use normal ones that you find at a gas station on the NJ Turnpike or at the Eiffel Tower gift shop. AAAs would be nice.

Since blood glucose self-monitoring is the first step in a decision-making process, the ideal BG meter would help me with the rest of the process. Get a BG reading, add in the name and amount of the thing I’m going to eat, and voilà the carbs show up for the bolus wizard. I should be able enter in foods that I frequently eat as well as downloading nutritional information for those place we won’t tell our nutritionist about. If I’m going for a bicycle ride, the decision-support part of the system could remind me what works and suggest some snacks or insulin pre-gaming that I need to do based on my own history. It could even point my attention to the fact that I’ve been going high around 4:00 most afternoons for the last month and suggest that I bring it up with my healthcare team.

Finally, it would be at least as small as my current meter. If it has to be a separate device, it should fit into a stylish case that won’t get nasty after a year of constant use. But . . .

Look at this:

iPod Touch

Look closer!

iPod Touch

The data ports on the iPod and iPhone are perfect for attaching something small that can communicate with the software on the device. The ultimate BG meter would just attach to an iPhone or iPod Touch (or Android device), adding the BG reading capability to a platform that is perfect for everything else. Basically, I want a smartphone with “an app for that,” where “that” is diabetes.*

BG database with flexible journaling? There’s an app for that.

BG results analysis? There’s an app for that, too.

Bolus wizard support using a food database? E-mailing results? Decision support? Apps for them, of course.

These devices already have a backlight for those late-night readings and wireless connectivity to integrate CGMs and insulin pumps.

And we already carry them around. Or at least I would go buy one now if this were available. I’d probably buy two.


* — Look at what Apple has already done with the point-of-sale (POS) system in their own stores. “Running an Apple supply chain? There’s an app for that.”

Posted in Computing, Data-betes, Diabetes, Fodder for Techno-weenies | 6 Comments

New Video File Formats

File formats come, and file formats go. Strike that last part. File formats never really go away. People just stop storing data in them, and vendors stop supporting the formats in their products. Eventually the data is just a bunch of bits that nobody really cares about. (At least that’s how I feel about most of the papers that I wrote in college.)

While formats never really retire*, there’s a steady stream of rookies. Sometimes a format totally destroys the competition: PDF, JPEG, GIF, etc. (Being first helps, as does being in the right place at the right time.) Other times a new file format results from an actual deficiency for one community in an existing family of widely-used formats. Those formats — such as DNG, JPEG 2000, etc. — have rather more difficulty overcoming the inertia of the majority of data users’ workflows despite their superior qualities.

For example, DNG never really took off the way I had hoped. My Nikon D300′s RAW file is still NEF. As are all Nikon RAW files. And I’m not convinced that there are enough applications that support DNG in my workflow (beyond the obvious Adobe applications) for me to consider converting my .nef files to DNG on import. It’s a funny chicken and egg problem.

Add to this menagerie two new video file formats.

I don’t have a lot of video experience. Still photography was always more accessible and interesting to me, though I have to confess that I’ve been greatly enjoying editing the video from our trip to Australia. iMovie is surprisingly good at what it does, and the video coming out of my point-and-shoot camera is acceptable for reminiscing. I still like the story that a still photograph can tell, but video fits that niche that I always used to fill with babbling during my slide shows.

Anyway, I digress.

I don’t have a lot of video file format experience. Undoubtedly it’s more complicated than I know, but the sense I got was that there are a few widely used file formats — AVI, MPEG, Quicktime — with a variety of audio and video compression codecs, chroma subsampling settings, and bit depths thrown in to complicate what would otherwise be a very simple landscape.

Enter the consumer HD video revolution — partly thanks to a new generation of dSLR cameras — and it seems like we’re on the cusp of another explosion of proprietary file formats. Add in the demands of professional workflows, and you get two new file formats.

Just as it did with DNG for still cameras, Adobe is proposing CinemaDNG as an open file format for storing RAW files from digital video cameras.

Storing, retrieving, and manipulating the RAW pixels in a video frame only goes so far. Eventually those frames are edited, cut and combined with audio tracks. Those frames and audio are mixed with other assets, such as subtitles, alternate audio tracks, time codes, and other metadata. Finally all of these assets are combined with a desired output intent to create a digital or film copy for cinema projection, a television broadcast, a DVD, streaming video, etc.

The Entertainment Technology Center at the University of Southern California (ETC) has worked with industry players to develop an interoperable master format (IMF) that encapsulates audio, video, and effects assets together with metadata and output profiles into a package. Basically IMF is the file-level portion of a digital asset management (DAM) solution.

The details of this encapsulating master format are quite numerous, but the following might be of interest to people who need to contemplate support for reading and writing the imagery portions of IMF. The format is evolving, but as of version 0.82a these were true.

  • IMF is pretty permissive with respect to image dimensions, audio sampling frequencies, bit depths, and so on. There are a lot of “shoulds” in the spec.
  • “Essence files” contain the video and audio assets.
  • Essence files must use ISO or SMPTE standard formats. That’s good news. I hate the reinvention of the wheel.
  • Frame rates must be constant.
  • There are some required standard and nonstandard resolutions and frame rates.
  • Non-1:1 pixel aspect ratios are OK.
  • 8- and 10-bit samples must be supported, and I/O drivers should support 12- and 16-bit imagery, too.
  • 4:4:4 and 4:2:2 chroma sampling is allowed.
  • RGB-709, YCbCr-709, YCbCr-601, and CIE XYZ are supported color spaces.
  • 3-D/stereoscopic imagery must be supported.
  • Compression is recommended, especially visually/perceptually lossless methods (but not necessarily mathematically reversible).
  • Compression must be industry standard and open. In fact, it probably should look a lot like JPEG-2000.
  • Uncompressed data will look a lot like DPX or SMPTE 384M.

Once again this is just the tip of the iceberg of the details are in the draft document. If you like these or don’t agree with them or if you have other suggestions — such as specifying a particular set of options and metadata settings as a “baseline” — do download the spec yourself and comment.


* — For an example of a moribund format, consider PICT from Apple.

Posted in Computing, File Formats, Fodder for Techno-weenies, Photography, Video | Leave a comment

Ten Things I Love about Adobe Photoshop CS5

I just recently upgraded from Adobe Photoshop CS to Photoshop CS5. As you might imagine, a lot has changed in four major releases over the last seven years. I know I should have upgraded sooner . . . blah blah blah.

After installing CS5 over the weekend, I gave it a quick go and was immediately pleased. Tonight I used it a bit more, and now I’m even happier. Who knows how many of these are new to CS5? Not me. Anyway, here are ten things I really like:

Screenshot #1 of Adobe Photoshop CS5
Click for larger.

Screenshot #2 of Adobe Photoshop CS5
Click for larger.

  1. The “Adjustments” panel — I can work on multiple layers without being locked into editing one layer at a time. This makes me sooooo happy.
  2. Photo filters — Yeah, so they’re not real photo filters, since they don’t work on color spectra. But who cares? It’s 2010, not 2020. At least now I can easily make a warming filter.
  3. Adjustment presets — A lot of the curve shapes and levels adjustments are now precooked. Just select the right one from the drop-down list.
  4. Nicer panels — The way to move around and resize panels/palettes is just like I’d expect.
  5. More adjustments shiz — Okay, I guess I really like the adjustment layer improvements, because I honestly can’t remember what I was going to say here. I think it might have had something to do with being able to browse the precooked adjustments. Maybe? I don’t know.
  6. New adjustment layers — Easy to get to, right there next to the adjustments I want to make.
  7. Tabs — Tabs for files . . . Up there on the top, right where they belong.
  8. Action menus — The context menus appear on each panel, and the Photoshop engineers have located most of the common actions in the action menus, making them easier to find.
  9. Workspace browser — I like very much that Adobe is customizing the Photoshop experience for various communities via workspace. Click a button and you’ve changed your Photoshop experience. The panels move around, and (perhaps controversially) the menus change. I’ve saved my panel configuration as my own workspace.
  10. Mini Bridge — Do I like this or don’t I? I’ve never used Bridge effectively before. I used the Mini Bridge tonight to find and load a file; it seemed alright.

And of course there’s stuff you can’t see here, stuff buried in the menus. Some of them are brand new features to CS5, and some — like many of the items listed above — are only new to me.

I can’t wait to see what else is new and how it will continue to improve my retouching and editing workflow.


* — A couple years ago I was part of the Photoshop CS4 beta. As part of that, I used the Photomerge feature to create some panoramas from multiple photographs. I loved it then, and I’m excited to try it out with some photos from Australia. Stay tuned.

Posted in Computing, Fodder for Techno-weenies, Photography | Leave a comment

A Menagerie of Image File Formats

This is a follow-up to my recent post on parsing NITF files that contain JPEG data. It’s basically a crash course into the organization of the guts of image file formats. If I were ever asked to be an expert witness in a trial, it would probably be about file formats.* This is the area of my expertise.

You can divide the world of image file formats into different kingdoms based on the their structure. There is some overlap between these categories, but for the most part image formats are (1) tag/record-based, (2) structure-like, (3) marker/stream-based, (4) textual, (5) card-like, (6) raw, or (7) opaque.

TIFF, DNG, and DICOM are examples of tag/record-based formats. A unique tag identifies the entity in the file and its meaning. For example, a particular hexadecimal tag might indicate that this is the “photometric interpretation” record. The datatype of this record either explicitly appears after the tag or appears in a data dictionary that’s known to the application developer. Almost always, these records explicitly tell the length of their data, which makes it easy to skip to the tag location of the next record.

Microsoft was (for a time) very fond of making structure-like formats. In these formats, the file looks a lot like the memory representation of a C/C++ data structure. These formats are easy to describe and easy to read if you have the structure definition; simply fread() the data into a variable and reference the data members by name. The problems should be pretty clear. You need to be using a programming language that supports C structs. And you need to know the layout of the struct. And once you define the layout of the struct, it’s fixed. (Well, not exactly. Microsoft changed the data layout in its BMP family of formats with every release of Windows, and used a “magic” value to tell readers which struct to use.) All told, it’s a very brittle kind of format.

JPEG is the prototypical — but certainly not the only — marker-based format. Markers are special combinations of bytes that, like a tag, tell what the data is that’s coming next in the stream. But, very much like struct-based formats and very unlike tagged formats, the data that follows the marker can be heterogeneous. In JPEG, the data that appears after the SOF (Start of Frame) marker is a record, while the data that follows an RSTn marker is just a stream of compressed bytes. The SOI and EOI (Start/End of image) markers don’t even have any bytes that follow them. In marker-based formats, semantics and syntax are rather carelessly jumbled together.

It’s very difficult to quickly parse marker-based formats, because often markers don’t specify how much data appears before the next marker. These are very much “streams” of bytes that you’re forced to read until you come to the next marker. Consequently the number and appearance of markers is very limited and this limitation ripples through to the data that they contain. JPEG markers all begin with the 0xFF byte followed by another byte, which taken together specify which marker it is. Consequently, the appearance of an 0xFF byte in the data of a marker has to be escaped by a NULL byte so that it’s not mistaken for the next marker.

Textual formats, such as XML, have the benefit of being self-describing and readable by both humans and machines. Their main drawbacks are the inflated size of the data they contain (even when represented in a semi-binary CDATA hunk) and the inability to quickly skip through them with binary I/O routines.

FITS is a fairly prototypical “card-like” format. As the name implies, these are fixed-length records like one might have encountered on a punch card. For example in format with 120-character records, the first n characters are reserved for the “variable name” part of the equation, while the remaining 120-n characters are the textual representation of the value of the record. They are frequently text-only for the descriptive part of the format with a binary payload at the end. These are easy to read, but a pain to parse, since the “right hand side” values often have to be interpreted.

Raw and opaque formats aren’t very easy to describe because they’re so varied. In a “raw” format (and there are dozens or hundreds . . . possibly more) all of the bytes are jumbled together in a payload-only file. A separate file may have a header that describes the data and helps a reader/parser make sense of the payload. Or not. These are almost always completely free of any helpful description within the file.

This shouldn’t be confused with opaque files, such as HDF, CDF, or netCDF. These formats are completely defined by their API, which for all intents and purposes, you have to use to access the data within the file. This allows for a lot of richness in handling the data contents, which can be organized in highly optimized ways. The downside is that you’re limited in how you can interact with your data to mechanisms someone else has defined. And data permanence can suffer, since if the tool chain changes (or goes out of existence) you don’t really have a way to get at your data.

Practically, each format style has it’s pros and cons. But tagged formats (which might incorporate features of the record style) are the most durable and easiest for third-parties to work with.


* — Cue awesome “CSI” + “Law and Order” + “House” mashup daydream. *DOINK DOINK*

Posted in Computing, File Formats, Fodder for Techno-weenies, Life Lessons | Leave a comment

NITF + JPEG

I’ve recently been working with streams of JPEG data inside of NITF files. Given my experience supporting I/O involving DICOM files that contain JPEG-compressed imagery, I was extremely surprised to learn how difficult it is to read JPEG from “National Imagery Transmission Format” files. This post exists to help the next person who needs to read JPEG data embedded in NITF or another file format.

My naïve idea was to copy the JPEG-encoded to a temporary file and then read that file using the Independent JPEG Group‘s libjpeg library. That’s what I did with JPEG data encapsulated in DICOM. This is far too simple an approach for NITF, resulting in incomplete images. Here’s why:

  • NITF breaks most images into multiple tiles.
  • Each tile is independently compressed into its own image stream.
  • NITF uses “block masking,” which prevents storing unimportant tiles.

The idea makes sense on one level. If you’re going to send an image over a low-bandwidth or low-fidelity channel, you want to limit the amount of data that you send, and you want to avoid an all-or-nothing situation during image transmission or reception. But it’s a total pain in the ass for application developers.

Add to this the fact that JPEG is a marker-based format that isn’t very self-describing, and you have a tricky parsing situation.*

Here’s the basic idea behind getting imagery out of a NITF file if it’s been JPEG compressed. (I assume that you already know how to parse a NITF file — see MIL-STD-188-198A if you don’t — and that you have a JPEG codec that you can use to decode the data.)

  1. The first two bytes of the compressed stream should be the standard JPEG SOI marker (0xFF 0xD8). This is your sanity check.
  2. The next two bytes should be the APP6 marker (0xFF 0xE6). The payload of this marker contains a bunch of useful information about tile sizes and counts, bit depths, etc. Some of this is redundant with what’s inside the NITF file.
  3. The remainder of the NITF file should be a bunch of JPEG codestreams delimited by SOI and EOI (0xFF 0xD9) markers. Each delimited stream is one tile in the image; and it’s a completely standalone JPEG stream. It can be extracted to its own file (if necessary) and decompressed. Tiles are stored across the image horizontally and then down.
  4. If there’s no block masking, it suffices to read each tile in turn and store it in the appropriate region in the output image.
  5. If the NITF file does use block masking, use the values in the BMRnBNDm attribute of the image subheader to find the locations of the blocks that contain actual image data. The masked out blocks will have 0xFFFFFFFF values. The other values — there’s one for each tile — are 0-based offsets pointing to the SOI marker that starts each tile, relative to the start of the JPEG compressed data.

And that’s it. After coding, you should probably test out your parser on the sample NITF files provided by the NGA.


* – You can divide the world of image file formats into different buckets based on the their structure. There is some overlap between these categories, but for the most part image formats are (1) tag/record-based, (2) structure-like, (3) marker/stream-based, (4) textual, (5) card-like, (6) raw, or (7) opaque. I’m going to write more about this in the next post.

Posted in Computing, File Formats, Fodder for Techno-weenies, Life Lessons | Leave a comment

Buckshot o’ Links – Software Development Edition

I’m a hoarder. I may not have lived through the Great Depression like my grandmother did, but I seem to have inherited the gene that led her to keep dozens of plastic Cool Whip tubs in her attic “just in case she needed them.” My grandfather kept used bolts and nails for reuse. Me, I keep articles about things I think I should know some day. From smart people on Twitter and e-mail lists and coworkers I gather links to articles, PowerPoint presentations, blog posts, and videos. And they hang out in my browser tabs — forever.

It’s time to clear some of them out. Here are some daytime-themed links. (If I had a Tumblr account, I’d just post there. But I don’t need another website no one reads.)

Parallel Computing
James Reinders of Intel TBB fame estimates that datasets (images, videos, etc.) have grown 10x larger over the last five years. Sequential systems are just too dang slow to process this amount of data. In the near future, “parallel programming” will just become “programming.” (I’m still hoping for better language support so that state synchronization and multicore memory issues are as easy to get right as the sequential aspects of programming are now.)

New memory models would certainly help. A new paper, DMP: Deterministic Shared Memory Multiprocessing by Joseph Devietti, Brandon Lucia, Luis Ceze, and Mark Oskin presents some of the problems with the current memory model and provides one possible solution.

Another post on SoftTalk (sponsored by Intel) describes some of the ways that Intel plans to make parallel programming easier this year: Parallel Studio 2010, a Cilk-based offering for task parallelism, “a data-parallel centric model with safety guarantee,” new SIMD instructions, and new array notations.

You might also want a high-level view of how Intel’s offerings work together.

Herb Sutter, who really knows his stuff, wrote an article for Dr. Dobbs a couple years ago about understanding parallel performance. It’s one of a series of articles about multicore/multithreaded programming, and this helps set expectations about what’s possible and gives pointers on where to start making changes.

Miscellaneous
Visual Studio + Time Machine = IntelliTrace. Don’t just move up and down the call stack; now you can move forward and backward in time, too.

Everything you ever wanted to know about floating-point representation: Floating Point Guide. (Everything, that is, unless you work where I do. Then you just have to go down the hall to get that last 2%. Of course, you’ll be drinking from the fire hose. . . .)

What does Microsoft think are the key trends in software development? Cloud computing, the web as a platform, parallel computing, proliferation of devices (with their own capabilities, IO paradigms, etc.), agile development processes, distributed development. Nothing terribly futuristic here, and comments want to know why “mobility” (i.e., phones) isn’t on the list.

The C++0x “final draft” revision is ready for “final” comments. Here’s your chance to see the significant changes to C++ that will be part of the standard next year (they hope).

Posted in C, Computing, Fodder for Techno-weenies, Hoarding, Software Engineering | Leave a comment

Checklists

We use checklists a lot at work. They help us reduce waste and ensure a high quality product. If we’ve run into a problem before, we’re likely to run into it again, so we might as well go down the checklist of “Did you think about this?” and “Did you do that?” items before submitting code into the repository.

But our checklists have gotten a little long and messy, which raises the risk that people won’t use them at all. Part of my job is to improve our team best practices and checklists, so I’m working out how to make all of those checklist-bound countermeasures fresher and more accessible.

So I’m very hopeful that Atul Gawande’s The Checklist Manifesto: How to Get Things Right, which arrived on my desk today, will give me some in-the-trenches perspective. I’ll keep y’all posted on what I learn.

Posted in Book Notes, Computing, Life Lessons, Software Engineering | Leave a comment

Generating globally unique values on Linux

I may expand this later. . . .

Query the file /proc/sys/kernel/random/uuid for a globally unique value. It produces a new value on each read. For a globally unique value that’s persistent between machine startup, query /proc/sys/kernel/random/boot_id.

[earth:/]120 % cat /proc/sys/kernel/random/uuid
78345a49-875f-48d3-aa80-130db5e57991

[earth:/]121 % cat /proc/sys/kernel/random/uuid
d258123d-f2bd-49c0-89d6-e4db5d377776

[earth:/]122 % cat /proc/sys/kernel/random/boot_id
e58a255a-0f6c-418f-ac0b-0fac81a5ff4a

[earth:/]123 % cat /proc/sys/kernel/random/boot_id
e58a255a-0f6c-418f-ac0b-0fac81a5ff4a
Posted in Computing | Leave a comment

MATLAB and Greenspun’s 10th Rule

Just to get this disclaimer out of the way, let’s remind everyone that this is my personal website. Even though I may write some of the articles at work about things I’ve done at work, they aren’t in anyway supervised or endorsed by my employer. I’m only including this disclaimer because this article is meant to be self-deprecating in that “I had the best of intentions, but now I feel a little silly” way.

Several years ago I read Greenspun’s Tenth Rule of Programming: “Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.” Basically it’s a joke about feature creep in software. I was reminded of this quotation today when I started reading Joshua Kerievsky’s Refactoring to Patterns. He describes the perils of over-engineering, which is basically the same as wasting money.

You see, about seven or eight years ago, I added a Lisp parser to a feature in MATLAB’s Image Processing Toolbox. If you have the toolbox, just take a look in toolbox/images/iptformats/private/dicom_create_IOD.m. There you’ll see a part of the code that looks like this:

function tf = check_condition(expr, metadata) %CHECK_CONDITION  Determine whether a condition is true. % %   Conditions are LISP-style cell arrays.  The first element %   is a conditional operator, remaining cells are arguments %   to the operator. % %   Conditions can be nested.  Each cell array in expr indicates %   a new conditional expression. %[snip] % % Process conditional expressions recursively. % switch (lower(operator)) case 'and'         % This AND short circuits.     for p = 1:numel(operands)         tf = check_condition(operands{p}, metadata);                 if (~tf)             return         end     end [snip]

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’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 — you know — 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.

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 dicom_modules.m file in the same directory to see how to express those conditions.) But for g-d’s sake, ask yourself if you really, really need that, or if you aren’t just fooling yourself into over-engineering your code.

Posted in Computing, Life Lessons, MATLAB, Software Engineering | Leave a comment

AMD performance counters

Here’s a little reminder for myself and for anyone on the web who’s searching for information about AMD Athlon and/or Opteron performance counters.

AMD Performance counter resources:

Less techie posts to follow . . . honestly.

Posted in Computing, Fodder for Techno-weenies, From the Yellow Notepad, Software Engineering | Leave a comment

Rememberance of things past

This has been the busiest year ever. True, last year I was in school and (consequently) working twice as much. But this year, I’ve actually gone places and done things that have generally kept me away from posting here.

In January, I went to the Electronic Imaging symposium in San Jose, promised to write about what I learned and then did not. In February, I went on a “business trip” to Cozumel — via cruise ship — and then posted some of the photos I made on my Holga camera. Then in March, Lisa and I went to Paris to celebrate my graduation. I could talk your ear off all day about how much I love Paris; and if you’re Lisa, you’re probably sick of hearing me walk around the house sighing and saying “I miss Paris.” (Sorry!) Most recently, I promised to post pictures from my backpacking/camping/hiking trip to Utah. I did put some of them into a photoset on Flickr, but I haven’t gotten them here yet. Tomorrow I’m off to Iowa for a family reunion.

“But what about the other 15-or-so weeks of the year? Why no posts?”

It isn’t that I haven’t had any ideas. Here are some of the things I jotted down that I should write about:

Physical architecture vs. software architecture, with respect to the visibility and communication of design — I actually started writing a bit about this after some lengthy conversations with coworkers. Basically, I yearn for the day when software engineers can have books like this, this, and this. We need a shared visual grammar, shared materials, and shared processes so that we too can have coffee-table books that inspire our cohort.

A response to Jeff Atwood on (not) reinventing the wheel again . . . and again — Given what I just wrote above, it’s no surprise that I would be disappointed after reading an article that advocates waste. I hope one day to live in a software engineering world which is more like a real engineering world, a world in which there are two kinds of software businesses: (1) the businesses where almost everyone buys off-the-shelf or special-order parts and uses them to build incredible things, innovating very broadly and (2) the businesses that specialize in making those off-the-shelf and special-order parts, making them well, and innovating very deeply.

Design blogs — I’ve been making a little list of design blogs that I like. . . . I’m a total tease, though, so I’ll share them later.

My notebooks — One of those afore(un)mentioned design web sites has an occasional series looking inside designers’ notebooks. (For example.) I keep most of my thoughts (and some designs) worth remembering in journals and took some beauty shots of them. I’ve actually downloaded the photos off my camera into Lightroom.

French music — The French are different. Especially in their musical tastes. I like some of it and thought about shilling for folks like Mylène Farmer, Mara Tremblay, A.D.N., Abd al Malik, Karna, MC Solaar, Cœur de Pirate, Alain Bashung, Dumas, Karkwa, Noir Désir, Prototypes, Vulgaires Machins, and Indochine.

Women in Software Engineering — Though I’m not part of the Ruby/Rails communities I was disappointed to see the kerfuffle over a recent presentation which reminded many of us how few women there are in our profession, how they’re often (subconsciously) typecast, and how their accomplishments don’t often get enough attention. So here are some belated congratulations to Barbara Liskov, winner of the most recent Turing Award. And I like Liz Keogh’s web site.

My grad program — In a nutshell, I enjoyed my time at Brandeis as I worked toward my master of software engineering (M.S.E.) degree. I learned a lot of practical things related to software construction, tooling, and process (just as I hoped that I would).

And finally, Lent and my year-long cleaning project — After graduating I looked around my office/library and was shocked at how cluttered it was. So just before the new year, I resolved to get through all of the magazines, papers, articles, etc. in my big cardboard “in-box” — seriously, it’s big — by the end of 2009 and recycle whatever is left on January 1st, 2010. My progress is slow. (I’m being very generous to myself right there.) So for Lent I decided to better myself by working on my reading pile. In particular, I forbade myself to add more things to it. Basically, I’ve gotten to that point in my life where I need to put myself on an information diet or two. Which I’ve done, although I find myself snacking a lot.

Anyway, that’s what I’ve been doing: reading from the big in-box, watching some of the 499 films in my Netflix queue, reading other people’s web sites*, writing in my own journal, photographing, gardening, carpooling, and more-or-less not writing here. More to come, eventually. . . .

*   Thanks for nothing, Facebook and Twitter! Just kidding. You know I love you.

Posted in Computing, General, Software Engineering, Travel, Worthy Feeds | Leave a comment

Surveying Quality in Object-Oriented Design

Just a short post informing you about a survey paper I wrote for my object-oriented (OO) design class: Surveying Quality in Object-Oriented Design. In it, I look at the major books and articles concerning best practices for OO design. If you do OO programming, you’ll probably find something interesting. (It’s language-neutral, too.)

The major goals of using object-oriented design are to facilitate the maintenance and extension of software systems by reducing the complexity of software at the class and system level. Successful OO designs are resilient to change, largely because they manage interclass dependencies. In such a system, changes to one part of the system are localized and do not cause a chain of modifications through the system.

The major techniques that OO designers have at their disposal are abstraction, encapsulation, inheritance, polymorphism, and composition. But how does an engineer apply these techniques to create a good design? What are the main ways that sets of classes can be structured and interact to maximize the chance of a successful design? Over the last twenty years, numerous OO practitioners have developed a mature set of rules-of-thumb and best practices to use when constructing and evaluating OO design.

If you celebrate it, enjoy your Thanksgiving tomorrow. Don’t do any homework if you can help it. I won’t!

Posted in C, Computing, From the Yellow Notepad, Software Engineering | Leave a comment

Announcing a Series on Design Patterns

The first week of my final semester of grad school is in the bag. This go-round is all about software design, both low-level (“RSEG 109: Object-Oriented Design“) and high-level (“RSEG 290: Special Topics: Design Patterns”). When you add in the reading group we’re starting at work, this could also be called the “UML semester.”

Design patterns give a shared vocabulary for talking about common software design features, present how and when to use a design, and lay out the trade-offs of using a particular design. They aren’t as widely used as they should be in a profession that claims to value reuse. I think that’s a shame.

As part of the design patterns course, I must create an object model for a real-world problem. And along the way, I’ll be learning about most of the two-dozen OO design patterns in the Gang Of Four book. (Usually I don’t present solutions to my homework in public because I feel it could help the next semesters’ students cheat; but this semester we’re each doing our own thing.)

Since I’m learning about them, I’ll do my best to write about them over the coming weeks. If all goes well, I’ll have an outlet to reinforce what I’m learning; and you, my dear readers, will have a gentle on-ramp to design patterns, too.

Here’s the description I submitted last night of the software system I will design:

I will apply design patterns to a simplified web content management system, colloquially known as a “blog.”

While blogs frequently are vehicles for cute kitty photos, angst-filled teen poetry, and ill-informed political shouting, this CMS will not know anything special about its content. Here’s what users will be able to do with it:

  • The blog author(s) will be able to write new articles and edit them before publishing.
  • Authors will be able to preview articles before publishing.
  • Authors will be able to post articles and have them appear on the web.
  • Authors will be able to edit articles after they are published.
  • The blog’s readers — supposing there are any — will be able to post comments in response to articles.
  • The CMS software will display the following elements: static text, linked images, embedded objects, and dynamically generated content.
  • Authors can activate/deactivate “plugins” that implement a well-defined API.
  • Authors will be able to change the appearance of the blog by selecting from an arbitrary set of “themes.”
  • Readers will be able to display single articles or an archive of articles showing a full month of articles.
  • Readers can navigate from one article (or set of articles) to the prior or next article (or set of articles).
  • The author can choose whether the CMS stores articles in a database or in a flat-text file.

So keep tuning in, and we’ll take a tour through design patterns for object-oriented software reuse. And please post comments about where you’ve been able to use design patterns successfully, if you see anything you would have done differently, or if you just want to leave your two cents.

Posted in Computing, From the Yellow Notepad, Software Engineering | Leave a comment

Photography Podcasts

I am a serious podcast junkie. I currently have over 16 days of unheard podcasts. News, arts and culture take up most of my bandwidth.

Recently — and by that I mean the last few months — I’ve been working on two big podcast series.

Earlier in the summer I finished listening to Jeff Curto’s excellent History of Photography Podcast. As someone who liked school, loves photography and dabbles in history, I found myself really getting into the fifteen-part rebroadcasts of Curto’s college course.

I can hear some of you out there now. “But, Jeff, it’s an audio podcast. And photography is an inherently visual medium. How does that work?”

Well, the podcast has two things going for it. First, the podcast is enhanced with a lot of photographs, which are in sync with the lecture. Furthermore, Prof. Curto is a very gifted lecturer. He describes the photographs quite well, along with the ideas they contain and the artists who made them. (It probably helps that I had previously seen many of the photographs, too.)

A new semester of classes just started, so consider subscribing to it.

I also want to mention Adobe’s Lightroom podcast.

I love Lightroom! It’s a brilliant piece of software for photographers, taking all of the most important parts of Adobe Photoshop that a photographer needs, adding superb image management features, and putting it within a user interface that emphasizes workflow. It challenges the widely held view among geeks (and probably most software users) that powerful software has to be difficult to use. It makes me want to write better software myself.

So what’s so great about a podcast about Lightroom? George Jardine, formerly the product manager of Lightroom, brought together a diverse group of people during the public betas of Lightroom and had them talk about a bunch of subjects that really interest me. Professional photographers discussed photography and their digital workflows, which gave me ideas how to improve my own. A couple of analog printmakers took the long view, helping me think about how to make better digital prints. And then there were the software engineers.

Software engineers? Really?

Yeah, it sounds odd, especially since I try to keep my photography discussions about art and not about gear or f/stops or color profiles or pixels. But . . . I know a few things about image processing, color science, and software engineering. And I know how hard it is to make really great software. So I really appreciated being able to learn tidbits from people with more experience than me, as they talked about the things that interest me. And these guys aren’t just dilettantes. No, these Adobe engineers are deep into it; they know the trade-offs you have to make in the real world when implementing image processing and I/O algorithms. And did I mention that they worked really, really hard with Lightroom to get it right.

If you use Lightroom and want to get some ideas how to use it more effectively, you should listen to the podcast. Or if you just want to hear about the evolution of a software project, it’s also for you.

Finally, check out Edward Burtynsky’s SALT lecture on the “10,000 Year Gallery”. The SALT (Seminars about Long Term Thinking) podcasts by the Long Now Foundation cover a wide range of subjects, all of which attempt to get us to think on a millennium-long timeframe. (At first I thought it was something like a cult or a Burning Man-esque art project; but now I see it for what it is: transcendent, if somewhat eccentric.) Anyway, Burtynsky is helping create a gallery of photographs about who we are today that should last at least 10,000 years and will be installed inside an enormous clock that will toll every 10,000 years. Seriously… Not the most exciting podcast episode, but in general the whole seminar series is worth listening to.

Posted in Computing, Fodder for Techno-weenies, History, Photography, Software Engineering, This is who we are, Worthy Feeds | 1 Comment

Quickly Finding Numeric Patterns in MATLAB

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’s strfind function, except more general than looking for substrings in strings.

So I wrote a rather naïve algorithm to do just that. It wasn’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 one of my coworkers for tips with a faster implementation.

Turns out the strfind works just as well on numeric arrays as it does on strings. And it’s really fast, too.

% "data" is a 1,200,000 element UINT8 array. % It contains 29 instances of the pattern. tic; offsetTable = strfind(data, [254 255 0 224]); toc % Elapsed time is 0.027390 seconds.

Update: Loren Shure posted an even better solution on her blog.

Posted in Computing, MATLAB | 2 Comments