This repository was archived by the owner on Feb 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsegment_multi_index_sonata.py
57 lines (41 loc) · 1.65 KB
/
segment_multi_index_sonata.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
Blue Brain Project - Spatial-Index
A small example script on how to create a circuit segment multi-index
with SONATA; load the multi-index and perform some queries.
Must be run with MPI, e.g., one of:
mpiexec -n5 python segment_multi_index_sonata.py
srun -n5 python segment_multi_index_sonata.py
Detailed advice on picking the `srun` parameters can be found
in the documentation.
"""
import os
from mpi4py import MPI
import brain_indexer
from brain_indexer import MorphMultiIndexBuilder
# Loading some small circuits and morphology files on BB5
CIRCUIT_1K = "/gpfs/bbp.cscs.ch/project/proj12/spatial_index/v4/circuit-1k"
NODES_FILE = os.path.join(CIRCUIT_1K, "nodes.h5")
MORPH_FILE = os.path.join(CIRCUIT_1K, "morphologies/ascii")
OUTPUT_DIR = "tmp-doei"
def example_create_multi_index_from_sonata():
# Create a new indexer and load the nodes and morphologies
# directly from the SONATA file
MorphMultiIndexBuilder.from_sonata_file(
MORPH_FILE,
NODES_FILE,
"All",
output_dir=OUTPUT_DIR,
)
def example_query_multi_index():
if MPI.COMM_WORLD.Get_rank() == 0:
# The index may use at most roughly 1e6 bytes.
core_index = brain_indexer.open_index(OUTPUT_DIR, max_cache_size_mb=100)
# Define a query window by its two extreme corners, and run the
# query.
min_corner, max_corner = [-50, 0, 0], [0, 50, 50]
found = core_index.box_query(min_corner, max_corner)
# Now you're ready for the real science:
print(found)
if __name__ == "__main__":
example_create_multi_index_from_sonata()
example_query_multi_index()