Tutorial qMuscleSim

Installation

The easiest way is to install qmusclesim via the anaconda distribution

conda install -c jlaforet qmusclesim

Running

The qMuscleSim package provides several tools which can be run all together from the main program or separately.

To run the simulation interface, simply type in a terminal:

qmusclesim

The visualisation tools can be run using one of the following:

Usage

qMuscleSim

General configuration

  • Model: Select the model you wish to simulate (among which have been detected on your system)

  • user name: Your name, as it will appear on the results report (defaults to your login on the current session)

  • Working directory: Directory where the simulation results will be saved. A subdirectory with a timestamp will be created here.

  • Purpose: A short description of the simulation and its purpose.

/tuto_qmusclesim/0_config.png

Edition of model parameters

Here you can either load an existing json description or build your own.

/tuto_qmusclesim/1_edit_1.png

The buttons at the top of the interface give access to the main functions of this part:

  • New Creates a new empty description of the current model.

  • Open Opens an already existing json description. It can be altered afterwards.

/tuto_qmusclesim/1_edit_open.png
  • Save Saves a copy of the description in json format. You must save your description before being able to run it.

  • Add model Adds a new model with its default parameters. Please pay attention to the consistency of your description.

/tuto_qmusclesim/1_edit_addmdl.png
  • Add Parameter Adds a new parameter to the currently selected model. Please pay attention to the consistency of your description.

/tuto_qmusclesim/1_edit_addparam.png
  • Modify Parameter Modify the currently selected parameter.

/tuto_qmusclesim/1_edit_modifparam.png
  • Delete Removes the currently selected paramter or model.

Check and run simulation

The interface displays the parameters entered at the first step and the simulation options:

  • Cores to use : Select the number of cores of your cpu to use for the simulation. This has no effect if the model doesn't support parallel computations.

  • batch mode If enabled, a simulation in batch mode will only save the EMG signals (if any) and will not produce graphical outputs.

/tuto_qmusclesim/2_run_1.png
  • Simulate Runs the simulation. While the simulation is computing, the interface will display a busy progress bar.

/tuto_qmusclesim/2_run_2.png

The complete progress bar is only displayed in the terminal. It also computes the ETA (Estimated Time of Arrival) of the simulation. .. image:: /tuto_qmusclesim/2_run_progress.png

The interface will also display any information or error messages generated by the model during the simulation.

/tuto_qmusclesim/2_run_3.png

Simulation results and report

This last step display the html report of the simulation. The buttons at the bottom are links to the visualization applications provided by qMuscleSim. Only the applications pertinent for your data will be enabled. For example, if you only have EMG signals, the surface visualization will be disabled.

/tuto_qmusclesim/3_results_1.png

qsurf_viewer

This application let you visualize surface data generated by your model simulation. To make comparisons, you can display several surfaces from the same simulation.

First you'll need to open the hdf5 results.

/tuto_qmusclesim/qsurf_0.png

The add view dialog lets you define which surface and how it will be displayed.

/tuto_qmusclesim/qsurf_add.png

You can then visualize the evolution over time, and save pictures and videos.

/tuto_qmusclesim/qsurf_view0.png

qemg_viewer

This application will display the EMG signals simulated. First you'll need to open the hdf5 results.

The application allows you to visualize the signals for each grid simulated. You can also zoom and pan on the temporal scale (all channels will be affected).

/tuto_qmusclesim/qemg_signals.png

Pressing the fft button will toggle the power spectrum mode. Press it again to disable it.

/tuto_qmusclesim/qemg_fft.png

A map of the electrode grid is available by the minimap icon.

/tuto_qmusclesim/qemg_minimap.png

qemg_explorer

This last application offers a mixed visualization. It will display side by side a flat 2D surface and one channel of an electrode grid with its power spectrum. The controls are the same as previous applications.

/tuto_qmusclesim/qexplore.png

Documentation - Formation Python

Documentation Suite à la Formation Python

Présentations de la formation

Les deux séries de slides, convertis en PDF:

Ebooks

Liste de références

Un ensemble de liens utiles pour en apprendre plus:

Pysens Tutorial

PySens  Tutorial / Basic Test==================

In [1]:
import json
import pysens
%pylab inline
Populating the interactive namespace from numpy and matplotlib

First let's define our parameter space in json format. You should describe each parameter variations with a probability distributions.

As a test we will use the Ishigami function implemented as a basic test in the library.

In [2]:
%%writefile ishigami.json
{
 "model": "test",
 "parameters": [
   {
     "name": "X1",
     "distrib": {
       "max": 3.14,
       "min": -3.14,
       "type": "uniform"
     },
     "unit": "mm"
   },
   {
     "name": "X2",
     "distrib": {
       "min": -3.14,
       "max": 3.14,
       "type": "uniform"
     },
     "unit": "V"
   },
   {
     "name": "X3",
     "distrib": {
       "min": -3.14,
       "max": 3.14,
       "type": "uniform"
     },
     "unit": "V"
   }
 ]
}
Overwriting ishigami.json

Now we can sample this space using one of the available methods in pysens.sample

In [3]:
smpl=pysens.sample.Sobol('ishigami.json')
smpl.build()

Let's visualise our DOE and print its statistical properties:

In [4]:
smpl.plot_plan()
pysens.tools.print_stat(smpl.mat)
Statistics for DOE
Euclidean maximin distance: 0.0857099128711
Maximum pairwise correlation: 0.041104110411
Condition number: 1.09694361664
ML2 discrepency: 0.000370740566756

Now we can evaluate the model at each of the point described by the DOE plan:

In [5]:
ev=pysens.evaluate.TestIshigami('ishigami-Sobol.csv')
ev.simulate()
Number of threads to be used: 8/8
Number of simulations to run: 100

Total time elapsed: 0.12s 

This generated a hundred npy files each containing the results of one evaluation of the model. They have been stored in a new subdirectory named by the time and date of the analysis.

(In the following lines, we use the name of the subdirectory stored in ev.subdir. You can run the post-processing and analysis without the evaluator object, just by giving the directory name instead.)

In [6]:
prcss=pysens.process.TestModels(ev.subdir)

Now we have both the DOE plan in ishigami-Sobol.csv and the features in Out.csv. Both files are in the subdirectory. For the test models, there's only one feature, the scalar output of the model.

Let's compute the linear correclations of the inputs / output:

In [7]:
anls=pysens.analyse.CorrelationsSA(ev.subdir+'ishigami-Sobol.csv',ev.subdir+'Out.csv')
anls.analyse()
anls.save_results()
anls.plot_results()
In [ ]: