tract_querier.query_processor

Classes

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()

tract_querier.query_processor.RewritePreprocess(...)

Functions

tract_querier.query_processor.eval_queries(...)

tract_querier.query_processor.labels_for_tracts(...)

tract_querier.query_processor.queries_preprocess(...)

tract_querier.query_processor.queries_syntax_check(...)

Exceptions

tract_querier.query_processor.TractQuerierLabelNotFound(value)

tract_querier.query_processor.TractQuerierSyntaxError(value)

class tract_querier.query_processor.EvaluateQueries(tractography_spatial_indexing)[source]

Bases: 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:
nodeast.Node

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

visit_Attribute

visit_AugAssign

visit_BinOp

visit_BoolOp

visit_Call

visit_Compare

visit_Constant

visit_Expr

visit_For

visit_Module

visit_Name

visit_UnaryOp

Returns:
tractsset

numbers of the tracts that result of this query

labelsset

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

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_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:
nodeast.Node

Parsed tree

Returns:
tracts, labels
tractsset

Numbers of the tracts that result of this query

labelsset

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:
nodeast.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:
nodeast.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_Constant(node)[source]
visit_Expr(node)[source]
generic_visit(node)[source]

Called if no explicit visitor function exists for a node.

visit_For(node)[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]
tract_querier.query_processor.queries_preprocess(query_file, filename='<unknown>', include_folders=[])[source]
exception tract_querier.query_processor.TractQuerierSyntaxError(value)[source]

Bases: ValueError

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

Bases: ValueError