Skip to content

Commit

Permalink
Add grower for axon trunks
Browse files Browse the repository at this point in the history
Only trivial axon trunks are synthesized to allow axon grafing in
another process.

Change-Id: Iec4d2998c769834d82bfae33951a4b649198e3c6
  • Loading branch information
adrien-berchet committed Jan 14, 2021
1 parent b4032d1 commit 986d275
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 4 deletions.
90 changes: 90 additions & 0 deletions tests/data/axon_trunk_distribution.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"apical": {},
"basal": {
"filtration_metric": "trunk_length",
"num_trees": {
"data": {
"bins": [
4
],
"weights": [
1
]
}
},
"trunk": {
"azimuth": {
"uniform": {
"max": 0.0,
"min": 3.141592653589793
}
},
"orientation_deviation": {
"data": {
"bins": [
0.09586683335089932,
0.39001954178950027,
1.174426764292436,
1.566630375543904,
2.9393430149240416
],
"weights": [
4,
3,
1,
1,
2
]
}
}
}
},
"axon": {
"filtration_metric": "trunk_length",
"num_trees": {
"data": {
"bins": [
1
],
"weights": [
1
]
}
},
"trunk": {
"azimuth": {
"uniform": {
"max": 0.0,
"min": 3.141592653589793
}
},
"orientation_deviation": {
"data": {
"bins": [
0.09586683335089932,
0.39001954178950027,
1.174426764292436,
1.566630375543904,
2.9393430149240416
],
"weights": [
4,
3,
1,
1,
2
]
}
}
}
},
"soma": {
"size": {
"norm": {
"mean": 9.024144162609812,
"std": 3.5462697985669935
}
}
},
"diameter": {"method": "default"}
}
16 changes: 16 additions & 0 deletions tests/data/axon_trunk_parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{"axon": {"randomness": 0.0,
"metric": "trunk_length",
"targeting": 0.2,
"radius": 0.3,
"num_seg": 999,
"orientation": null,
"growth_method": "axon_trunk",
"branching_method": "bio_oriented",
"modify": null,
"tree_type": 2,
"step_size": {"norm":{"mean":1.0, "std":0.2}}},
"origin": [0.0,
0.0,
0.0],
"grow_types": ["axon"],
"diameter_params": {"method": "default"}}
Binary file added tests/data/test_axon_grower.h5
Binary file not shown.
14 changes: 13 additions & 1 deletion tests/test_neuron_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
Finally, we need to check the TMD of the produced cells.
'''


from tempfile import TemporaryDirectory
import json
import os
Expand Down Expand Up @@ -178,6 +177,19 @@ def test_breaker_of_tmd_algo():
assert_array_almost_equal(n.sections[169].points[-1], np.array([117.20551, -41.12157, 189.57013]), decimal=5)
assert_array_almost_equal(n.sections[122].points[-1], np.array([ 77.08879, 115.79825, -0.99393]), decimal=5)


def test_axon_grower():
'''Test axon grower, which should only grow trunks with 1 section to allow later axon grafting.
The num_seg value in the parameters is set to 999 but only 1 segment should be synthesized.
'''
_test_full('radial_distances',
'axon_trunk_distribution.json',
'axon_trunk_parameters.json',
'test_axon_grower.h5',
None)


def test_basic_grower():
_test_full('radial_distances',
'bio_trunk_distribution.json',
Expand Down
15 changes: 15 additions & 0 deletions tns/generate/algorithms/basicgrower.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,18 @@ def extend(self, current_section):
until at least one stop criterion is fulfilled.
'''
return current_section.next()


class AxonAlgo(TrunkAlgo):
"""TreeGrower of axon growth.
Only a trunk with one segment is synthesized and another process is supposed to gaft an actual
axon on this trunk.
"""

def __init__(self, *args, **kwargs):
# Force num_seg in params to 1
params = kwargs.get("params", None) or args[1]
params["num_seg"] = 1

super().__init__(*args, **kwargs)
1 change: 1 addition & 0 deletions tns/generate/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
growth_algorithms = {'tmd': tmdgrower.TMDAlgo,
'tmd_apical': tmdgrower.TMDApicalAlgo,
'tmd_gradient': tmdgrower.TMDGradientAlgo,
'axon_trunk': basicgrower.AxonAlgo,
'trunk': basicgrower.TrunkAlgo}

section_growers = {'radial_distances': SectionGrowerTMD,
Expand Down
4 changes: 2 additions & 2 deletions tns/schemas/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"bias_length": {"type": "number"},
"branching_method": {"type": "string"},
"growth_method": {"type": "string",
"enum": ["tmd", "tmd_gradient", "tmd_apical", "trunk"]},
"enum": ["tmd", "tmd_gradient", "tmd_apical", "axon_trunk", "trunk"]},
"has_apical_tuft": {"type": "boolean"},
"metric": {"type": "string"},
"modify": {"oneOf": [{"type": "object"}, {"type": "null"}]},
Expand Down Expand Up @@ -64,7 +64,7 @@
{"$ref": "#/definitions/neurite"}]},
"basal": {"$ref": "#/definitions/neurite"},
"grow_types": {"type": "array",
"items": {"type": "string", "enum": ["basal", "apical"]}
"items": {"type": "string", "enum": ["basal", "apical", "axon"]}
},
"origin": {"$ref": "#/definitions/point"},
"diameter_params": {
Expand Down
2 changes: 1 addition & 1 deletion tns/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
""" tns version """
VERSION = "2.3.0"
VERSION = "2.3.1.dev0"

0 comments on commit 986d275

Please sign in to comment.