The weight graph

0 views
Skip to first unread message

Nina

unread,
Sep 21, 2007, 2:14:58 PM9/21/07
to Baobab Volunteers
Hi all

First an introduction: my name is Nina Jansen, I am from Denmark and I
am a former researcher in astrophysics (3 D models of colliding black
holes) turned self-employed all-round programmer. My coding career
started with Fortran and C, but I have always been scripting with
perl, and lately I've been doing a lot of php work. I learning about
Ruby and Ruby on Rails this February and I have tried to get into
projects that use Rails so far without success. But I've read the
books and I've tried to do a little rails work in my spare time. This
means that I'm probably not the go-to-person for deep rails knowledge,
but I am good at seing a problem from many angles and finding good
solutions.

When I met Mike after his talk at railsconf we discussed how we could
improve the graphical representation of the weight graph. As it is
now, at least in my understanding, the weight graph displays a
patients weight as a function of time, and the the BMI is lower than
18.5 an alert is shown that the patient needs counseling about eating
right. The y-axis runs from the lowest recorded weight of a patient to
the highest recorded weight. This means that even if the patient has
weight fluctuations in the healthy range the graph shows huge spikes.
This is my suggestion for making an improved graph.

I have written a ruby function that, given a patients height, computes
3 weight limits: the limit between underweight and normal, the weight
in the middle of the normal range, and the limit between normal and
overweight. The function is here:

def weight_limits_from_height_in_meters(height_in_meters)
weights = Hash.new
weights["low"] = 18.5*height_in_meters**2
weights["medium"] = 21.75*height_in_meters**2
weights["high"] = 25*height_in_meters**2
return weights
end

With these three weight numbers, one can draw 3 horizontal lines on
the graph. If those 3 lines are always on the graph, it gives a visual
frame of reference that shows if things are okay or not. The area of
the graph that is in the box could be green, while the areas sticking
out of the box could be red. If the patients weight fluctuations are
normal, they will be in the box. You would still need to calculate the
range on the y-axis for patients who have been measured at weights
outside the box, but you already know how to do that, so it would just
be a matter of adding a check, that is the lowest weight is higher
than the lower weight limit, one should use the lower weight limit as
the lowest point on the y-axis etc.

:-)

Nina

Murray

unread,
Sep 24, 2007, 9:18:07 AM9/24/07
to Baobab Volunteers
Hi Nina,

I don't know any Ruby or Rails (yet), but I am currently here at
Baobab in Malawi, and would be keen to collaborate with you and Mike
on novel graphical representations of data.

cheers,
Murray

Andrew Stewart

unread,
Sep 24, 2007, 9:23:37 AM9/24/07
to baobab-v...@googlegroups.com
Hi,

When I learned maths at school I was taught always to include 0 on
the axes. If you don't, graphs mislead because small changes appear
larger than they are.

So when plotting your lines, may I suggest that you always use 0 as
the start of the y-axis rather than, for examples, your lower weight
limit?

Regards,
Andy Stewart

-------
http://airbladesoftware.com

Nina Jansen

unread,
Sep 24, 2007, 1:28:30 PM9/24/07
to Baobab Volunteers
Hi Andy

While that is a good idea in principle, you waste a lot of "real
estate" that way. Suppose I plot my weight on a graph. I'm usually
somewhere in the 80's. Suppose I lose 10 kg. That would be alarming if
I hadn't changed my habits, but if you start the graph at 0, the drop
would only take up 1/9 of the graph (assuming we are plotting from 0
to 90). You want that drop to look big. If the graph goes from 60-
something to 90 something, the drop would be a third of the graph,
which is significant. Suppose a person that weigh around 40 kg. drops
10 kg. Now that is much more alarming than if I drop 10 kg. But on an
absolute graph, they look the same. However, if we take into account
that the "normal" BMI interval for a shorter person is not as wide as
for a tall person, we can get that a 5 kg. drop for a 40 kg. person
looks equally steep than a 10 kg. drop for an 80 kg person, then we
would have a good visual representation of the data. Steep graph =>
alarming. Red graph (ie. below or above normal BMI range) => alarming.
Green not so steep graph => everything is fine. Now I know that the
system as it is now issues a written warning if a persons BMI is lower
than 18.5, but the point of having the graph is to have it signal a
corresponding message, such that a busy health care worker takes
notice.

:-)

Nina

Andrew Stewart

unread,
Sep 24, 2007, 2:21:55 PM9/24/07
to baobab-v...@googlegroups.com
Hi Nina,

> While that is a good idea in principle, you waste a lot of "real
> estate" that way. Suppose I plot my weight on a graph. I'm usually
> somewhere in the 80's. Suppose I lose 10 kg. That would be alarming if
> I hadn't changed my habits, but if you start the graph at 0, the drop
> would only take up 1/9 of the graph (assuming we are plotting from 0
> to 90). You want that drop to look big. If the graph goes from 60-
> something to 90 something, the drop would be a third of the graph,
> which is significant. Suppose a person that weigh around 40 kg. drops
> 10 kg. Now that is much more alarming than if I drop 10 kg. But on an
> absolute graph, they look the same.

Hmm, surely on an absolute graph the drop looks different (because
you can see it in relation to the overall value) whereas on a
relative graph that omits 0 the drop looks the same?

> However, if we take into account
> that the "normal" BMI interval for a shorter person is not as wide as
> for a tall person, we can get that a 5 kg. drop for a 40 kg. person
> looks equally steep than a 10 kg. drop for an 80 kg person, then we
> would have a good visual representation of the data. Steep graph =>
> alarming. Red graph (ie. below or above normal BMI range) => alarming.
> Green not so steep graph => everything is fine.

It sounds like you're not really interested in the weight but instead
the rate of change. Since those are smaller numbers, less screen
space will be taken up anyway :)

Best regards,
Andy

-------
http://airbladesoftware.com

Jacob Atzen

unread,
Sep 25, 2007, 2:24:38 AM9/25/07
to baobab-v...@googlegroups.com
Hi all,

Perhaps it would be an idea to graph the BMI instead of or in addition
to the weight. Possibly with a fixed Y-axis from 15 to 25 or some other
constant range. I assume this would make it easier for the health
workers to get a quick reading of the patients status as all graphs
would be similar.

--
Cheers,
- Jacob Atzen

Nina Jansen

unread,
Sep 25, 2007, 2:53:05 AM9/25/07
to Baobab Volunteers
Hi Andy

On Sep 24, 8:21 pm, Andrew Stewart <b...@airbladesoftware.com> wrote:

> Hmm, surely on an absolute graph the drop looks different (because
> you can see it in relation to the overall value) whereas on a
> relative graph that omits 0 the drop looks the same?

Yeah, you're right. Got my terms switched around there.

> It sounds like you're not really interested in the weight but instead
> the rate of change. Since those are smaller numbers, less screen
> space will be taken up anyway :)

Yes, that's exactly right. Weight is just a number, that doesn't
really tell you anything about your health. Only when you relate it to
height (through BMI) or gender or something else, does it tell you
about a patients well-being or health risks. And that is the thing I
am interested in: the patients health. The way the graph is plotted
now, with the lowest measured weight as the lowest y-axis value and
the highest measured weight as the highest y-axis value, is not
optimal, because while it does show that the weight is changing it
does not show if that weight change means something bad or good. That
is why I am suggesting using BMI as a reference.

:-)

Nina

Nina Jansen

unread,
Sep 25, 2007, 2:59:51 AM9/25/07
to Baobab Volunteers
Hi Jakob

Yes, that is another interesting option. However, I am a bit worried
about BMI as the sole measure of health. Is a childs BMI supposed to
be in the same range as an adults? How about pregnant women: they are
obviously supposed to have a different BMI than non-pregnant women,
depending on how far along they are. Are there any gender differences?
How about people that are naturally skinny vs. people that are
naturally a bit rounder?

Even though I indirectly use the BMI to indicate health in my
suggestion, it is nice to have the actual weight. Of course this means
that the graph is sometimes sending the wrong signal... but if the
patient standing in front of the desk is clearly pregnant, it might be
easier to ignore that signal.

:-)

Nina

Mike McKay

unread,
Sep 25, 2007, 5:00:56 AM9/25/07
to baobab-v...@googlegroups.com
There is some great discussion going on regarding the graphs. I am still
trying to catch up! I thought it would be helpful to get you guys some
code to actually play around with some data and the graphing tool that
we are using.

I have attached a little graph that I have extracted out of some real
data. Open the weight.html file and you can pretty much see how it
works. We are using PlotKit, the documentation can be found here:

http://media.liquidx.net/js/plotkit-doc/PlotKit.html

Other information that might be useful:

* We do have a BMI for the patient over time (we don't remeasure their
height if they are an adult, but we do for children). While BMI is
probably a more normalized data point, it is definitely a more abstract
number for people to think about.

* For each age & gender we have a plausible weight range to make sure
our data is reasonable.

I will catch up on the rest of the emails now, but I look forward to
seeing what you guys put together!

I am also working on svn access. I am pretty sure tommy has something
setup already, I just need to test it.

Mike

graph.tgz

Nina Jansen

unread,
Sep 25, 2007, 6:51:30 AM9/25/07
to Baobab Volunteers
Hi Mike

Is there any reason why you use javascript for drawing? I'd draw the
pictures, cache them and when a new weight is entered expire and
redraw them. But maybe it's because I'm used to certain tools like IDL
or Mathematica.

:-)

Nina

> graph.tgz
> 220KDownload

Mike McKay

unread,
Sep 25, 2007, 10:23:01 AM9/25/07
to baobab-v...@googlegroups.com
Nina Jansen wrote:
> Is there any reason why you use javascript for drawing? I'd draw the
> pictures, cache them and when a new weight is entered expire and
> redraw them. But maybe it's because I'm used to certain tools like IDL
> or Mathematica.

Yeah, we have pretty much focused on ruby and javascript as the core
languages that we want to have a high competence in. I am sure there are
other approaches that would get the job done, but javascript allows us
to dynamically update the graph without loading a new page. This is a
little bit subtle, but when doing a "Height/Weight" encounter we ask a
number of questions, but only one per "page" and then at the end we show
a new "page" with the graph. But these pages are actually just divs that
are being swapped around in javascript, and the weight chart is created
dynamically based on all of the previous entries. This makes things nice
and instantaneous. It also means that you can click back, change the
weight, go forward and have a new graph based on the new weight.

Plotkit is pretty cool actually. It has SVG and canvas support and is
quite flexible.

Mike


MagpieUK

unread,
Oct 14, 2007, 11:09:01 AM10/14/07
to Baobab Volunteers
I must admit I know very little about HIV, BMI and until Mikes talk in
Berlin anything about Malawi. So as we have been discussing BMI etc
with reference to the graphs I thought I would do some digging around.
These are the articles that I found relating to BMI. I hope they are
of some use :

BMI valuable tool for assessing when to start ARVs in resource limited
settings
http://www.impactaids.org.uk/newsletter/Oct10-04.htm#BMI

WHO BMI Classification
http://www.who.int/bmi/index.jsp?introPage=intro_3.html

BMI for Children
http://www.cdc.gov/nccdphp/dnpa/bmi/childrens_BMI/about_childrens_BMI.htm

BMI and pregnancy
http://www.babycentre.co.uk/pregnancy/antenatalhealth/physicalhealth/weightgain/

Regards

Lee


MagpieUK

unread,
Oct 15, 2007, 2:25:12 AM10/15/07
to Baobab Volunteers

After chatting with Mike last night on IRC the two BMI bands we are
interested in are:
17 - 18.5 : at which point Nutritional Advice is given
below 17 : which means the patient has access to free food.

With this in mind I took Nina's function and changed it slightly.

class Person

attr_accessor :height

def treatment_bands

weights = Hash.new

weights["freefood"] = 17*self.height**2
weights["advice"] = 18.5*self.height**2

return weights

end
end

So now we can get the treatment bands based on the persons height.

I have mocked up a graph showing what it might look like in practice
which I have put in the files section called modifiedweight.html. You
will need to put it into the same directory as the weight.html from
the extracted graph.tgz.

The implementation would be very simple:
Using Nina's function get the bandings
Plot them using first and last xtick.
Plot Advice, FreeFood and then the patient weights so that the order
and colouring are correct.

Hope this helps

Lee


MagpieUK

unread,
Oct 15, 2007, 2:48:14 AM10/15/07
to Baobab Volunteers
Reply all
Reply to author
Forward
0 new messages