From 47fd1ce6d4cd45e6e9197fc5f2778eb56f4fe76f Mon Sep 17 00:00:00 2001 From: arnaudon Date: Wed, 4 Dec 2024 17:25:12 +0100 Subject: [PATCH] fix test --- region_grower/synthesize_morphologies.py | 22 ++-- tests/data/apical.yaml | 30 ++--- tests/data/apical_no_axon.yaml | 62 +++++------ tests/data/debug_data.pkl | Bin 6720 -> 6930 bytes tests/data_factories.py | 6 +- tests/test_context.py | 134 +++++++++++++---------- tests/test_synthesize_morphologies.py | 64 +++-------- 7 files changed, 154 insertions(+), 164 deletions(-) diff --git a/region_grower/synthesize_morphologies.py b/region_grower/synthesize_morphologies.py index 052823b..ae11bea 100644 --- a/region_grower/synthesize_morphologies.py +++ b/region_grower/synthesize_morphologies.py @@ -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"], ) @@ -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(): @@ -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(), diff --git a/tests/data/apical.yaml b/tests/data/apical.yaml index a27668e..283c669 100644 --- a/tests/data/apical.yaml +++ b/tests/data/apical.yaml @@ -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 diff --git a/tests/data/apical_no_axon.yaml b/tests/data/apical_no_axon.yaml index 98737a0..5371cd3 100644 --- a/tests/data/apical_no_axon.yaml +++ b/tests/data/apical_no_axon.yaml @@ -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 diff --git a/tests/data/debug_data.pkl b/tests/data/debug_data.pkl index b521d09bf153f90e65b73070bdcf032598214882..404efd9d1ebf9d4de68a5afb80651163314d0507 100644 GIT binary patch delta 2072 zcmX?LGRcg!fpsdo^hVabEQ}u}?_+&G`7A33+msC59;VF61*}RU%-&pWQ!-pjrUXsN z@bPB$X7grjpUlW7%gqRu0IKu1n5@VwHJOKr)0)ZOU`obJWZ1)=lA4xSno}|*V^(U( zlq8@TY~JiZGl1rKGl9qq?hHGPX#tZDvxKvQ?M<_otiUfX0x=(EF}pVh%wmX(rgg?n z(b#OrF^O?<1E=%m22KkW4_7=WHEj(7KPm32PRAM+Y242>vC9Ok?+Ky zVz_@wmH;CI!{iD4QbG;?_u3cC4|Fi`s<%p#z` zeQf#~=K?YILqPs!eE~*BR$!=uLrHG3p`dQP6HsrK3y5$B63!etFH9#$+om{7X#)mt zmJd+O-TwAT?TBul4W+eHG_uguYhP3sKVTh3wEBhd3Mo6q(_rfB30k1M=lE39mx(Y9 z1l9lXTl~6)nOF}9I&+}8Xz~M*EkZ~E@@MKvJrD1y$yS0Y^+iD2kpm0W^JN%rLswsy zGW(w7odl>~2&+f+dl}GaBK28mKx=BJWMzOUjjSvvoddGnq3HlPX=ddDdA@0^S$QB) z`wx)xTAGy)x zj9H*~08;p)!4F#O!Ez0(*dsz57#$1@rKzRG#lR$iCuPveDak~*5$r?~{DiK4v!%o= aM$tBJu2xvpZqdV)JE35EQ|{#*RX|8F69kk(d}VMn|y#(NtMZ)t8Ge#Ysr+LDH%TA z?B4v|EbTzHHxr1=;LfnqnC8GZ`3%cD#uJm@@1 zD+2`ZKvE3?McjB6PPd^NRXN)pIz3Q&94pfty1Sw3+tR9o3u!7eqJ+`#vOQ(h(W z;LJ@=ocJdf@_VtX(p<%PjJpt|=Sthl+96|KDq0G(XU3^ZA*R z_whUM@4px6`1C=Iv&H6KhbdVMlT!s0xQ|X><6J1lehA3lJVAhwk+E&^7D3&54Mqlr zEG;0B(dNvd^TKq3v~7yRlr~_fX6XS%-R*Cm)Q;%(*-%Gi^065aJlz}|oG}bH?kf{9!NKBSysRFscbb=8)f2N+)^YE@B!VfvXkS8fH z>r!Ullf08agwa5g(ZX`_2O$yKc=(QFUHR&F`9!#?9_TFeh`^iFsI0giDan&$G)eiR za?R)R25W4wH2JsCN`6?Lg9h8=y@D$BUBI*i&y1-0`@pFVIWwXtUiPreG^7-kV+bfl z^#(#QJTsygO_DoMQyao)Sk6T;88zqjF+wt99nh!1%-8^?G_snYbPJI7X3T1ZP;Ed8 zDHFB>xzJ1qvcWG4Vlyn0f-)zO;=r`Qz)+f6T3ift!vHv?o&vXnolb&Z;a&w-Q$F6j c-a_7+6(s8z`6hdFfonrh