Skip to content

Running AllenSDK models on Arbor

Brent Huisman edited this page Jan 19, 2021 · 3 revisions

Process

This is a very quick summary of the steps taken which can be skipped for the technical details below.

In the beginning, all .mod files were cleaned and ported to arbor, for details see below. In the running setup, arbor and allesdk produced completely different results. We then stripped the model down to a single CV soma and tested all mechanisms individually and in combination. After some trivial fixes it became apparent that the nernst mechanism for concentration equilibria was needed. Neuron automatically enables it following some opaque logic.

From there, the morphology was extended until it achieved the original complexity. At this stage different outputs were observed still. After reviewing the allensdk source, we decided to remove its handling of the axon and hard code its effect --- as we understand it --- into the morphology (see below under allensdk/patching).

Finally, identical outputs were obtained, although they differ from the allen DB references. The geometry of the axon has significant impact on the observed dynamics.

Concurrently with this effort spherical somata were removed from arbor and replaced by cylindrical segments with the same surface area (actually tubes, caps do not contribute to area here) which is close to neuron's behaviour.

Mechanisms

The morphology is divided into 4 non-overlapping regions that are derived from the swc structure identifier field. Not all mechanisms are available on every region. The distribution of mechanisms over the regions in the table below is implicitly derived from the (region,mechanism,parameter) tuples specified in the JSON fit inputs.

           soma   axon   apic   dend

pas X X X X CaDynamics X X CaHVA X X CaLVA X X Ih X X X Imv2 X X KT X Kd X Kv2like X Kv31 X X X X NaV X X X X SK X X

Porting the inputs

Patching modcc

  • added support for FROM ... TO ...
  • added support for units in argument lists
  • allow 'magic' variables, eg v to be accessed in LINEAR

Clean-up

  • remove errors, ie writing to v, ica, etc
  • remove mistaken declarations, eg RANGE v
  • adjust to modcc
    • pass v, celsius, ... to PROCEDURES

Optimisation on Mechanisms

  • replace vtrap with exprelr
  • inline PROCEDURES and convert variables to LOCAL
    • saves signigicant amounts of memory traffic
    • exposes more optimisation opportunities to the backend (C++) compiler
  • extract common sub-expressions and invariants

Benchmarks

Laptop

  • best of three wallclock time
  • MacBook pro 13" 2018 i5
  • Neuron: 117-128s

Effect of Mechanism Optimisation

Version Runtime/s


Baseline 70 Vectorised 21 CaLVA 21 CaHVA 20 Ih 19 NaV 15 SK 15 CaDynamics 14 Kv31 14 Imv2 14 Kd 14 KT 14 Kv2like 13

Ault

Installation

Setting up arbor

This is obsolete abd the naster branch can be used.

git clone <https://github.com/thorstenhater/arbor.git> --branch
nmodl/allen cd arbor mkdir build cd build ccmake ..

make install

Setting up neuron

pip install neuron

Setting up allensdk

pip install allensdk

Patching

  • Remove axon manipulation
    • seems wrong / different from the docs/comments, AllenSDK does one of two things to axon[0]:
      • 'truncated' truncates the axon[0] found in the swx morphology file to 60um length.
      • 'stub' replaces axon[0] with 60um diameter and 1um radius (cylindrical) axon.
    • Option 1.
      • Edit allensdk/model/biophysical/utils.py
      • Comment out ll. 363--383
    • Option 2.
      • Edit model-nrn.py
      • Change 'truncated' to 'stub' on ll. 122

Running the Models

git clone <https://github.com/thorstenhater/allen-models.git> cd
allen-models cd model-491766131 nrnivmodl modfiles python model-nrn.py
manifest.json
  • dynamics and geometry can be swapped via symbolic links

    dynamics : 491766131_fit.json

    all mechanisms
    :   `full-dyn.json`
    
    only passive
    :   `pas-only.json`
    

    geometry : Rbp4-Cre_KL100_Ai14-203503.04.01.01_527109145_m.swc

    original w/ stub axon
    :   `full.swc`
    
    original w/o axon
    :   `full-no-axon.swc`
    
    spherical soma
    :   `single-cv.swc`
    
    cylindrical soma
    :   `single-section.swc`
    
    test geometry
    :   `simple.swc`
    

Results

full.swc (unmodified from AllenSDK)

Arbor vs. NRN, without any modification (full.swc)

Does not correspond (4 spikes vs. 5), due to modified axon in NRN but not Arbor.

Arbor vs. NRN, comment out l363-383 (full.swc)

Corresponds (nearly), due to unmodified axon in both NRN and Arbor.

full-no-axon.swc (modified from AllenSDK: model axon removed, cylindrical 60um long axon added.)

These comparisons are meant to corroborate the AllenSDK axon modifications.

Axon of 0.25um radius in full-no-axon.swc

Arbor vs. NRN, without any modification

Agrees nearly, AllenSDK truncated to 60um but that should not matter because the axon is already 60um long. Contrary to what the comments in the AllenSDK code claim, it seems in trunctation mode it actually replaces the axon as well, and replaces it with a cone with diameters equal to the first and last diameter encountered in the original axon.

Arbor vs. NRN, comment out l363-383

Agreement due to AllenSDK not truncating.

Arbor vs. NRN, l122 set to stub

Disagreement due to AllenSDK replacing with a 1um radius axon. The radius seems to have a great effect.

Axon of 1um radius in full-no-axon.swc

Arbor vs. NRN, without any modification

Agreement.

Arbor vs. NRN, comment out l363-383

Agreement.

Arbor vs. NRN, l122 set to stub

Near agreement.

Clone this wiki locally