Skip to content

Commit

Permalink
Fix: Update to 3d angles and latest neurots (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudon authored Dec 3, 2024
1 parent dc9efef commit 68f549b
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 235 deletions.
8 changes: 4 additions & 4 deletions region_grower/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from neuroc.scale import scale_section # noqa: E402 ; pylint: disable=C0413
from neurots import NeuronGrower # noqa: E402 ; pylint: disable=C0413
from neurots import NeuroTSError # noqa: E402 ; pylint: disable=C0413
from neurots.utils import PIA_DIRECTION # noqa: E402 ; pylint: disable=C0413
from neurots.utils import Y_DIRECTION # noqa: E402 ; pylint: disable=C0413
from voxcell.cell_collection import CellCollection # noqa: E402 ; pylint: disable=C0413

from region_grower import RegionGrowerError # noqa: E402 ; pylint: disable=C0413
Expand Down Expand Up @@ -85,7 +85,7 @@ def lookup_orientation(self, vector: Optional[Point] = None) -> np.array:
If orientation is None, the direction is assumed towards the pia.
"""
return np.dot(self.orientation, vector)[0] if vector else PIA_DIRECTION
return np.dot(self.orientation, vector)[0] if vector else Y_DIRECTION


@attr.s(auto_attribs=True)
Expand Down Expand Up @@ -197,7 +197,7 @@ def _correct_position_orientation_scaling(self, params_orig: Dict) -> Dict:

for neurite_type in params["grow_types"]:
if isinstance(params[neurite_type]["orientation"], dict):
params["pia_direction"] = self.cell.lookup_orientation(PIA_DIRECTION).tolist()
params["pia_direction"] = self.cell.lookup_orientation(Y_DIRECTION).tolist()
if isinstance(params[neurite_type]["orientation"], list):
params[neurite_type]["orientation"] = [
self.cell.lookup_orientation(orient).tolist()
Expand Down Expand Up @@ -249,7 +249,7 @@ def _post_growth_rescaling(self, grower: NeuronGrower, params: Dict) -> None:

scale = modify.output_scaling(
root_section,
self.cell.orientation.dot(PIA_DIRECTION)[0],
self.cell.orientation.dot(Y_DIRECTION)[0],
target_min_length=target_min_length,
target_max_length=target_max_length,
)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"morph-tool[nrn]>=2.9,<3",
"neuroc>=0.3,<1",
"neurom>=3,<4",
"neurots>=3.6,<4",
"neurots>=3.7,<4",
"numpy>=1.22",
"pandas>=1.5.3",
"tqdm>=4.28.1",
Expand Down
36 changes: 18 additions & 18 deletions tests/data/apical.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
14a03569d26b949692e5dfe8cb1855fe:
- 5.5464959144592285
- 113.9891357421875
- -2.365058422088623
- 4.3279709815979
- 59.805320739746094
- -0.6919530630111694
216363698b529b4a97b750923ceb3ffd:
- -4.380718231201172
- 116.65441131591797
- 6.396718978881836
- -70.52275085449219
- 129.78277587890625
- -7.857072830200195
4462ebfc5f915ef09cfbac6e7687a66e:
- -44.474491119384766
- 68.06861877441406
- -7.087465286254883
- 1.484359622001648
- 52.40570831298828
- -4.806603908538818
87751d4ca8501e2c44dcda6a797d76de:
- 4.237551689147949
- 369.3919677734375
- -0.3368062376976013
- 13.616881370544434
- 252.8784942626953
- 4.428127288818359
e3e70682c2094cac629f6fbed82c07cd:
- -5.780806541442871
- 164.6251678466797
- 0.9229676723480225
- -14.571318626403809
- 114.34882354736328
- 6.069221019744873
e8d79f49af6d114c4a6f188a424e617b:
- -28.59885025024414
- 215.1460723876953
- -12.506669998168945
- -77.39925384521484
- 345.1856994628906
- -33.771915435791016
12 changes: 6 additions & 6 deletions tests/data/apical_NRN_sections.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
14a03569d26b949692e5dfe8cb1855fe:
- 9
- 3
216363698b529b4a97b750923ceb3ffd:
- 9
- 46
4462ebfc5f915ef09cfbac6e7687a66e:
- 12
- 3
87751d4ca8501e2c44dcda6a797d76de:
- 35
- 6
e3e70682c2094cac629f6fbed82c07cd:
- 50
- 18
e8d79f49af6d114c4a6f188a424e617b:
- 20
- 32
28 changes: 14 additions & 14 deletions tests/data/apical_NRN_sections_no_axon.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
14a03569d26b949692e5dfe8cb1855fe:
- 9
- 3
216363698b529b4a97b750923ceb3ffd:
- 9
- 46
4462ebfc5f915ef09cfbac6e7687a66e:
- 12
- 3
5bc8fbbcbde5c0994164d8399f767c45:
- 12
- 3
6018366cf658f7a75ed34fe53a096533:
- 49
- 3
6513270e269e0d37f2a74de452e6b438:
- 5
- 56
7b89296c6dcbac5008577eb1924770d3:
- 5
- 3
87751d4ca8501e2c44dcda6a797d76de:
- 35
- 6
b8a1abcd1a6916c74da4f9fc3c6da5d7:
- 10
- 58
cd613e30d8f16adf91b7584a2265b1f5:
- 6
- 46
d95bafc8f2a4d27bdcf4bb99f4bea973:
- 3
- 11
db5b5fab8f4d3e27dda1494c73cf256d:
- 7
- 5
e3e70682c2094cac629f6fbed82c07cd:
- 50
- 18
e8d79f49af6d114c4a6f188a424e617b:
- 20
- 32
84 changes: 42 additions & 42 deletions tests/data/apical_no_axon.yaml
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
14a03569d26b949692e5dfe8cb1855fe:
- 5.5464959144592285
- 113.9891357421875
- -2.365058422088623
- 4.3279709815979
- 59.805320739746094
- -0.6919530630111694
216363698b529b4a97b750923ceb3ffd:
- -4.380718231201172
- 116.65441131591797
- 6.396718978881836
- -70.52275085449219
- 129.78277587890625
- -7.857072830200195
4462ebfc5f915ef09cfbac6e7687a66e:
- -44.474491119384766
- 68.06861877441406
- -7.087465286254883
- 1.484359622001648
- 52.40570831298828
- -4.806603908538818
5bc8fbbcbde5c0994164d8399f767c45:
- -2.684163808822632
- 112.33018493652344
- 3.1389687061309814
- 1.9180573225021362
- 56.46493911743164
- -4.888937473297119
6018366cf658f7a75ed34fe53a096533:
- -57.31629180908203
- 105.37586975097656
- -68.1922836303711
- -1.085249662399292
- 57.62152099609375
- -4.8218231201171875
6513270e269e0d37f2a74de452e6b438:
- 0.15954150259494781
- 112.9250717163086
- -2.502075672149658
- 8.458586692810059
- 162.99160766601562
- 4.474689960479736
7b89296c6dcbac5008577eb1924770d3:
- 0.4192541837692261
- 57.192779541015625
- 5.780771255493164
- 0.7617863416671753
- 57.46580123901367
- 1.8977699279785156
87751d4ca8501e2c44dcda6a797d76de:
- 4.237551689147949
- 369.3919677734375
- -0.3368062376976013
- 13.616881370544434
- 252.8784942626953
- 4.428127288818359
b8a1abcd1a6916c74da4f9fc3c6da5d7:
- -4.5237274169921875
- 114.20574188232422
- -1.732434630393982
- -84.93132019042969
- 116.4366455078125
- -6.362834453582764
cd613e30d8f16adf91b7584a2265b1f5:
- -1.3810073137283325
- 115.31499481201172
- -1.1782004833221436
- -71.48829650878906
- 137.7943115234375
- -5.734889030456543
d95bafc8f2a4d27bdcf4bb99f4bea973:
- 1.7359588146209717
- 57.819026947021484
- 0.7563515901565552
- 7.555803298950195
- 96.93486785888672
- 2.7653095722198486
db5b5fab8f4d3e27dda1494c73cf256d:
- -45.093421936035156
- 75.82533264160156
- 6.015667915344238
- -3.1312777996063232
- 57.919647216796875
- -0.5503649115562439
e3e70682c2094cac629f6fbed82c07cd:
- -5.780806541442871
- 164.6251678466797
- 0.9229676723480225
- -14.571318626403809
- 114.34882354736328
- 6.069221019744873
e8d79f49af6d114c4a6f188a424e617b:
- -28.59885025024414
- 215.1460723876953
- -12.506669998168945
- -77.39925384521484
- 345.1856994628906
- -33.771915435791016
Binary file modified tests/data/debug_data.pkl
Binary file not shown.
66 changes: 46 additions & 20 deletions tests/data/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
"has_apical_tuft": true,
"metric": "path_distances",
"modify": null,
"orientation": [
[
0.0,
1.0,
0.0
]
],
"orientation": {
"mode": "normal_pia_constraint",
"values": {
"direction": {
"mean": 0.0,
"std": 0.0
}
}
},
"radius": 0.3,
"randomness": 0.15,
"step_size": {
"norm": {
Expand All @@ -30,7 +33,17 @@
"growth_method": "tmd",
"metric": "path_distances",
"modify": null,
"orientation": null,
"orientation": {
"mode": "pia_constraint",
"values": {
"form": "step",
"params": [
0.44484279339093336,
0.5461595884090537
]
}
},
"radius": 0.3,
"randomness": 0.15,
"step_size": {
"norm": {
Expand All @@ -48,8 +61,8 @@
"axon": 0.6
},
"grow_types": [
"basal_dendrite",
"apical_dendrite"
"apical_dendrite",
"basal_dendrite"
],
"origin": [
0.0,
Expand All @@ -66,13 +79,16 @@
"has_apical_tuft": true,
"metric": "path_distances",
"modify": null,
"orientation": [
[
0.0,
1.0,
0.0
]
],
"orientation": {
"mode": "normal_pia_constraint",
"values": {
"direction": {
"mean": 0.0,
"std": 0.0
}
}
},
"radius": 0.3,
"randomness": 0.15,
"step_size": {
"norm": {
Expand All @@ -89,7 +105,17 @@
"growth_method": "tmd",
"metric": "path_distances",
"modify": null,
"orientation": null,
"orientation": {
"mode": "pia_constraint",
"values": {
"form": "step",
"params": [
0.44484279339093336,
0.5461595884090537
]
}
},
"radius": 0.3,
"randomness": 0.15,
"step_size": {
"norm": {
Expand All @@ -107,8 +133,8 @@
"axon": 0.6
},
"grow_types": [
"basal_dendrite",
"apical_dendrite"
"apical_dendrite",
"basal_dendrite"
],
"origin": [
0.0,
Expand Down
24 changes: 12 additions & 12 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,28 +196,28 @@ def test_synthesize_morphologies(
)
assert equal_infos.all()
assert debug_data["apical_sections"].tolist() == [
[72],
[55],
None,
[23],
[46],
None,
[42],
[49],
None,
[38],
[62],
None,
[67],
[74],
[34],
[49],
]
assert debug_data["apical_NRN_sections"].tolist() == [
[50],
[18],
None,
[9],
[46],
None,
[9],
[3],
None,
[12],
[3],
None,
[35],
[20],
[6],
[32],
]

cols = ["apical_sections", "apical_NRN_sections", "apical_points", "debug_infos"]
Expand Down
Loading

0 comments on commit 68f549b

Please sign in to comment.