brain-indexer Python API

brain_indexer classes

High-Level Index API

Open Index

brain_indexer.open_index(path, max_cache_size_mb=None)

Open an index.

Indexes are stored in folders, these folders contain the actual index and a meta data file, typically called meta_data.json. The path is either the file name of the meta data file; or the path of the directory containing the meta data file.

When opening multi-indexes one must specify the amount of memory the index is allowed to consume. This is done through max_cache_size_mb which is the size maximum amount of memory all loaded indexed elements may consume, in MB. Note that this does not include the space required for the tree structure itself. The User Guide contains more information about how a multi-index works and how the cache size affects performance. Regular, in-memory indexes will ignore this flag.

SphereIndex

class brain_indexer.SphereIndex(core_index)
property available_fields

All attributes that can be passed to fields=.

In addition to the builtin fields these may contain the names the SONATA attributes that can be retrieved.

bounds()

The joint minimal bounding box of all elements in the index.

Parameters
  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

box_counts(corner, opposite_corner, *, group_by=None, accuracy=None)

Counts all elements intersecting with the query box.

A detailed explanation is available in the User Guide.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • group_by (str) – Enables first grouping the index elements and then counting the number of elements in each group.

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

box_empty(corner, opposite_corner, *, accuracy=None)

Checks whether the given box intersects any object in the tree.

This is equivalent to

index.box_counts(*box, accuracy=accuracy) == 0

but will return as soon as any element has been found.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

box_query(corner, opposite_corner, *, fields=None, accuracy=None)

Find all elements intersecting with the query box.

A detailed explanation is available in the User Guide.

Parameters
  • fields (str,list) – A string or iterable of strings specifying which attributes of the index are to be returned.

  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

property builtin_fields

The attributes built into the index.

These attributes are stored directly inside the spatial index. Therefore, you can expect good performance for these fields. Furthermore, the builtin fields only depend on the type of index, e.g. “morphology”, “synapse”, etc.

property element_type

A string identifier of the element type.

The element type is one of: "morphology" for morphology indexes; "synapse" for synapse indexes; or "sphere" for sphere indexes.

property populations

The names of the populations covered by this index.

Single population indexes may return [None] instead of the actual population name.

sphere_counts(center, radius, *, group_by=None, accuracy=None)

Counts all elements intersecting with the query sphere.

A detailed explanation is available in the User Guide.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • group_by (str) – Enables first grouping the index elements and then counting the number of elements in each group.

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

sphere_empty(center, radius, *, accuracy=None)

Checks whether the given sphere intersects any object in the tree.

This is equivalent to

index.box_counts(*sphere, accuracy=accuracy) == 0

but will return as soon as any element has been found.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

sphere_query(center, radius, *, fields=None, accuracy=None)

Find all elements intersecting with the query sphere.

A detailed explanation is available in the User Guide.

Parameters
  • fields (str,list) – A string or iterable of strings specifying which attributes of the index are to be returned.

  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

write(index_path)

Saves the index to disk.

No action is performed if index_path is None.

MorphIndex

class brain_indexer.MorphIndex(core_index, sonata_nodes=None)
property available_fields

All attributes that can be passed to fields=.

In addition to the builtin fields these may contain the names the SONATA attributes that can be retrieved.

bounds()

The joint minimal bounding box of all elements in the index.

Parameters
  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

box_counts(corner, opposite_corner, *, group_by=None, accuracy=None)

Counts all elements intersecting with the query box.

A detailed explanation is available in the User Guide.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • group_by (str) – Enables first grouping the index elements and then counting the number of elements in each group.

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

box_empty(corner, opposite_corner, *, accuracy=None)

Checks whether the given box intersects any object in the tree.

This is equivalent to

index.box_counts(*box, accuracy=accuracy) == 0

but will return as soon as any element has been found.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

box_query(corner, opposite_corner, *, fields=None, accuracy=None)

Find all elements intersecting with the query box.

A detailed explanation is available in the User Guide.

Parameters
  • fields (str,list) – A string or iterable of strings specifying which attributes of the index are to be returned.

  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

property builtin_fields

The attributes built into the index.

These attributes are stored directly inside the spatial index. Therefore, you can expect good performance for these fields. Furthermore, the builtin fields only depend on the type of index, e.g. “morphology”, “synapse”, etc.

property element_type

A string identifier of the element type.

The element type is one of: "morphology" for morphology indexes; "synapse" for synapse indexes; or "sphere" for sphere indexes.

property populations

The names of the populations covered by this index.

Single population indexes may return [None] instead of the actual population name.

sphere_counts(center, radius, *, group_by=None, accuracy=None)

Counts all elements intersecting with the query sphere.

A detailed explanation is available in the User Guide.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • group_by (str) – Enables first grouping the index elements and then counting the number of elements in each group.

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

sphere_empty(center, radius, *, accuracy=None)

Checks whether the given sphere intersects any object in the tree.

This is equivalent to

index.box_counts(*sphere, accuracy=accuracy) == 0

but will return as soon as any element has been found.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

sphere_query(center, radius, *, fields=None, accuracy=None)

Find all elements intersecting with the query sphere.

A detailed explanation is available in the User Guide.

Parameters
  • fields (str,list) – A string or iterable of strings specifying which attributes of the index are to be returned.

  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

write(index_path, *, sonata_filename=None, population=None)

Saves the index to disk.

If both sonata_filename and population are passed, then the additional metadata needed to load an index supporting fetching attributes from SONATA is also saved.

No action is performed if index_path is None.

SynapseIndex

class brain_indexer.SynapseIndex(core_index, sonata_edges=None)
property available_fields

All attributes that can be passed to fields=.

In addition to the builtin fields these may contain the names the SONATA attributes that can be retrieved.

bounds()

The joint minimal bounding box of all elements in the index.

Parameters
  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

box_counts(corner, opposite_corner, *, group_by=None, accuracy=None)

Counts all elements intersecting with the query box.

A detailed explanation is available in the User Guide.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • group_by (str) – Enables first grouping the index elements and then counting the number of elements in each group.

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

box_empty(corner, opposite_corner, *, accuracy=None)

Checks whether the given box intersects any object in the tree.

This is equivalent to

index.box_counts(*box, accuracy=accuracy) == 0

but will return as soon as any element has been found.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

box_query(corner, opposite_corner, *, fields=None, accuracy=None)

Find all elements intersecting with the query box.

A detailed explanation is available in the User Guide.

Parameters
  • fields (str,list) – A string or iterable of strings specifying which attributes of the index are to be returned.

  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

property builtin_fields

The attributes built into the index.

These attributes are stored directly inside the spatial index. Therefore, you can expect good performance for these fields. Furthermore, the builtin fields only depend on the type of index, e.g. “morphology”, “synapse”, etc.

property element_type

A string identifier of the element type.

The element type is one of: "morphology" for morphology indexes; "synapse" for synapse indexes; or "sphere" for sphere indexes.

property populations

The names of the populations covered by this index.

Single population indexes may return [None] instead of the actual population name.

sphere_counts(center, radius, *, group_by=None, accuracy=None)

Counts all elements intersecting with the query sphere.

A detailed explanation is available in the User Guide.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • group_by (str) – Enables first grouping the index elements and then counting the number of elements in each group.

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

sphere_empty(center, radius, *, accuracy=None)

Checks whether the given sphere intersects any object in the tree.

This is equivalent to

index.box_counts(*sphere, accuracy=accuracy) == 0

but will return as soon as any element has been found.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

sphere_query(center, radius, *, fields=None, accuracy=None)

Find all elements intersecting with the query sphere.

A detailed explanation is available in the User Guide.

Parameters
  • fields (str,list) – A string or iterable of strings specifying which attributes of the index are to be returned.

  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

write(index_path, *, sonata_filename=None, population=None)

Saves the index to disk.

If both sonata_filename and population are passed, then the additional metadata needed to load an index supporting fetching attributes from SONATA is also saved.

No action is performed if index_path is None.

MorphMultiIndex

class brain_indexer.MorphMultiIndex(core_index, sonata_nodes=None)
property available_fields

All attributes that can be passed to fields=.

In addition to the builtin fields these may contain the names the SONATA attributes that can be retrieved.

bounds()

The joint minimal bounding box of all elements in the index.

Parameters
  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

box_counts(corner, opposite_corner, *, group_by=None, accuracy=None)

Counts all elements intersecting with the query box.

A detailed explanation is available in the User Guide.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • group_by (str) – Enables first grouping the index elements and then counting the number of elements in each group.

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

box_empty(corner, opposite_corner, *, accuracy=None)

Checks whether the given box intersects any object in the tree.

This is equivalent to

index.box_counts(*box, accuracy=accuracy) == 0

but will return as soon as any element has been found.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

box_query(corner, opposite_corner, *, fields=None, accuracy=None)

Find all elements intersecting with the query box.

A detailed explanation is available in the User Guide.

Parameters
  • fields (str,list) – A string or iterable of strings specifying which attributes of the index are to be returned.

  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

property builtin_fields

The attributes built into the index.

These attributes are stored directly inside the spatial index. Therefore, you can expect good performance for these fields. Furthermore, the builtin fields only depend on the type of index, e.g. “morphology”, “synapse”, etc.

property element_type

A string identifier of the element type.

The element type is one of: "morphology" for morphology indexes; "synapse" for synapse indexes; or "sphere" for sphere indexes.

property populations

The names of the populations covered by this index.

Single population indexes may return [None] instead of the actual population name.

sphere_counts(center, radius, *, group_by=None, accuracy=None)

Counts all elements intersecting with the query sphere.

A detailed explanation is available in the User Guide.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • group_by (str) – Enables first grouping the index elements and then counting the number of elements in each group.

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

sphere_empty(center, radius, *, accuracy=None)

Checks whether the given sphere intersects any object in the tree.

This is equivalent to

index.box_counts(*sphere, accuracy=accuracy) == 0

but will return as soon as any element has been found.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

sphere_query(center, radius, *, fields=None, accuracy=None)

Find all elements intersecting with the query sphere.

A detailed explanation is available in the User Guide.

Parameters
  • fields (str,list) – A string or iterable of strings specifying which attributes of the index are to be returned.

  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

SynapseMultiIndex

class brain_indexer.SynapseMultiIndex(core_index, sonata_edges=None)
property available_fields

All attributes that can be passed to fields=.

In addition to the builtin fields these may contain the names the SONATA attributes that can be retrieved.

bounds()

The joint minimal bounding box of all elements in the index.

Parameters
  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

box_counts(corner, opposite_corner, *, group_by=None, accuracy=None)

Counts all elements intersecting with the query box.

A detailed explanation is available in the User Guide.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • group_by (str) – Enables first grouping the index elements and then counting the number of elements in each group.

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

box_empty(corner, opposite_corner, *, accuracy=None)

Checks whether the given box intersects any object in the tree.

This is equivalent to

index.box_counts(*box, accuracy=accuracy) == 0

but will return as soon as any element has been found.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

box_query(corner, opposite_corner, *, fields=None, accuracy=None)

Find all elements intersecting with the query box.

A detailed explanation is available in the User Guide.

Parameters
  • fields (str,list) – A string or iterable of strings specifying which attributes of the index are to be returned.

  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

property builtin_fields

The attributes built into the index.

These attributes are stored directly inside the spatial index. Therefore, you can expect good performance for these fields. Furthermore, the builtin fields only depend on the type of index, e.g. “morphology”, “synapse”, etc.

property element_type

A string identifier of the element type.

The element type is one of: "morphology" for morphology indexes; "synapse" for synapse indexes; or "sphere" for sphere indexes.

property populations

The names of the populations covered by this index.

Single population indexes may return [None] instead of the actual population name.

sphere_counts(center, radius, *, group_by=None, accuracy=None)

Counts all elements intersecting with the query sphere.

A detailed explanation is available in the User Guide.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • group_by (str) – Enables first grouping the index elements and then counting the number of elements in each group.

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

sphere_empty(center, radius, *, accuracy=None)

Checks whether the given sphere intersects any object in the tree.

This is equivalent to

index.box_counts(*sphere, accuracy=accuracy) == 0

but will return as soon as any element has been found.

Parameters
  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

sphere_query(center, radius, *, fields=None, accuracy=None)

Find all elements intersecting with the query sphere.

A detailed explanation is available in the User Guide.

Parameters
  • fields (str,list) – A string or iterable of strings specifying which attributes of the index are to be returned.

  • accuracy (str) – Specifies the accuracy with which indexed elements are treated. Allowed are either "bounding_box" or "best_effort". Default: "best_effort"

  • populations (str,list) – A string or list of strings specifying which populations to query. Ignored by single-population indexes.

  • population_mode (str) – (advanced) Defines if the query uses the single- or multi-population return type. Available: None (native), "single" (single-population), "multi" (multi-population). Please consult the User Guide for a detailed explanation.

High-Level Builder API

MorphIndexBuilder

class brain_indexer.MorphIndexBuilder(morphology_dir, nodes_file, population=None, gids=None)

A MorphIndexBuilder is a helper class to create a MorphIndex from a SONATA nodes file and a morphology library.

Initializes a node index builder

Parameters
  • morphology_dir (str) – The file/directory where morphologies reside

  • nodes_file (str) – The SONATA nodes file

  • population (str, optional) – The nodes population. Defaults to the only population.

  • gids ([type], optional) – A selection of gids to index. Defaults to all GIDs.

classmethod create(*args, progress=False, output_dir=None, **kw)

Interactively create, with some progress

classmethod from_sonata_file(morphology_dir, node_filename, pop_name, gids=None, output_dir=None, **kw)

Creates a node index from a sonata node file.

Parameters
  • node_filename – The SONATA node filename

  • morphology_dir – The directory containing the morphology files

  • pop_name – The name of the population

  • gids – A list/array of target gids to index. Default: None Warn: None will index all synapses, please mind memory limits

  • output_dir – If not None the index will be stored in the folder output_dir.

classmethod from_sonata_selection(morphology_dir, node_filename, pop_name, selection, output_dir=None, **kw)

Builds the synapse index from a generic Sonata selection object

process_cell(gid, morph, points, position)

Process (index) a single cell

process_range(sub_range=(None,))

Process a range of cells.

Param

sub_range (start, end, [step]), or (None,) [all]

SynapseIndexBuilder

class brain_indexer.SynapseIndexBuilder(sonata_edges, selection)

Builder for in-memory synapse indexes.

classmethod create(*args, progress=False, output_dir=None, **kw)

Interactively create, with some progress

classmethod from_sonata_file(edge_filename, population_name, target_gids=None, output_dir=None, **kw)

Creates a synapse index from a sonata edge file and population.

Parameters
  • edge_filename – The Sonata edges filename

  • population_name – The name of the population

  • target_gids – A list/array of target gids to index. Default: None Warn: None will index all synapses, please mind memory limits. Note: For multi-indexes, this keyword argument only needs to be present on the constructor rank.

  • output_dir – If not None the index will be stored in the folder output_dir.

classmethod from_sonata_selection(sonata_edges, selection, **kw)

Builds the synapse index from a generic Sonata selection object.

Any additional keyword arguments are passed on to cls.create.

classmethod from_sonata_tgids(sonata_edges, target_gids, **kw)

Creates a synapse index from an edge file and a set of target GIDs.

MorphMultiIndexBuilder

SynapseMultiIndexBuilder

Source

api.rst