Mouse brain atlas based placement#

The BSB supports integration with cell atlases. All that’s required is to implement a Voxels partition so that the atlas data can be converted from the atlas raster format, into a framework object. The framework has Allen Mouse Brain Atlas integration out of the box, and this example will use the AllenStructure.

After loading shapes from the atlas, we will use a local data file to assign density values to each voxel, and place cells accordingly.

We start by defining the basics: a region, an allen partition and a cell type:

  "regions": {
    "brain": {"children": ["declive"]}
  },
  "partitions": {
    "declive": {
      "type": "allen",
      "struct_name": "DEC"
    }
  },
  "cell_types": {
    "my_cell": {
      "spatial": {
        "radius": 2.5,
        "density": 0.003
      }
    }
  },

Here, the mask_source is not set so BSB will automatically download the 2017 version of the CCFv3 mouse brain annotation atlas volume from the Allen Institute website. Use mask_source to provide your own nrrd annotation volume.

The struct_name refers to the Allen mouse brain region acronym or name. You can also replace that with struct_id, if you’re using the numeric identifiers. You can find the ids, acronyms and names in the Allen Brain Atlas brain region hierarchy file.

If we now place our my_cell in the declive, it will be placed with a fixed density of 0.003/μm^3:

  "placement": {
    "example_placement": {
      "cls": "bsb.placement.RandomPlacement",
      "cell_types": ["my_cell"],
      "partitions": ["declive"]
    }
  },

If however, we have data of the cell densities available, we can link our declive partition to it, by loading it as a source file:

  "partitions": {
    "declive": {
      "type": "allen",
      "source": "my_cell_density.nrrd",
      "keys": ["my_cell_density"],
      "struct_name": "DEC"
    }
  },

The source file will be loaded, and the values at the coordinates of the voxels that make up our partition are associated as a column of data. We use the data_keys to specify a name for the data column, so that in other places we can refer to it by name.

We need to select which data column we want to use for the density of my_cell, since we might need to load multiple densities for multiple cell types, or orientations, or other data. We can do this by specifying a density_key:

  "cell_types": {
    "my_cell": {
      "spatial": {
        "radius": 2.5,
        "density_key": "my_cell_density",
      }
    }
  },

That’s it! If we compile the network, my_cell will be placed into declive with different densities in each voxel, according to the values provided in my_cell_density.nrrd.