Archive for the ‘Hacking’ Category.

QR code stencil upmanship

As far as I know, I was the first person to publish a generalizable method for creating a QR code stencil or to even clearly document why such a method was difficult.

However, since that time, I have realized that other approaches would ultimately be superior. The two I have been pursuing are automated embroidery of qr codes and improved stencils using laser cutting or 3d printing.

I will likely be abandoning the latter work, now that my early attempts have been eclipsed by Golan Levin at the Studio for Creative Inquiry at Carnegie Mellon. This work is being released from fffff.at, whose motto is: release early, often and with rap music.

Here is a link to his post on his new laser-cutter QR code stencil generation code. Along with his first application, a remake of hobo-coding.

Golan gave me a shout-out on the post he made. In some ways, it is hardly justified, since his method obviously surpasses my chicken-wire method in several ways. In fact, the only outstanding benefit to my method now is that it is much cheaper, and you do not need access to a laser cutter. The codes generated from his method are cleaner, and could probably be made smaller than my methods, and do not require an hour of working with caulk.

In a private email, he mentioned the possibility of a githib release soon…

In any case, take a look at the wonderful photos of the stencil in action.

Programmable Self Reading List

Hi,

I am preparing for my talk at Quantified Self about my work on Programmable Self. I was asked to make a “reading list” for the people who were interested in this subject so I wanted to create that here. Please add links in my comments section for titles that I have omitted!! Requirements for inclusion are simple. Anything that applies to using technology to change your own behavior. I would also suggest that you get a kindle from Amazon. Kindle will run as software on the iphone, ipad, and android, as well as OS X and Windows. So you do not need to buy a new device if you do not want to, but buying the kindle edition of the following books will probably save you more than $100.

My goal here is to have something relevant no matter what your background. If you are a behavioral economist, then there is some cool gamification stuff here. If you are all about gamification, then there is some cool behavioral economics stuff here… Please help me make this list even better with comments!! (thanks to Lesath for pointing out a broken link!!)

While there are some “gamification” books here, most of this has to do with recent research into human motivation.

I would also take a moment to check out BJ Fogg’s work from the Persuasive Technology lab at Stanford. What I like about BJ’s work is that he seems very focused on making simple models for clear communication. BJ did a good job convincing me that most people have something different in their head when you say “behavior” or “engage” or “change”. Given that, you need a kind of simple vocabulary for talking about what behavior intervention your are discussing. So you should understand the following basic concepts.

I will add more links as time goes on. What did I miss? Leave me a comment with your favorite resources for behavior change.

-FT

Hacking data: showing patterns in kids health

Here is my submission for the Local Children’s Data Health 2.0 developer challenge. The challenge was to make data available through kidsdata.org come alive.

Generally, the red circles correspond to the percentage of child allergy suffers who had -seen- a doctor, but had no specific plan to address their condition. The red tags, are healthcare providers from the NPI database that are listed as experts in kids allergies… the top of the field for asthma treatment. We are using these “super experts” as a proxy for the availability of specialist care for allergies generally. Notice the under-served areas… The specialist are clustering in the high-population areas. Hopefully this map will inspire an expert to move to Eureka, or Santa Maria..

Here was my process for this for my hack:

  • I would only use Open Source software or Open APIs. The idea here is to show just how powerful FOSS tools can be in health data analysis.
  • I have just created the best API to the National Provider Identifier database at docnpi.com, so I have this rich datasource that previously has not been available as an API.
  • I wanted to target something from kidsdata.org that was directly related to the availability of healthcare, something that you can measure geographically using the docnpi.com API.
  • I chose Asthma, because this is something that clearly responds to treatment.
  • I wanted to document my process to show how easy this kind of analysis is with the right tools.

Ok here’s what I did…

  1. First, I browsed kidsdata.org for asthma information. That leads you straight to this analysis of asthma hospitalizations for young children over the last few years.
  2. Then I started digging for source data. It looks like the California Health Interview Survey was a substantial source of the data.
  3. They offer Public Use Files of the original survey data. I signed in, and the terms of use for the data were reasonable, and not contrary to my purposes or Open Source. So I signed up and went to download the data.
  4. Sadly, the data was only available in three proprietary data formats, Strata, SPSS and SAS. This was obviously designed for academics that think using proprietary software is ethical and normal. Thankfully there are other options. The R project is where I usually turn first for stats help, but I actually found that there was an Open Source SPSS alternative called PSPP. Using PSPP I was able to open the SPSS data file. Victory for Open Source! It would be nice if organizations like CHIS would release in simple XML or CSV, which is much friendlier to hackers and people who believe in software freedom.
  5. My feeling of elation was short lived. The data had no geo-coded information. Which makes sense, that would make re-identification much easier. There had to be another way to get geo-coded data.
  6. And there was. AskCHIS is a powerful data reporting tool that allowed for xls data download. Again, I am amazed that CHIS would chose to run with a proprietary format without an open alternative. They used alot of advanced xls layout options that meant that an export to CSV would never work. An API would be even better, but at least CSV would allow me to actually parse a file instead of cutting and pasting which is what I ended up doing.
  7. But I had access to lots of data. I could see several different measures of asthma that I could have used in my mashup. This included lots of stuff like missed school days, emergency room visits, diagnosis of asthma, symptoms in the last twelve months… etc etc. If CHIS had given this data up using an API, I would have been able to merge the various asthma measures into an overall asthma status score… but it would have take a week of cutting and pasting to do that manually.
  8. So I had to choose one data point and run with it. I chose “Health professional ever provided asthma management plan“. This was asked to parents whose kids already had a doctor who was “treating” the asthma. I thought this was an interesting question because it seemed to correlate strongly with doctor-availability, something that I had good geo-coded data on.
  9. Now what provider data should I compare it to? Using docnpi.com I can easily grab a list of all/most of the doctors in California who specialize in treating allergies in children I decided to use that as a proxy for “available allergy specialists”. Of course, I had a serious advantage here, because I had already done the work of changing the NPI database into something I could access using an API (that is the idea behind docnpi.com). This easily saved me 30 hours of work on this project alone.
  10. So now I have the data I want… but what now? I had addresses for the doctors and clinics from the NPI database, but the asthma data was coded by county. No problem, I just needed to geocode the counties into longitude and latitude. If I had a rich data source from CHIS, it would have been worth writing a script to do this, but since I was using cut-and-paste data, with about 75 rows, it was much simpler to just manually geocode everything. Which is what I did. More cut-and-paste.
  11. But now I have geo-coded data for both data sources.
  12. I needed a method to graphically display geo-coded scoring. This is pretty easy to do using proprietary GIS tools, even costless tools like Google Earth. But I wanted to keep things simple and Open Source at the same time. Enter the EInsert extension to Google Maps API v2. This allowed me to overlay png circle graphics on a Google Map, and size them in accordance with their percentage (bigger is worse, it means more of the kids did not have asthma plans).
  13. Then something tickled my brain. Using circles to represent scaled data is problematic. There is solid research indicating that humans have trouble estimating the area of circles in relation to each other… So I used the ratio suggested by James Flannery to counter this effect. Now the circles are sized in a way that indicates their relative meanings in a somewhat more appropriate way.
  14. Now I had a Google Map that displayed data regarding the frequency of plans as meaningfully sized circles over the California state. This data shows some predictable effects. First, the worst areas are either very urban or very rural. Exactly the places that have trouble attracting medical talent. That means that on this map, Ureka and Los Angeles urban counties have similarly sized circles.
  15. Now all I needed to do was overlay the doctor data on this map. This turned out to be pretty simple. I already have a link to provide a Google Map display of any small search on docnpi.com. For instance, here is the link for the map for the search on allergists in California. All I needed to do was copy the html and javascript for the doctor map and integrate the map with the Asthma data map I had already made.
  16. So far, that maps looks pretty good. However, there is no easy way to tell which county, specifically, a given circle represents. I decided that the simplest way to address this was to dynamically rewrite the png using the gd library of php. I would pass the php script a label, and it would generate a circle with a label on it. This would allow me to label all of the circles on the map. As usual, stackoverflow provided a quick and dirty solution. (update 4-20) I realized that the label should show both the name of the county, and the percentage without a plan… now it does.

Take a look at the final result.

Notice that the shapes scale automatically as you zoom in. Try zooming in to Los Angeles or San Francisco to compare the compacted counties more closely. Also note that you can actually get the name of particular doctor that specializes in the treatment of asthma directly from the map. If you click the link you can get all of the contact information from docnpi.com

Which brings us to the point of this exercise.  A better view of the data can prompt change.

If you are a parent of a child with Asthma in one of the “big circles” you need to know that the long term treatment of Asthma requires a plan. If you do not have a plan, the reason might be that there are not enough doctors around you to provide the help you need. This map can put you in touch with the nearest expert.

If you are a doctor, who specializes in childhood allergy treatment, this is an opportunity map for you. Eureka is much smaller than LA or San Francisco, but you would have a near monopoly on a population that needs help with asthma. These people do not have the same access to specialized care and that might be a business opportunity for you. Moreover, a doctor who chose to focus on the urban areas in the larger cities might also be able to gain patients and profit. The data here shows that while there are lots of experts -around- the densely urban areas they are not meeting the demand for care. If a doctor could find a way to make money on a Medicare/Medicaid population in these urban areas, this might also be an opportunity.

Seeing the health data in a new way can provoke change. I hope you think my application is cool and sexy, but frankly I do not give a damn about that. I want to make a difference, not toys.

People remember Florence Nightengale as the mother of modern nursing. But she once made a diagram that changed the way people thought about war. It was that diagram that gave her much of the political clout she needed to create the field of professional nursing that we know today.

I have made the NPI data more liquid with docnpi.com. Organizations like CHIS need to a much better job of making their data accessible. If I had been able to access the data from AskCHIS in a normalized and open format using an API, I would have been able to make mapping system that would allow the overlay of -any- type of doctor with -any- health data measure that they survey.

So that leaves me with a call to action for three groups: Patients -> find better care near you. Doctors -> go where the patients need you. Researchers -> expose your data in open formats using APIs and open file formats.

Of course, I publish my source code under an Open Source license. Enjoy.

-FT

QR code stencils, the problem

I love QR codes.

I think the notion of simple graphical URLs is beautiful and elegant. If my wife were a graphical data object, I think she would be a 2D QR code.

Think of it, you can put links anywhere you want, in the real world!

You can put them on tshirts, coffee mugs, stickers, business cards… anything in the real world becomes a link to something in the virtual world. Awesome.

I have been playing with QR codes, with an eye towards gamification and behavior change for quite some time. I love the fact that with android and/or iphones you can rely on the GPS coordinates that webkit (the core of both browsers) will provide, makes a QR code a token that can do different things in different places. Think of the possibilities!

You could make geo-caching much much more interesting…

But how do you make durable (or intentionally not durable) QR code in a reproducible way? How do you manufacture large QR codes, that can be scanned accurately at a distance?

The first approach is simple to print the QR codes on either single sheets (A4 or US letter) and then clear paste them to some type of flat surface. You can use throw-away planks of wood from the hardware store to make durable QR code links. But what if you want to make a QR code on some permanent surface, like a wall or pavement. This basic idea can be taken pretty far, for instance you can paste the printed QR codes into ceramic tile or even bake it on, for a near permanent tag.

The simplest solution would be to use a stencil with black spray paint. QR code scanners vary greatly in their ability to pick up contrast, but the color black, and some other color, will almost always pick up. This has an advantage over gluing paper, because you can tag objects that are not entirely smooth. Moreover, with spray paint that does not damage the surface (more later) you can create images that can be placed out in public, non-destructively.

But what is the problem with a QR code stencil? In a word, islands. In order to make a stencil with, say, photo paper (which would otherwise be a great technique), you need a way to address bits that the stencil needs to block, that are not physically connected to the rest of the stencil. Its easier to show than explain. If you are spray painting black, for instance, and you want to make a stencil of the following QR code, you will have the following trouble spots:

A demo of the QR code islands that make stencils difficult

See the issue, the two anything white, that does not connect to something else white (even by a corner) is going to be an issue. You might be able to make something clever for the places where this happens in most/all QR codes, but each QR code is going to have random “islands” that are often just one pixel big… and in different spots each time. These are the real headache. Making a traditional stencil simply will not work.

Also, making a stencil is very very slow. If you have to cut each pattern by hand.. ouch… way to much time. We need something faster too!

My first approach to solving this problem was to try and find a programmatic solution. For a given URL, there are many different ways to encode into a QR code. It might be possible to use an algorithm that detects this type of “island status” to find a QR code solution that did not happen to have any islands. You could make an application smarter by posting meaningless GET variables at the end of a URL until you found a version of the URL that would work (of course, I am focused on using URL shorteners like bit.ly to ensure that you have a simple-as-possible QR-code. The more character in the URL, and the more complex the QR code is and the harder it is to make a stencil. The shortener ensures that the QR code is manageable.

I gave up on this technique after noting that there were islands in all of my test runs for various URLs, but the idea is sound.

Facebook Places powers the first social election game

Today, Farrin Anne ‘Crane’ Gustafson, the manager of the social media strategy for the Clayton Trotter (my father) congressional campaign became the first person in history to use Facebook Places to check-in to a new kind of application: a social election game. She earned the “At the Voting” badge by checking-in using Facebook Places as she early voted today on the first social election game that I have been frantically coding for the last few weeks. The game concept is simple: it rewards real-world political activity with points and badges. There have been a lot of discussion about how Foursquare et al. might be used politically. This is especially true of Gowalla, which has been targeting politicians.  There are also people who have talked of using a facebook game to energize supporters. But as far as I know, my application is unprecedented for the following reasons:

  1. The application is the first to allow its users to specifically earn badges for checking-in at polling stations during voting. This is much different then using the application to mark political rallies etc etc. Obviously, you do not have to vote to get the badge, you do not even need to be of voting age, or registered to vote in the state. All you have to do add the application on facebook, check-in at a polling station during voting (even after hours) and you get credit for the badge. Of course -most- of the people who do this will be registered voters who want to essentially participate in -perfect- exit polling.
  2. The application is built directly into facebook. That means that a users “check-ins” are something they can share directly with their facebook friends. There is no longer any need for a third-party application, or the need to limit the reach of the application to the very very few users of the geo-game like foursquare. This is an app for everyone on the largest single social network.
  3. You can check your friends in when you vote, and that counts too. So one iphone+facebook application can support several different users.
  4. The game does not just support check-ins. You can sign up for vote reminders, get credit for volunteering, and most importantly, use the application to provide a structured endorsement on your wall.
  5. Because it is powered by the facebook social network, you get full credit when your friends score. When your friends show up at the polling station or sign up for a vote reminder, you get credit too. You “win” by cooperating to get the candidate elected. Because there is a powerful proxy for detecting real votes (polling station check-ins), it will be easy to tell who the “vote influencers” were.
  6. The design of the application allows for a deep integration with the ability for the crowd to communicate back to the candidate. If my father is elected, he will be able to use the application to mine the facebook social grid and engage with his constituents in a fundamentally new way.

I believe that all of these elements together (and not just GEO apps or just political games) are the foundations for a new class of facebook game: For now I am calling them social election games. I believe they are the future of politics.

Up until now political power in the United States came from essentially two places: sources of money and sources of fanatical single-issue voters. Democrats cater to different type of unions. Republicans appeal to evangelical Christians. Democrats appeal to environmentalists. Republicans appeal to big business. Each small group would either deliver either a small cache of extremely loyal voters, or expensive advertising, or both. People who were able to directly influence candidates and politicians were either donors, or the leaders of these extreme groups. In short, the people with political influence in this country have become those with agendas that are generally out of sync with anything remotely mainstream. I made it clear, in my endorsement of my father, that I do not agree with all of his extreme views. I support him primarily because I know he will be more careful with defense spending than his opponent has been, and that is a very important issue to me.

I feel out of sync with my fathers extremely conservative positions and I feel (slightly more) out of sync with his opponents extremely liberal policies. They have done well as candidates because they have appealed to the extremes. I know of no reasonable person who agrees with either candidate on all of their political stances. (I am aware, and intend, the implication that if I know you and you agree with my dad 100% that I think you are unreasonable; and that my father, in the sense that he obviously agrees with himself entirely,  is also unreasonable. Given the Tea party energy, me saying that my father is unreasonably conservative, will do nothing but help him. I endorsed my father because he was -more- reasonable than his opponent, not because he was reasonable. Frankly, who thinks of their own parent as ‘reasonable’ in any case… I mean really…)

American politics as a whole suffers from the Myth of Polarization. We have turned politics into a kind of entertainment, something like pro-wrestling. Listen to any televised political commentator and tell me they do not sound like they are going to break out at any moment with “aaaarrree you ready to ruuuuuuuumble?” and then present the surprise cage fight…

Why do we have this kind of environment? Because that kind of low-brow drama gets people to vote. But what if we had a different way to get people to vote?  What if we could have simple, polite conversations with our friends about who the next sheriff or Congressman should be? I think if those conversations were easy, if they were simple and if voting itself were a fun process, then we might see a trend back to center. A trend away from blood-sport politics. In this world, the wielders of influence would not be the arch-bishop, but the local priest, with 300 facebook friends who actually trusted him as a human being. Instead of caring about who the chief of police voted for, you would care about which candidate the policeman who lives down the street from you (with 354 facebook friends) endorsed. Instead of caring about who the national teachers unions endorsed for president, you would care more about your kids third-grade teacher (54 followers on Twitter). Instead of caring about some insane radio talk show host, you might care about the opinion of an intelligent college kid from South Dakota with a podcast followed by 300 people.

In this hopeful/hypothetical world, real-world trust relationships, enabled by virtual social networks, will become the new political currency. I want people like my father and his opponent to care much more about someone who has 1000 followers on facebook or twitter, and has shown that 730 of those followers take their endorsement seriously, than the person who can pay for a political ad for them for $100k.

The whole point of social media is that it is -not- a broadcast medium. It is an engagement medium. No matter who wins the election in the San Antonio ‘Alamo’ district in 2010, this application is a template for something much much bigger. The irony is that now that I have proven that it is possible, others will try to mine this for a profit. I will have none of that. After the election, I plan to Open Source the code. I plan to start a project to enable a whole slew of social election applications for different groups and for different interests. This open source project, (which is looking for a project manager) will keep the goal of bringing reasonableness back to politics as a central design goal.

P.S. Polls indicate that the election between my Clayton Trotter (my father) and Charlie Gonzalez will be very very close. I honestly think this application might tip the scales in my fathers favor.  How cool is that?

(Update 11-22-2010) P.P.S Sadly, my father lost to Congressman Gonzalez… oh well..

Happily it does look like this game might be on to something. It was featured on some of the top tech blogs:

http://www.insidefacebook.com/2010/10/24/social-voting/
http://gigaom.com/2010/10/22/if-voting-is-a-social-game-will-it-make-democracy-better/

Pretty cool!!

How to add a new place to Facebook places

Soon, I will be making an announcement about some work that I have been doing with the Facebook places API.

For now, I want to give a little tutorial on how to create a new place, in Facebook places, using your iphone Facebook app.

First, you have to download the facebook application from iTunes, or get someone to help you do this. This tutorial assumes that you have the facebook application already installed… if you really need help with this, go to the Mac store and talk to someone there… should be pretty simple…

The first step is pretty important:

Go to where you want to create the place!

So click on the facebook application to start…

Click the facebook application

Click the facebook application

This will pull up the home screen…

This is where you typically start

This is where you typically start

You can also get to the checkin menu from the main facebook menu in two steps:

This is the main menu, places is right in the middle

This is the main menu, places is right in the middle

After clicking there you will see the main Facebook places interface where you can see your friends recent checkins..

This is the central places interface on the iphone, but it is not the checkin interface

This is the central places interface on the iphone, but it is not the checkin interface

Now you should have gotten to the check-ins interface… one way or another…

The check-in interface looks like this!!

This is the checkins interface, you are almost to the point where you can create a new place

This is the checkins interface, you are almost to the point where you can create a new place

So now you could choose a place where you would want to checkin… but that is not what this tutorial is about. You want to create a *new* place that will show up on this list and allow other people to check-in. To do that you need to hit the little red button at the top right of the screen, which should bring you to the “new place” interface:

Make sure that the little blue dot is exactly where on the map that it should be!!

The iphone facebook app Add a Place interface

The iphone facebook app Add a Place interface

Now you will be able to check-in to your new place…

The iphone check-in interface

The iphone check-in interface

Now you should go ahead and check-in to your new location. By doing this you will start to “legitimize” the place in Facebooks eyes. You also need to get your friends to start using the place when they check-in.

I hope this helps someone. I could not find a current how-to on making a new place in Facebook places. It is pretty simple. If you ‘own’ a place (like a business or non-profit) then you should also read about the process to claim a facebook place.

HTH,

-FT

You might be a cyborg….

People often do not get why I am so convinced that only GPL Software should be used in Medicine. I can understand why. Without understanding the nature of Healthcare, people assume that I am being religious about the issue. This is the furthest thing from the truth.

It has been a while since I have blogged over at GPLMedicine.org. In fact you can see that I still have some site maintenance to do. But recently more attention has been given to the issue of Open Source and Software Freedom in medicine.

The Software Freedom Law Center has just released a paper called Killed by Code: Software Transparency in Implantable Medical Devices

Awesome title. Even more awesome paper.

The form of the argument is so simple:

  1. Hey you are putting hardware AND software in my body? yep.
  2. I cannot look at the software? nope.
  3. And the software is hackable? yep.
  4. Well that kinda sucks.

Feels kinda icky don’t it?

One thing I love about people with pacemakers or other implantable medical devices, is that they know they are cyborgs. Most people living in modern countries are cyborgs, but unlike people with pacemakers, they do not see it that way, because they carry their electronics, rather than implanting them. Makes no difference. In fact lets play a variant of “You might be a redneck“: I call it “You might be a cyborg..”;

  • If you leave your cell phone at home, and you -must- to leave work to go home and get it, you might be a cyborg.
  • If you will sleep through the morning unless a machine wakes you up, you might be a cyborg.
  • If your spouse is jealous of your cell phone, tablet, laptop, server or workstation, you might be a cyborg
  • If not wearing a watch makes you uneasy, you might be a cyborg
  • If you view any relationship you have with an online service as an addiction, you might be a cyborg
  • If you try to avoid walking more than 100ft in favor of a segway, bicycle, golf cart, or automobile, you might be a cyborg
  • If you try to avoid walking more than 100ft in favor of a lawn mower, you might be a cyborg and a redneck

Our relationship with technology is becoming more and more personal, and the operating system to your mobile phone, the software your medical devices uses and the EHR system that your doctor uses to track your health information make software freedom ethical issues into personal freedom ethical issues.

Today, its people with pacemakers, but tomorrow, there will things that people consider normal to do with their own bodies that will either use software that the user controls, or software that some random company controls.

Thanks to the Software Freedom Law Center, for helping to make this issue more personal.

-FT

gvim over ssh

I use vi for development.

I keenly remember one of Dr. Eggen‘s early lectures to us.

“There are other editors out there, but if you learn to use vi, you will have a powerful editor on every unix server you ever use…” (or something like)

It took me the about halfway through the compsci intro class to get used to command mode vs. input mode, but since then I have never looked back. Using keyboard commands to perform editing has become second nature to me, and I find myself constantly typing ESC then yy on windows text editors… Then I promptly install vim for Windows. Making Dr. Eggen’s point even more valuable.

However, I have gotten used to gvim. Its really the best of both worlds. You can use mouse based cut and past, but all of the command mode goodness still works. I must admit that I have never memorized the search and replace syntax and the fact that it is a dropdown menu on gvim really helps.

More and more I have been programming in the cloud. Which means I am frequently (for hours each day) using vim over ssh. But I miss gvim and the helpful menu items. I have been looking for a way to easily use gvim on a remote host for some time. Sharing an X session over the internet has always felt a like overkill to me. No cloud server should have X installed in any case.

The answer sshfs. Here is a link to a tutorial to using sshfs.

Basically the idea is that you have scp mirror a whole directory content, in real time, to a local directory. Because it is a local directory, gvim works fine. Of course, it takes an extra second for files to load… but now I can use gvim to my hearts content. It also means that I can edit ten different files at once, a pretty important feature if you are doing serious development work. This lets me code for the cloud in the cloud, which is lovely.

[Update Dec 19 2010] Happily this works with Mac OSX to… but you need to be sure to download the right version of gvim from here: http://code.google.com/p/macvim/ the one that comes up first when you search… sucks…

-FT