NeuroPype Search Query Grammar
NeuroPype supports a simple subset of Python that can be used in nodes that support searching through packet data, such as SelectInstances
and AssignTargets
. Familiarity with Python is not required (though helpful), but basic familiarity with contemporary programming languages or graphing calculators is expected.
This syntax allows you to form criteria, such as for selection of instances (trials) in a Packet (data passed between nodes) in text form. Examples:
Marker == "mymarker"
(select instances where the Marker is "mymarker")startswith(Marker, "mymarker")
(select instances where the Marker starts with the string "mymarker")TargetValue in [1,2,3]
(select instances where the TargetValue is either 1, 2 or 3)(Duration < 2 or abs(Myval) > 5)
(select instances where the absolute value of custom field 'Myval' is greater than 5 and value of Duration is smaller than 2)
These can be combined using and
and or
; the not
operator can also be used to invert the selection. Example:
startswith(Marker, "mymarker") and not isnan(TargetValue)
(select instances where the Marker starts with "mymarker" and where the TargetValue is a valid value (not a NaN)
Grammar Components
Binary math operators (used as in A + B): + - * / % ** << >> ^ | & //
Unary math operators (used as in -A): ~ + -
Comparison operators (used as in A == B): == != < <= > >=
Any kind of Python or JSON literal value (used as in {"A": [1,2,3.5,('B','C'), "D": "E"}
)
strings, numbers, tuples, lists, dicts (mappings), sets
Special Python operators: A is B, A is not B, A in B, A not in B, A or B, A and B, not A
Variable references (availability of variables depending on context, e.g., fields of an instance axis):
examples: TargetValue > 10
, Marker in ["mrk1","mrk2"]
Array indexing and slice subscripts: A[3]
, A[4:10]
, A[2:10:2]
Function call with positional arguments (function availability depending on context): abs(x) > 10
Built-in Functions (always available)
type casts – convert a value to another data type
int(x)
, float(x)
, bool(x)
, str(x)
basic math operations:
round(x)
, abs(x)
, isnan(x)
sequence operations (e.g., for use on strings or lists etc)
len(x)
, any(x)
, all(x)
basic string operations:
lower(x)
, upper(x)
, startswith(str, prefix)
, endswith(str, suffix)
,
fnmatch(str, pattern)
, split(str, separator)
, replace(str, old, new)
, match(str, regex)