Getting Started Developing Interactive Web Interfaces for Scientific and Medical Applications

Alex Amies April 8, 2006

Contents

Abstract

This document discusses creation of a simple interactive web user interface for scientific and medical applications.  In particular, it describes the details behind the code for an example interactive web page for modeling of electric gradients and action potentials in neurons.  This is done using cascading style sheets (CSS), JavaScript, and HTML document object model (DOM).  The intended audience is people in science and medicine wanting to present material in an interactive way over the web.

Introduction

Modeling of the electrical and ion concentration gradients is a fascinating topic that inspires demonstration with a dynamic user interface.  The accompanying article The Nernst Equation and Action Potentials in the Nervous System does this.  I also found a number of references, some of which are listed below, that provide more detailed technical treatment and even more dynamic user interfaces (references 1 through 5).  However, I couldn't find a simple and informative reference that went through the calculation the way I want to see it, with the values for all the constants and terms clearly listed in a format where I could enter the exact values of the parameters that I wanted. 

I will describe the approach for the creation of the interactive elements of The Nernst Equation and Action Potentials in the Nervous System page. It uses dynamic HTML, which provides an interactive user interface suitable for this purpose. See the FAQ on this site for basic information on dynamic HTML.  It also makes use of is made of CSS to lay out the Nernst Equation.  I will use this as an example to discuss presentation of simple mathematical formulas in HTML.

My choice of technology in this example is driven by several factors:

  • Convenient for a casual user. Consider a user who is looking for a fast check on a college homework problem. They will probably not want to install a desktop application just for this one problem just to add it to their bloated collection of once-only used software on their desktop. It may also be important for the equation to be run repeatedly with precise values.  A simple HTML page with textfied inputs and JavaScript fits this purpose. 
  • Can conveniently provide relevant information on the use of the equation.  A desciption of any symbols used in equations and references can be provided conveniently in HTML pages.
  • To avoid alienating users who do not want to load plug-ins, such as Java, or who have problems with those plug-ins, use the minimum software requirements possible.  The JavaScript methods used in this example are present on most recent broswers.  They may not work on browsers older than three or four years but those users will still be able to read the static content.

Laying out the Nernst Equation with Cascading Style Sheets

You can associate styles with text in HTML documents using the link tag.  This example shows linking our example html file action_potentials.html to the CSS file action_potentials.css containing the style definitions.


<link rel="stylesheet" type="text/css" href="action_potentials.css">


The Nernst equation for the potassium equilibrium potential over the cell membrane is

EK
RT  ln  [K+]out
zF [K+]in

where the terms are described in the accompanying article.  To see how the equation is laid out I will show it again with a light color for the hidden borders.

EK
RT  ln  [K+]out
zF [K+]in

In the table definition I set the class to "equation":


<table class="equation">

This matches the following selector in the style sheet.


table.equation {
        border-collapse: collapse;
        border: none
}

The border collapse attribute makes it possible to specify rules for borders that surround all or part of a cell, row, row group, column, and column group.  With border: none I switched the border off in general leaving it to be shown specifically in certain table cells.  This is done with the selector


td.equation {
        text-align: center;
        border-bottom: solid black;
        border-width: thin;
}

I used the rowspan attribute to vertically align the elements of the equation:


<td rowspan="2">

For more on CSS see the World Wide Web Consortium (W3C)  Cascading Style Sheets home page and, in particular, the CSS 2.1 Specification6.  An alternative to doing equations in this way is to use Math Markup Language (MathML)13.  This is an XML variant specially designed for displaying mathematical formulas and proofs.

Scientific and Mathematical Symbols

Equations usually use a number of symbols that are not part of a normal keyboard. Unicode is a character coding standard that has all of these symbols. In fact, Unicode has many more symbols, including Chinese, Japanese, Tibetan, and Egyptian hieroglyphics. This enables you to put even the most exotic set theory symbols on your web pages and they will be displays correctly, providing your browser has the font to display them.

UTF-8 is a standard that allows developers to put Unicode symbols in files and over computer networks. This includes HTML web pages. This enables web authors to put characters from multiple languages, say Russian, Arabic, and Sanskrit, on the same web page as complex mathematical symbols (if they might want to). In order to take advantage of UTF-8 and Unicode you need to set the content type at the top of your HTML pages to UTF-8 with the line


<meta content="text/html; charset=UTF-8" http-equiv="content-type">

Unicode characters can be written HTML documents in the form &#x000B0; (° degrees), where 000B0 is the Unicode value in hexadecimal (base 16 ) or &#176; where 176 is the Unicode value in decimal.

There are also HTML entity literals that can be referred to by name. The math symbols used in accompanying page are &middot; (·) and &times; (×). A list of useful entities for scientific and mathematical formulas is given in the table below.  A longer list is provided in the W3C HTML Specification11 and an even longer list in the MathML specification13.

Useful HTML Entities for Scientific and Mathematical Formulas
(from W3C HTML 4.01 Specification, Section 24.3.1)

Literal Display Description
&times; × Multiplication
&middot; · Multiplication
&fnof; ƒ Generic function
&alpha; α
The first character in the Greek alphabet (equivalent to Roman A)
&beta; β The second character in the Greek alphabet (equivalent to Roman B)
&mu; μ The Greek character equivalent to Roman M
&frac14; ¼ One quarter
&frac12; ½ One half
&prime; Prime, derivative
&part; Partial differential
&int; Integral
&isin; Member of (a set)
&notin; Not a member of (a set)
&exist; There exists
&sub; Subset
&sup; Superset
&nsub; Not a subset
&sube; Subset or equal to
&supe; Superset or equal to
&empty; Empty set
&#x211D; Real numbers
&#x2124; Integers
&#x2131; Fourier transform
&#x2147; Exponential e
&prod; Product of a series
&sum; Sum of a series
&radic; Square root
&infin; Infinity
&sdot; Dot operator
&there4; Therefore
&deg; ° Degrees (temperature, angle)
&211E; Prescription
&ohm; Ohm
&212B; Angstrom
&210E; Plank's constant

Next


Please send ideas and opinions by email at webmaster@medicalcomputing.net or add comments to my blog.  The content may become part of the web site.

© Alex Amies 2006