Page doesn't render properly ?
Valid XHTML 1.0!
Valid CSS!

User documentation

The user help provided here is the same than the one included with the package.

Algorithm writer documentation

If you want to write your own algorithms in Python, I suggest you read quickly the python tutorial.

Each python file found in QPEDIR/lib/morphine/pyalgos will be loaded at startup. It will be considered as an algorithm definition file if it contains a "initalgo" function which takes one parameter (an algorithm manager instance, which you don't need to know much more about it).

Each algorithm is defined by subclassing the "MedicAlgorithm" class. The class must override the functions "__init__", and "run". Thus, the code for a new algo will look like :

class MyAlgo(MedicAlgorithm):
    def __init__(self):
         MedicAlgorithm.__init__(self, "Algorithm name", "Algorithm description (can be quite long)")
         self.param1 = FloatParameter("param name", "param comment or None", default_value, unit_list, 0)
         ...
         self.result1 = FloatParameter("param name", "param comment or None", default_value, unit_list, 0)
         ...
         #what you want else to be initializind code
     def run(self):
         #Do calculations here

When all algos have been defined, you must write the initializations code, which is called via the "initalgo" function. It will look like this :

def initalgo(manager):
     category1 = Category("Category name","Category description)
     manager.registerAlgorithm(None, category1)
     cat2 = Category("sub category name","Category description)
     manager.registerAlgorithm(category1, cat2)
     alg1 = MyAlgo()
     manager.registerAlgorithm(cat2, alg1)
Here, we defined one main algorithm category, one sub-category (son of the main one), and one algorithm defined as son of the sub-category.

Parameters types

For each parameter, there is an "optional" argument. It's a boolean arg (0 or 1), which tells the algomanager if the parameter is required for a proper execution of the algorithm. For results, it must always be set to false (0).

Each parameter can have an optional argument ("disabled_function" after "optional") which must callable (thus, it's a function). The given function must return a boolean: it should return "1" if the parameter must be disabled (thus not visible in the parameter list), and 0 if it should be enabled. This permits to have prameters which are apparent on certain conditions on others parameters value. See BMI.py to have an example of the usage of this feature.

Availables parameters are:

Each parameter have the following accessing functions :

Please look at the available python algorithms as complete examples.

Compilation

Yes, the compilation of the soft is somewhat tricky. First, for the compilation of the main application (remember to set the environment vars before, in order to use the right compiler, the right libraries, etc.):

The morphine apps should be built OK.

Then, you must go in the "python" directory. Here comes the difficult part. In fact, I put the required static libs already compiled in it (libpython and libsip). You can compile them if you want to. You need python sources and sip sources.

La conscience est venue pourrir notre saine et sereine bestialité originelle... Mon combat est de la retrouver. - Ptiluc in "Geste de Gilles de Chin et du dragon de Mons"
2003/02/28