Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudon committed Dec 4, 2024
1 parent 6216569 commit 47fd1ce
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 164 deletions.
22 changes: 13 additions & 9 deletions region_grower/synthesize_morphologies.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,17 @@ def _parallel_wrapper(
if p not in ["x", "y", "z", "orientation", "mtype", "current_depth"]
},
)
use_boundary = False
if "atlas_info" in row and isinstance(row["atlas_info"], str):
use_boundary = True
current_space_context = SpaceContext(
layer_depths=row["layer_depths"],
cortical_depths=cortical_depths[row["synthesis_region"]],
directions=row["directions"] if "directions" in row else None,
boundaries=row["boundaries"] if "boundaries" in row else None,
atlas_info=json.loads(row["atlas_info"]) if "atlas_info" in row else None,
directions=row["directions"] if "directions" in row and use_boundary else None,
boundaries=row["boundaries"] if "boundaries" in row and use_boundary else None,
atlas_info=json.loads(row["atlas_info"])
if "atlas_info" in row and use_boundary
else None,
soma_position=current_cell.position,
soma_depth=row["current_depth"],
)
Expand Down Expand Up @@ -570,11 +575,11 @@ def assign_atlas_data(self, min_depth=25, max_depth=5000): # pylint: disable=to
dtype=object,
)

if "directions" in self.atlas.region_structure[_region]:
if "directions" in self.atlas.region_structure.get(_region, []):
self.cells_data.loc[region_mask, "directions"] = json.dumps(
self.atlas.region_structure[_region]["directions"]
)
if "boundaries" in self.atlas.region_structure[_region]:
if "boundaries" in self.atlas.region_structure.get(_region, []):
boundaries = self.atlas.region_structure[_region]["boundaries"]
for boundary in boundaries:
if not Path(boundary["path"]).is_absolute():
Expand All @@ -589,10 +594,9 @@ def assign_atlas_data(self, min_depth=25, max_depth=5000): # pylint: disable=to
)

self.cells_data.loc[region_mask, "boundaries"] = json.dumps(boundaries)
if (
"directions" in self.atlas.region_structure[_region]
or "boundaries" in self.atlas.region_structure[_region]
):
if "directions" in self.atlas.region_structure.get(
_region, []
) or "boundaries" in self.atlas.region_structure.get(_region, []):
self.cells_data.loc[region_mask, "atlas_info"] = json.dumps(
{
"voxel_dimensions": self.atlas.brain_regions.voxel_dimensions.tolist(),
Expand Down
30 changes: 15 additions & 15 deletions tests/data/apical.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
14a03569d26b949692e5dfe8cb1855fe:
- 4.3279709815979
- 59.805320739746094
- -0.6919530630111694
- 4.327972412109375
- 59.805328369140625
- -0.69195556640625
216363698b529b4a97b750923ceb3ffd:
- -70.52275085449219
- 129.78277587890625
- -7.857072830200195
- -7.8570709228515625
4462ebfc5f915ef09cfbac6e7687a66e:
- 1.484359622001648
- 52.40570831298828
- -4.806603908538818
- 1.4843597412109375
- 52.40570068359375
- -4.806610107421875
87751d4ca8501e2c44dcda6a797d76de:
- 13.616881370544434
- 252.8784942626953
- 4.428127288818359
- 13.61688232421875
- 252.87850952148438
- 4.428131103515625
e3e70682c2094cac629f6fbed82c07cd:
- -14.571318626403809
- 114.34882354736328
- 6.069221019744873
- -14.571319580078125
- 114.34881591796875
- 6.0692138671875
e8d79f49af6d114c4a6f188a424e617b:
- -77.39925384521484
- 345.1856994628906
- -33.771915435791016
- 345.18572998046875
- -33.77191162109375
62 changes: 31 additions & 31 deletions tests/data/apical_no_axon.yaml
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
14a03569d26b949692e5dfe8cb1855fe:
- 4.3279709815979
- 59.805320739746094
- -0.6919530630111694
- 4.327972412109375
- 59.805328369140625
- -0.69195556640625
216363698b529b4a97b750923ceb3ffd:
- -70.52275085449219
- 129.78277587890625
- -7.857072830200195
- -7.8570709228515625
4462ebfc5f915ef09cfbac6e7687a66e:
- 1.484359622001648
- 52.40570831298828
- -4.806603908538818
- 1.4843597412109375
- 52.40570068359375
- -4.806610107421875
5bc8fbbcbde5c0994164d8399f767c45:
- 1.9180573225021362
- 56.46493911743164
- -4.888937473297119
- 1.918060302734375
- 56.464935302734375
- -4.8889312744140625
6018366cf658f7a75ed34fe53a096533:
- -1.085249662399292
- -1.0852508544921875
- 57.62152099609375
- -4.8218231201171875
6513270e269e0d37f2a74de452e6b438:
- 8.458586692810059
- 8.458587646484375
- 162.99160766601562
- 4.474689960479736
- 4.4746856689453125
7b89296c6dcbac5008577eb1924770d3:
- 0.7617863416671753
- 57.46580123901367
- 1.8977699279785156
- 0.76177978515625
- 57.465789794921875
- 1.89776611328125
87751d4ca8501e2c44dcda6a797d76de:
- 13.616881370544434
- 252.8784942626953
- 4.428127288818359
- 13.61688232421875
- 252.87850952148438
- 4.428131103515625
b8a1abcd1a6916c74da4f9fc3c6da5d7:
- -84.93132019042969
- 116.4366455078125
- -6.362834453582764
- -6.3628387451171875
cd613e30d8f16adf91b7584a2265b1f5:
- -71.48829650878906
- 137.7943115234375
- -5.734889030456543
- -5.734893798828125
d95bafc8f2a4d27bdcf4bb99f4bea973:
- 7.555803298950195
- 96.93486785888672
- 2.7653095722198486
- 7.5558013916015625
- 96.93487548828125
- 2.7653045654296875
db5b5fab8f4d3e27dda1494c73cf256d:
- -3.1312777996063232
- -3.1312713623046875
- 57.919647216796875
- -0.5503649115562439
- -0.5503692626953125
e3e70682c2094cac629f6fbed82c07cd:
- -14.571318626403809
- 114.34882354736328
- 6.069221019744873
- -14.571319580078125
- 114.34881591796875
- 6.0692138671875
e8d79f49af6d114c4a6f188a424e617b:
- -77.39925384521484
- 345.1856994628906
- -33.771915435791016
- 345.18572998046875
- -33.77191162109375
Binary file modified tests/data/debug_data.pkl
Binary file not shown.
6 changes: 3 additions & 3 deletions tests/data_factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ def generate_region_structure_boundary(
"""Generate region_structure file with boundary entries."""
with open(region_structure_path, encoding="utf-8") as f:
structure = yaml.safe_load(f)
structure["O0"]["boundaries"] = {"path": mesh}
structure["O0"]["boundaries"] = [{"path": mesh}]

if with_sections:
structure["O0"]["boundaries"]["params_section"] = {"d_min": 5, "d_max": 50}
structure["O0"]["boundaries"][0]["params_section"] = {"d_min": 5, "d_max": 50}

if with_trunks:
structure["O0"]["boundaries"]["params_trunk"] = {"d_min": 5, "d_max": 5000}
structure["O0"]["boundaries"][0]["params_trunk"] = {"d_min": 5, "d_max": 5000}

with open(out_path, "w", encoding="utf-8") as f:
yaml.dump(structure, f)
Expand Down
Loading

0 comments on commit 47fd1ce

Please sign in to comment.