Skip to content

Commit

Permalink
Cleanup and README updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rhyolight committed Jul 6, 2017
1 parent 7620045 commit 3dfd070
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
13 changes: 11 additions & 2 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Data, either streaming or batched, that contains the state of the HTM system. Sh

# Configuring an HTM Network for Highbrow

HTM Networks consiste of CorticalColumns, Layers, Neurons, and (sometimes) MiniColumns. HTM Networks can be defined in a configuration file, which is enough information to render the structures in 3D. The configuration is a JSON object that looks like this:
HTM Networks consists of CorticalColumns, Layers, Neurons, and (sometimes) MiniColumns. HTM Networks can be defined in a configuration file, which is enough information to render the structures in 3D. The configuration is a JSON object that looks like this:

```json
{
Expand All @@ -67,12 +67,21 @@ Each node in this tree represents a Renderable object. The top level is an HtmNe

Layers must have dimensions. The dimensions of CorticalColumns and HtmNetworks are calculated from the layers.

## Scale and Spacing

Scale is basically how large the rendering will be. You can think of it also has how big each neuron's renderable space is. By default it is 1 unit, which is pretty small in most spaces. A reasonable scale is `100`, which would give each neuron a space of 100x100x100 unit for rendering.

Spacing represents how much empty space will be between renderable objects. When spacing is applied to the CorticalColumn configuration, it affects how much space is between layers in the column. When applied to Layer configuration, it affects how much space is between Neurons in the Layer.

When applying scale and spacing, be sure to present the spacing values within the scale. For example, if your Layer scale is `100` and you want cells to be spaced with 1/2 a cell width between them, you should set the Layer spacing to `50`.

# Objects

## Neuron

Represents a pyramidal neuron. Neurons can be put into different states. Must be created with a `position` corresponding to its XYZ location in the layer cell grid. Neurons are created by their parent Layer objects.
Represents a pyramidal neuron. Neurons can be put into different states. Must be created with a `position` corresponding to its XYZ location in the layer cell grid. Neurons are created by their parent Layer objects, which decides its `origin` at time of creation.

To get the XYZ origin (the renderable 3D coordinate) of a Neuron, call `neuron.getOrigin()`. To get its position in the cellular grid within the layer, call `neuron.getPosition()`.

## Layer

Expand Down
23 changes: 9 additions & 14 deletions bin/highbrow-0.0.1.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,15 +536,18 @@ class CorticalColumn extends Renderable {
_buildColumn() {
let columnOrigin = this.getOrigin();
let scale = this.getScale();
// let accumulationForLayerY = 0
let processedLayers = [];

// Reverse the layer configuration so that they render from bottom to
// top. slice() copies the array first so the config is not altered.
let reversedLayers = this._config.layers.slice().reverse();
reversedLayers.map((layerConfigOriginal, layerIndex) => {
let layerConfig = Object.assign({}, layerConfigOriginal);
layerConfig.scale = scale;
// Only pass along the column's scale if there is no user-defined
// scale present.
if (layerConfig.scale == undefined) {
layerConfig.scale = scale;
}
layerConfig.origin = this.getOrigin();

// Default cell spacing for layers will be 10% of scale, or 0
Expand All @@ -553,29 +556,21 @@ class CorticalColumn extends Renderable {
if (layerConfig.spacing < 1) layerConfig.spacing = 0;
}

// Get the total height of previously processed layers.
let layerBuffer = processedLayers.map(processedLayer => {
// Get the total height of previously processed layers so we know
// where to put the origin for this layer.
let layerY = processedLayers.map(processedLayer => {
let ydim = processedLayer.getDimensions().y;
let cellHeight = ydim * processedLayer.getScale();
let spacingHeight = (ydim - 1) * processedLayer.getSpacing();
let columnSpacing = this.getSpacing();
console.log("---- %s Y dimensions:", processedLayer.getName());
console.log("cell height: %s\tspacing height: %s\tcolumn spacing: %s", cellHeight, spacingHeight, columnSpacing);
return cellHeight + spacingHeight + columnSpacing;
}).reduce((sum, value) => {
return sum + value;
}, 0);

// Layers need spacing in between them, which will affect their
// origin points in the Y direction. If there are multiple layers,
// their Y origins get updated here using the scale, column spacing,
// and the sizes of lower layers. Each layer is rendered below the
// last to keep the config alignment the same as the visual
// alignment.
layerConfig.origin.y = layerConfig.origin.y + layerBuffer;
layerConfig.origin.y = layerConfig.origin.y + layerY;

let layer = new Layer(layerConfig, this);
// accumulationForLayerY += layer.getDimensions().y
processedLayers.push(layer);
return layer;
});
Expand Down
6 changes: 5 additions & 1 deletion src/cortical-column.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ class CorticalColumn extends Renderable {
let reversedLayers = this._config.layers.slice().reverse()
reversedLayers.map((layerConfigOriginal, layerIndex) => {
let layerConfig = Object.assign({}, layerConfigOriginal)
layerConfig.scale = scale
// Only pass along the column's scale if there is no user-defined
// scale present.
if (layerConfig.scale == undefined) {
layerConfig.scale = scale
}
layerConfig.origin = this.getOrigin()

// Default cell spacing for layers will be 10% of scale, or 0
Expand Down

0 comments on commit 3dfd070

Please sign in to comment.