-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ee748e
commit a675115
Showing
23 changed files
with
21,012 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
examples-dev | ||
examples-old | ||
docs | ||
*.swp | ||
build.make | ||
node_modules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"source": "./src", | ||
"destination": "./docs", | ||
"plugins": [ | ||
{ | ||
"name": "esdoc-standard-plugin", | ||
"option": { | ||
"test" : { | ||
"source" : "./spec/", | ||
"interfaces": ["describe", "it", "context", "suite", "test"], | ||
"includes": ["(spec|Spec|test|Test)\\.js$"], | ||
"excludes": ["\\.config\\.js$"] | ||
}, | ||
"manual": { | ||
"index": "./manual/index.md", | ||
"asset": "./manual/asset", | ||
"files": [ | ||
"./manual/installation.md", | ||
"./manual/quickstart.md", | ||
"./manual/htmlTemplate.md" | ||
] | ||
}, | ||
"brand": { | ||
"repository": "https://github.com/ingewortel/cpmjs" | ||
} | ||
} | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module.exports = { | ||
"env": { | ||
"browser": true, | ||
"es6": true, | ||
"node": true, | ||
"jasmine" : true | ||
}, | ||
"extends": "eslint:recommended", | ||
"parserOptions": { | ||
"ecmaVersion": 2015, | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"indent": [ | ||
"error", | ||
"tab" | ||
], | ||
"linebreak-style": [ | ||
"error", | ||
"unix" | ||
], | ||
"quotes": [ | ||
"error", | ||
"double" | ||
], | ||
"semi": [ | ||
"error", | ||
"never" | ||
] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
log.txt | ||
*.swp | ||
build.make | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<title>NoTorusDemo</title> | ||
<style type="text/css"> | ||
body{ | ||
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", | ||
Helvetica, Arial, "Lucida Grande", sans-serif; | ||
padding : 15px; | ||
} | ||
td { | ||
padding: 10px; | ||
vertical-align: top; | ||
} | ||
</style> | ||
|
||
|
||
<script src="./artistoo.js"></script> | ||
<script src="./fpsmeter.min.js"></script> | ||
<script> | ||
"use strict" | ||
|
||
|
||
/* ---------------------------------- | ||
CONFIGURATION SETTINGS | ||
---------------------------------- | ||
*/ | ||
let config = { | ||
|
||
// Grid settings | ||
ndim : 2, | ||
field_size : [500, 13], | ||
|
||
// CPM parameters and configuration | ||
conf : { | ||
// Basic CPM parameters | ||
torus : [false,false], // Should the grid have linked borders? | ||
seed : 1, // Seed for random number generation. | ||
T : 20, // CPM temperature | ||
|
||
// Constraint parameters. | ||
// Mostly these have the format of an array in which each element specifies the | ||
// parameter value for one of the cellkinds on the grid. | ||
// First value is always cellkind 0 (the background) and is often not used. | ||
|
||
|
||
// Adhesion parameters: | ||
J : [ [NaN,20,0], [20,100,200], [0,200,0] ], | ||
|
||
// VolumeConstraint parameters | ||
LAMBDA_V : [0,5,NaN], // VolumeConstraint importance per cellkind | ||
V : [0,500,NaN], // Target volume of each cellkind | ||
|
||
// PerimeterConstraint parameters | ||
LAMBDA_P : [0,2,NaN], // PerimeterConstraint importance per cellkind | ||
P : [0,360,NaN], // Target perimeter of each cellkind | ||
|
||
// BarrierConstraint parameters | ||
IS_BARRIER : [false, false, true ], | ||
|
||
// ActivityConstraint parameters | ||
LAMBDA_ACT : [0,700,NaN], // ActivityConstraint importance per cellkind | ||
MAX_ACT : [0,50,NaN], // Activity memory duration per cellkind | ||
ACT_MEAN : "geometric" // Is neighborhood activity computed as a | ||
// "geometric" or "arithmetic" mean? | ||
|
||
}, | ||
|
||
// Simulation setup and configuration: this controls stuff like grid initialization, | ||
// runtime, and what the output should look like. | ||
simsettings : { | ||
|
||
// Cells on the grid | ||
NRCELLS : [3,0], // Number of cells to seed for all | ||
// non-background cellkinds. | ||
// Runtime etc | ||
BURNIN : 500, | ||
RUNTIME : 1000, | ||
RUNTIME_BROWSER : "Inf", | ||
|
||
// Visualization | ||
CANVASCOLOR : "eaecef", | ||
CELLCOLOR : ["000000","AAAAAA"], | ||
ACTCOLOR : [true,false], // Should pixel activity values be displayed? | ||
SHOWBORDERS : [false,false], // Should cellborders be displayed? | ||
zoom : 2, // zoom in on canvas with this factor. | ||
|
||
// Output images | ||
SAVEIMG : true, // Should a png image of the grid be saved | ||
// during the simulation? | ||
IMGFRAMERATE : 1, // If so, do this every <IMGFRAMERATE> MCS. | ||
SAVEPATH : "output/img/NoTorusDemo", // ... And save the image in this folder. | ||
EXPNAME : "NoTorusDemo", // Used for the filename of output images. | ||
|
||
// Output stats etc | ||
STATSOUT : { browser: false, node: true }, // Should stats be computed? | ||
LOGRATE : 10 // Output stats every <LOGRATE> MCS. | ||
|
||
} | ||
} | ||
/* ---------------------------------- */ | ||
let sim, meter | ||
|
||
|
||
function initialize(){ | ||
/* The following functions are defined below and will be added to | ||
the simulation object. If Custom-methods above is set to false, | ||
this object is ignored and not used in the html/node files. */ | ||
let custommethods = { | ||
initializeGrid : initializeGrid, | ||
buildBorder : buildBorder | ||
} | ||
sim = new CPM.Simulation( config, custommethods ) | ||
|
||
|
||
|
||
meter = new FPSMeter({left:"auto", right:"5px"}) | ||
step() | ||
} | ||
|
||
|
||
function step(){ | ||
sim.step() | ||
meter.tick() | ||
if( sim.conf["RUNTIME_BROWSER"] == "Inf" | sim.time+1 < sim.conf["RUNTIME_BROWSER"] ){ | ||
requestAnimationFrame( step ) | ||
} | ||
} | ||
|
||
|
||
|
||
/* The following custom methods will be added to the simulation object*/ | ||
function initializeGrid(){ | ||
|
||
// add the initializer if not already there | ||
if( !this.helpClasses["gm"] ){ this.addGridManipulator() } | ||
|
||
let nrcells = this.conf["NRCELLS"], cellkind, i | ||
this.buildBorder() | ||
|
||
// Seed the right number of cells for each cellkind | ||
for( cellkind = 0; cellkind < nrcells.length; cellkind ++ ){ | ||
|
||
for( i = 0; i < nrcells[cellkind]; i++ ){ | ||
// first cell always at the midpoint. Any other cells | ||
// randomly. | ||
if( i == 0 ){ | ||
this.gm.seedCellAt( cellkind+1, this.C.midpoint ) | ||
} else { | ||
this.gm.seedCell( cellkind+1 ) | ||
} | ||
} | ||
} | ||
} | ||
|
||
function buildBorder(){ | ||
|
||
let bordervoxels | ||
|
||
bordervoxels = this.gm.makePlane( [], 0, 0 ) | ||
bordervoxels = this.gm.makePlane( bordervoxels, 0, this.C.extents[0]-1) | ||
bordervoxels = this.gm.makePlane( bordervoxels, 1, 0 ) | ||
bordervoxels = this.gm.makePlane( bordervoxels, 1, this.C.extents[1]-1) | ||
|
||
this.gm.changeKind( bordervoxels, 2) | ||
|
||
} | ||
|
||
</script> | ||
</head> | ||
<body onload="initialize()"> | ||
<h1>NoTorusDemo</h1> | ||
<p> | ||
The torus property of the Grid class allows you to choose if the grid boundaries are | ||
linked, but setting them to false may give artifacts if not done properly. Cells will | ||
stick to the border because at the border, they have fewer neighbors to get adhesion and/or | ||
perimeter constraint penalties from. To avoid this, it is best to add a border of | ||
barrier pixels to the edges of the grid. This forbids cells from copying in to the | ||
outermost pixels, and allows you to specify the adhesion with the border specifically. | ||
In this example, the border is made repellant by setting its adhesive penalty | ||
with the cell much higher than that of the background. | ||
|
||
<br> | ||
Note that this would also work when you do not set the torus property to false, since the | ||
barrier layer prevents the cells from crossing the grid borders. However, changing the | ||
torus setting is important for some internal computations (such as computing centroids). | ||
Especially if the grid is small (as it is here in the y dimension), these computations | ||
can go wrong if torus is not properly specified. It is therefore best practice to always | ||
set torus to false if cells cannot cross the grid border. | ||
</p> | ||
</body> | ||
</html> |
Oops, something went wrong.