dbbs-lab / bsb-core

The Brain Scaffold Builder
https://bsb.readthedocs.io
GNU General Public License v3.0
22 stars 16 forks source link

"count_ratio" placement does not work when parent placement is "density_key" #744

Closed drodarie closed 1 year ago

drodarie commented 1 year ago

The following placement of mossy fibers as entities does not work, even with the fix of #683:

cfg = Configuration.default(
    name="Declive",
    storage=dict(engine="hdf5", root="network.hdf5"),
    network=dict(x=528 * 25.0, y=320 * 25.0, z=456 * 25.0, chunk_size=250),
    regions=dict(brain=dict(children=["declive"])),
    partitions=dict(
        declive=dict(
            type="allen",
            sources=["glomerulus_density.nrrd",],
            keys=["glomerulus_density",],
            struct_name="DEC",
        )
    )
    cell_types=dict(
        glomerulus=dict(
            spatial=dict(
                radius=1.5,
                density_key="glomerulus_density",
            ),
        ),
        mossy_fibers=dict(
            spatial=dict(
                relative_to="glomerulus",
                count_ratio=0.05
            ),
        ),
    ),
    placement=dict(
        general_placement=dict(
            strategy="bsb.placement.RandomPlacement",
            cell_types=["glomerulus",],
            partitions=["declive"],
        ),
        granular_layer_innervation=dict(
            strategy="bsb.placement.Entities", partitions=["declive"], cell_types=["mossy_fibers"]
        ),
)

Throws:

Traceback (most recent call last):
  File "/home/toromis/Workspace/dbbs/bsb/bsb/core.py", line 264, in run_placement
    pool.execute(loop)
  File "/home/toromis/Workspace/dbbs/bsb/bsb/services/pool.py", line 285, in execute
    job.execute(self.owner, job.f, job._args, job._kwargs)
  File "/home/toromis/Workspace/dbbs/bsb/bsb/services/pool.py", line 162, in execute
    return f(placement, *args[1:], indicators, **kwargs)
  File "/home/toromis/Workspace/dbbs/bsb/bsb/profiling.py", line 157, in decorated
    return f(*args, **kwargs)
  File "/home/toromis/Workspace/dbbs/bsb/bsb/placement/strategy.py", line 198, in place
    n = indicator.guess()
  File "/home/toromis/Workspace/dbbs/bsb/bsb/placement/indicator.py", line 81, in guess
    sum(PlacementIndicator(s, relation).guess() for s in strats)
  File "/home/toromis/Workspace/dbbs/bsb/bsb/placement/indicator.py", line 81, in <genexpr>
    sum(PlacementIndicator(s, relation).guess() for s in strats)
  File "/home/toromis/Workspace/dbbs/bsb/bsb/placement/indicator.py", line 112, in guess
    raise Exception("Can't guess voxel density without a voxelset.")
Exception: Can't guess voxel density without a voxelset.