neurolang.utils.engine_registry#
Declarative engine registry for the neurolang-query CLI.
Engines are declared in engines/engines.yaml. Each engine may
define:
a Python initialisation script (
python_init);optional Datalog initialisation code (
datalog_init) evaluated after the Python script;optional CSV/TSV relations (
relations) loaded as extensional predicates after the Datalog init. Each relation entry may carry optionalnameanddescriptionfields for predicate metadata used by the--list-predicatescommand. Thefilevalue may be a URL (http:///https://) for automatic download;downloads— files to fetch (with optional archive extraction);templates— neuroimaging templates (brain masks, anatomical templates) downloaded via nilearn or TemplateFlow (if thetemplateflowpackage is installed). Each template may optionally register avoxel(i, j, k)predicate from its non-zero mask:templates: mni_brain: source: nilearn variant: brain_mask predicate: voxel t1_ref: source: templateflow template: MNI152NLin2009cAsym resolution: 1
ontologies— OWL/RDF ontologies to load from URLs or local paths;builtins— list of known function names (exp,log,startswith, etc.) to register as callable symbols;probabilistic_choice— uniform probabilistic choices declared asname: {source: other_predicate}.atlases— brain atlases downloaded via nilearn (e.g.destrieux,schaefer,difumo) and registered as predicates withExplicitVBRregions. Deterministic atlases useExplicitVBR.from_spatial_image_label; probabilistic atlases are thresholded (default 0.5) to create binary region masks.extends— one engine name, or a list of them, whose configuration is inherited (seeresolve_engine_config()); engines markedabstract: trueonly serve as bases and cannot be built or listed;text_embeddings— semantic search over document texts (e.g. PubMed abstracts) with SPECTER2, registered as a functionf(query, doc) -> similarity; seeneurolang.utils.text_embeddings:text_embeddings: study_abstracts: ids_from: study source: pubmed # or {file: ...} or {predicate: ...} function: query_similarity
Usage#
from pathlib import Path
from neurolang.utils.engine_registry import (
build_engine,
show_engines,
list_engine_names,
get_engine_config,
)
# Load engine from the built-in YAML
nl = build_engine("neurosynth", data_dir=Path("data"))
# Load engine from a custom YAML file
nl = build_engine("my_engine", yaml_path=Path("my_engines.yaml"),
data_dir=Path("data"))
# Print available engines with descriptions
show_engines()
# List engine names from a custom YAML
for name in list_engine_names(yaml_path=Path("my_engines.yaml")):
print(name)
Functions
|
Return the |
|
Return the values labelling each region of the atlas name of nl in the image of its grid ( |
|
Create and populate a |
|
Return the engines name extends, directly or not, bases first. |
|
Return the names of the grids of the engine cfg. |
|
Return the YAML configuration dict for a single engine. |
|
Return the predicates of an engine its SQUALL completion withholds. |
|
Return the predicate metadata dict for an engine from its YAML config. |
|
Return the predicates of an engine declared with a probability. |
|
Return the arguments of the predicates of an engine, by predicate. |
|
Return the sorts an engine declares, by name. |
|
Return the names of all registered, non-abstract engines. |
|
Return the rows of the CSV or TSV file path as a DataFrame. |
|
Return the column separator of the relation file path. |
|
Return the configuration of name with all |
|
Print a formatted description of all available engines. |
Classes
|
An argument of a predicate: an entity of a sort over columns. |
|
A sort of entities an engine declares once, in its |
Exceptions
|
Raised for a relation file whose extension is not supported. |