tract_querier.query_processor

Classes

tract_querier.query_processor.DocStringInheritor A variation on
tract_querier.query_processor.EndpointQueryInfo
tract_querier.query_processor.EvaluateQueries This class implements the parser to process White Matter Query Language modules.
tract_querier.query_processor.FiberQueryInfo([...]) Information about a processed query
tract_querier.query_processor.RewriteChangeNotInPrescedence

Methods

tract_querier.query_processor.RewritePreprocess(...)

Methods

tract_querier.query_processor.takewhile takewhile(predicate, iterable) –> takewhile object

Functions

tract_querier.query_processor.deepcopy(x[, ...]) Deep copy operation on arbitrary Python objects.
tract_querier.query_processor.eval_queries(...)
tract_querier.query_processor.gt gt(a, b) – Same as a>b.
tract_querier.query_processor.labels_for_tracts(...)
tract_querier.query_processor.lt lt(a, b) – Same as a<b.
tract_querier.query_processor.queries_preprocess(...)
tract_querier.query_processor.queries_syntax_check(...)

Exceptions

tract_querier.query_processor.TractQuerierSyntaxError(value)
class tract_querier.query_processor.EvaluateQueries[source]

Bases: ast.NodeVisitor

This class implements the parser to process White Matter Query Language modules. By inheriting from ast.NodeVisitor it uses a syntax close to the python language.

Every node expression visitor has the following signature

Parameters:

node : ast.Node

Returns:

tracts : set

numbers of the tracts that result of this query

labels : set

numbers of the labels that are traversed by the tracts resulting from this query

Methods

generic_visit(node) Called if no explicit visitor function exists for a node.
process_assignment(node) Processes the assignment operations
process_relative_term(node) Processes the relative terms
rewrite_side_query(node) Processes the side suffixes in a query
visit(node) Visit a node.
visit_Assign(node)
visit_Attribute(node)
visit_AugAssign(node)
visit_BinOp(node)
visit_BoolOp(node)
visit_Call(node)
visit_Compare(node)
visit_Expr(node)
visit_For(node)
visit_Module(node)
visit_Name(node)
visit_Num(node)
visit_Str(node)
visit_UnaryOp(node)
relative_terms = ['anterior_of', 'posterior_of', 'medial_of', 'lateral_of', 'inferior_of', 'superior_of']
visit_Module(node)[source]
visit_Compare(node)[source]
visit_BoolOp(node)[source]
visit_BinOp(node)[source]
visit_UnaryOp(node)[source]
visit_Str(node)[source]
visit_Call(node)[source]
process_relative_term(node)[source]

Processes the relative terms

  • anterior_of
  • posterior_of
  • superior_of
  • inferior_of
  • medial_of
  • lateral_of
Parameters:

node : ast.Node

Parsed tree

Returns:

tracts, labels

tracts : set

Numbers of the tracts that result of this query

labels : set

Numbers of the labels that are traversed by the tracts resulting from this query

visit_Assign(node)[source]
visit_AugAssign(node)[source]
process_assignment(node)[source]

Processes the assignment operations

Parameters:

node : ast.Node

Parsed tree

Returns:

queries_to_evaluate: dict

A dictionary or pairs ‘<name of the query>’= <node to evaluate>

rewrite_side_query(node)[source]

Processes the side suffixes in a query

Parameters:

node : ast.Node

Parsed tree

Returns:

node_left, node_right: nodes

two AST nodes, one for the query instantiated on the left hemisphere one for the query instantiated on the right hemisphere

visit_Name(node)[source]
visit_Attribute(node)[source]
visit_Num(node)[source]
visit_Expr(node)[source]
generic_visit(node)[source]

Called if no explicit visitor function exists for a node.

visit_For(node)[source]
exception tract_querier.query_processor.TractQuerierSyntaxError(value)[source]

Bases: exceptions.ValueError

exception tract_querier.query_processor.TractQuerierLabelNotFound(value)[source]

Bases: exceptions.ValueError

tract_querier.query_processor.queries_preprocess(query_file, filename='<unknown>', include_folders=[])[source]
tract_querier.query_processor.eval_queries(query_file_body, tractography_spatial_indexing)[source]
tract_querier.query_processor.queries_syntax_check(query_file_body)[source]