ChasteGuides/RunningCellBasedVisualization

Running the cell-based visualizer

Note: this page describes how to use the java visualiser supplied with the source release. The new, recommended approach is to use Paraview (see tutorials)

To run a Visualization you must

1. Compile the java

From the Chaste main directory

[chaste@hodgkin Chaste]$ cd anim
[chaste@hodgkin anim]$ javac Visualize.java
[chaste@hodgkin anim]$ javac Visualize1dChainIn2d.java
[chaste@hodgkin anim]$ javac Visualize2d.java
[chaste@hodgkin anim]$ javac Visualize2dCells.java

There is a clash between some of the Visualize classes, so you may need to recompile the one you want.

2a. Run simple visualization from the anim folder

[chaste@hodgkin anim]$ java Visualize /tmp/chaste/testoutput/CryptWithBirthVariableRestLength/results
[chaste@hodgkin anim]$ java Visualize1dChainIn2d example_data/data_1d_chain_in_2d.dat
[chaste@hodgkin anim]$ java Visualize2d example_data/data_2d_node.dat example_data/data_2d_element.dat

2b. Run the 2D cell visualizer from the anim folder

To simply visualize cells, use:

[chaste@userpc60 anim]$ java Visualize2dCells <data_path_and_prefix> <options>

The pathname of the input must come first but the additional arguments output, springs, nocells, ghosts and notcylindrical may appear in any order. The Visualizer will warn you if any options are not recognised but will continue running.

The pathname probably looks something like

<data_path_and_prefix> = /tmp/YOUR_USERNAME/testoutput/CHASTE_TEST_NAME/results_from_time_0 
or
<data_path_and_prefix> = /tmp/YOUR_USERNAME/testoutput/CHASTE_TEST_NAME/results_from_time_1.8333

Note that you don't have to specify separate nodes and elements files anymore - just the folder they live in.

The following are command-line options:

Command Default Description
output Off Writes an output to PNG files, which can be converted into an animated GIF (see below)
springs Off Draws the springs between the cells
nocells Off Do not draw the Voronoi cells
ghosts Off Visualize the ghost nodes (and springs)
notcylindrical Off Supress the cylindrical routine (print to screen exactly what is in the input files). This is automatically set to 'On' if a results.vizsetup file with the parameter MeshWidth is not supplied.
beta_catenin On* Displays a 'GFP style' simulation with shading dependent on protein concentrations. This is automatically set to 'On' if results.vizsetup has a line which reads BetaCatenin.
ancestors On* Draws the ancestor index of a cell with a pretty colour
nutrients On* Inputs a double associated with each cell and displays the cell with a colour proportional to the value of the double
axes On Draws axes on the simualtion

* When the appropriate results files are present.

For example, to switch off cell drawing but draw ghost nodes and springs, use:

[chaste@userpc60 anim]$ java Visualize2dCells <data_path_and_prefix> ghosts springs nocells

Memory

If you get an out of memory error, use

java -Xmn100M -Xms512M -Xmx512M Visualize2dCells <path>

for big simulations (24 hours of big crypts), or even

java -Xmn200M -Xms700M -Xmx700M Visualize2dCells <path>

for really big simulations (50 hours of full sized crypts). See comment 1 in ticket:293

Making an MPEG movie

When you have created image0*.png files in the anim folder (by running the visualizer with the output argument), go to the anim folder (cdchaste then cd anim)and simply type

[chaste@userpc60 anim]$ ./make_a_movie

This creates an MPEG format movie using MPlayer, and seems to compress it, whatever the length, into a file of about 15MB.

Making an animated gif

[chaste@userpc60 anim]$ convert image*.png my_cool_animation.gif

Renaming files

You may want to do this so you can show the results from one simulation following on from another, before making your movie. The following changes the filenames from image0*.png to image2*.png.

[chaste@userpc60 anim]$ for f in image*; do mv $f ${f/image0/image2}; done 

Data formats

Visualize (1D)

In a single text file, on each line, expects: time x_1 x_2 ... x_n where x_1,...,x_n are ordered points

Visualize1dChainIn2d

In a single text file, on each line, expects: time x_1 y_1 ... x_n y_n where (x_1,y_1),...,(x_n,y_n) are ordered points

Visualize2d

Requires two arguments. The first is the node file, where each line should be of the form

    time x_1 y_1 ... x_n y_n

where (x_1,y_1),...,(x_n,y_n) are points. The second is the element file where each line should be of the form

    time element1_node1 element1_node2 element1_node3 ... elementn_node1 elementn_node2 elementn_node3

Visualize2dCells

Requires two files. The first is the nodes file (results.viznodes), where each line should be of the form

    time x_1 y_1 c_1... x_n y_n c_n

where (x_1,y_1),...,(x_n,y_n) are points and c_1,...,c_n are numbers corresponding to cell types:

The second is the elements file (results.vizelements), where each line should be of the form

    time element1_node1 element1_node2 element1_node3 ... elementn_node1 elementn_node2 elementn_node3

An optional third file is the setup file (results.vizsetup), which includes parameters such as

    MeshWidth value
    BetaCatenin
    Complete

Complete tells the Visualizer that this set of results files are finished and it can read the last line safely. N.B. A setup file is required for a cylindrical visualization - to tell the visualizer what the crypt width is.

Other visualizer results files take the form results.viz<Whatever>

Where <whatever> can currently be

These files should all take the same form as results.viznodes, a row for every time step (with time as first item in the row) followed by a number of variables relating to each cell.

All the files should all be in a folder called 'vis_results/'. The location of this folder is then specified when calling Visualize2dCells.