Measuring has started

Today I’ve started with my week in Breda. I woke up a little too late for my taste but I suppose I just was tired… So from 10.10 the measuring has started. I had some problems getting my the pictures from my camera to my laptop. It refused to transfer the files. There were about 80 corrupt files on the camera. I don’t know where they came from. Maybe it had to do with the device I ordered to transfer the pictures to a USB stick without using a PC. Unfortunately this didn’t work with the JB cam. I don’t know why not, it worked just fine with my other digital camera. It’s a shame it doesn’t work because it would have made me more flexible. But now I will have to take my laptop when I leave home for more then a couple of hours.

It’s alive!

I’ve almost got the whole application working. Yesterday I managed to animate the map and the heart icon. Because I keep moving around (and the GPS logger isn’t always exact) the map is continually shifting a little. Together with the moving heart-beat ‘snake’ you really get the feeling this work is alive. And of course the work is about life and the way it’s changing constantly. So I’m rather pleased with the way it’s turning out. Watch a little video about the living map (a Windows media file.)

Animated

Yesterday I continued working on the heart-beat graph. I’ve managed to animate it. The speed of the animations varies with your cursor position. The speed ranges from 1000 milliseconds to 1 millisecond. When the animation goes faster the string of dots seems to be alive, like some snake like creature. Fascinating to watch.

The dots are 15 pixels apart. For my test file with 20 hours of data the heart-beat graph has a width of 107374 pixels! Flash is pretty powerful to caculate this image in less than a second, amazing.

As for the data collection. I’ve slept a night with the belt fastened by broad strips of medical tape. It worked till 7 am, which is an improvement but still not perfect. I’ve posted the question at a user group and hope to get some tips for improving this.

ps. My lowest heart-rate was 34 bpm this night! The lowest I ever measured.

Happy

prototype of the first heart-beat graph
prototype of the first heart-beat graph

I’ve managed to code my first heart-rate graphic. And it’s CUTE!
By looping through the big data file I can isolate the heart-beats, take the different values to draw lines and put in the dots at the right coordinates. The next step is to draw a big graph in Flash and move it to the right at certain intervals (500 milliseconds for example). Now it still is a drawing that is animated from left to right. It disappears from view after a while, as you can see in the picture.

Testing 1, 2, 3…

Thursday I did it test with all my sensors for 24 hours. It went rather well but there art two main points of attention.

Mathe, Richard an me working (no were not terrorists)
Mathe, Richard an me working (no we're not terrorists)

1. The stealth cam. It has limited capabilities in storage capacity and battery capacity. When I set the resolution to low it should be able to hold 350 pictures. This is not the case, it holds 300 max. Another drawback is that it’s very hard to make out to which resolution the cam is set. So I accidentally set it to high. As a result I couldn’t complete the whole day because I was with friends and I forgot my cable so I was stuck for the evening with a full camera. But I did get some nice shots (view right.)

It takes just one AAA size battery. I used up only 2.5 in 13.5 hours so that was fine. I do have to carry a spare one with me where ever I go. I bought a quick, one hour charger for four AAA batteries so I will never go without.

Tiny cam can be attached with velcro to a card
Tiny cam can be attached with Velcro to a card

I’ve found a very nifty  solution for wearing the camera. I can pin or clip it to every sort of clothing. The images are still shaky but he, life is bumpy 😉 To my relieve people didn’t look too suspicious when I passed them, I’m still a bit embarrassed though.

It was quite a puzzle to see where I missed pictures. (In the future I will note exactly when the camera stopped and restarted.) When I empty the storage it takes at least a couple of minutes to store them on hard disk. So there are gaps. I filled the gaps with duplicate pictures but I’m still files short…? I think the 60 second laps probably isn’t exactly 60 seconds so after a couple of hundred pictures you start noticing that. I’ll have to wait and see how that works out in the app.

The main challenge is dealing with the gaps in the data from all the devices.

2. My Suunto watch does a great job during the day but when I sleep it loses connection with the skin and it stopped at 4 a.m. Which was still almost all night. But it will have to do better when the project actually runs. I think I’ll buy some medical tape to fasten it for the night.

I don’t think it can log 24 hours of data, but it’s close. To be on the safe side I’ll store the data somewhere in the middle of the day.

Logging my activities was a very mindful thing to do. I thought it would irritate me but it made me quiet and alert at the same time. May be using pencil and paper helped there too.

Getting things on a map

Custom marker in Google maps for Flash
Custom marker in Google maps for Flash

Yesterday I continued with my Flash web app. I’d already done some tests with part of the application. For example displaying a map inside Flash. Only recently Google maps have released an API for working with Google maps inside Flash. This makes it very easy to include (interactive) maps inside your Flash app. Of course when you want different things it’s harder 🙂

I want to display two maps, one for Amsterdam and one for Breda. On the map you can follow me around for two weeks. I wanted to use a fitting icon to display where I have been. So I designed a heart to indicate where it was beating at a certain time. I thought it would be simple to display my custom marker. But I could only find difficult and not so logical examples explaining how this is done. So with a fresh mind in the morning I took a new look at the documentation and worked it out. As it took me quite some time to work this simple code out I’ll just repeat it here for those interested:

function onMapaReady(event:Event):void {
   map_a.setCenter(new LatLng(b_line_array[2],b_line_array[3]), 14, MapType.NORMAL_MAP_TYPE);
   var a_icon:Marker = new Marker(   new LatLng(b_line_array[2],b_line_array[3]),
   new MarkerOptions({
      icon: new my_icon()
   })
);
map_a.addOverlay(a_icon);
}

So in my library I have a movie clip called (linkage) my_icon. I use this for the Amsterdam and the Breda map, except that it’s called b_icon there, the rest of the code is the same. Make sure you import the marker classes:

import com.google.maps.overlays.Marker;
import com.google.maps.overlays.MarkerOptions;

And add the overlay, then you’re done.

Format data application

Today I finished my program for combining data from different files. There will be three different files at the end of a day. A text file with lines and tab separated data containing all the data recorded by the Suunto watch. A gpx file that contains GPS data in xml format. And a text file with lines and tab separated data which holds time and activity data.

I placed myself for the daunting task of combining these different files and formats into one tab separated text file. As Flash can’t output a text file I chose Processing for the job. It appeared the capabilities to work with strings are rather limited compared to ActionScript or PHP. But they do have a very convenient XML element class. It was actually the first time I worked with an XML file in this way (that is extracting attributes from an XML node). The loadStrings function is very handy for loading external data and putting it into an array at the same time. In one big loop I cycle through all the files, add a concatenated line at the end of every loop. The result is a tidy text file with only the necessary data in a structured format.

A day well spend 🙂

Merging three files into one (day_data.txt)
Merging three files into one (day_data.txt)

I give up

Flash Lite app with Shuriken component
Flash Lite app with Shuriken component

Part of the data I want to log and show are my activities. I’ve wrecked my brain trying to think of an easy but digital way of keeping track of my activities during the day. That data should consist of a time stamp and of course my activity. I imagined an application which would run either on my PDA or on my mobile phone. I would have to be really easy to work with as I’ll be using it for two whole weeks on a constant basis. I was thinking of a drop-down menu or combo-box which would hold all my possible activities (hmm, is that possible). Once I’d have selected an activity it would be stored on the device together with a time stamp indicating the current time. The next morning I would download the data from the device and integrate it with other data collected the previous day. Sounds simple right?

My first thought was Excel, as this is an easy way to store structured data and output it in different formats. But the power of my pocket Excel is limited and after some time I realized that you can’t use VB Script so that solution went down the drain.

By chance I realized that Flash (dear Flash) can also store persistent data. This wasn’t something I had worked with before but it sounded promising and I could use it on my Nokia. At first I developed a desktop version. When I got that working (sorting the collected data proved to be the most difficult task) I discovered that I couldn’t use the combo-box component on my Nokia, it wasn’t supported. But thankfully there are geniuses out there who made custom components for handheld devices! After I’d finally set them up other parts of my AS3 code weren’t working on Flash Lite, which supports AS2. But after a about a days work I can’t get the application to really store all the data. The sorting again is a problem (1, 10, 11, 2) pfffff. So this afternoon I made the very uncharacteristic decision to give up this application. Time is pressing. I still have to build… everything really.

So now I feel quite relieved and have decided I’ll use pencil, paper and my watch to collect my activities.