Module: tensor_math
Tensor math operations.
These nodes implement mathematical operations that can be applied to any kind of data tensor (n-way array). These nodes make no domain-specific assumptions (unlike, e.g., signal processing nodes in the filters module), and therefore it is usually necessary to set the axis that they should act on properly. Also the unit of measurement, if applicable, will usually be by default the most generic unit (such as indices on an array), and for certain axes you may need to set it to a domain-specific value to be useful (e.g., Hz for the frequency axis).
AddAxisArray
Create (add) a new array (field) to an existing axis.
This allows you to add custom arrays, which which can act as properties for axis elements (for example, the .names array of the space axis holds the name for each channel of signal data; you might need to create another space axis array to hold a property that can be specified for each channel.) The new array will be the same length as the other existing axis arrays (all of which must be the same length), and be initialized with dummy values (empty strings or zeros, or monotonically increasing numbers if monotonic is True). Use SetAxisValues
after this node to populate the array. The instance axis is a special case as it contains a .data array which itself can hold fields for each instance. When adding an array to an instance axis, this node will add a field to the .data array of the instance axis, rather than create a separate array, unless instance_data_field
is set to False. (Instances can be selected by .data fields using the SelectInstances
node.)
Version 0.9.0
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: Packet (can be None)
- data direction: INOUT
-
array
The name of the array (field) on the axis that will be created.- verbose name: Array
- default value: None
- port type: StringPort
- value type: str (can be None)
-
stream
Name of stream containing the axis to operate on. If empty, the operation will be performed on all streams which contain the specified axis. Note that this does not require an exact match. Any stream with a name beginning with the value specified here will be matched. Wildcards are not supported.- verbose name: Stream
- default value: None
- port type: StringPort
- value type: str (can be None)
-
axis
The Axis to modify, by its type. You can more precisely specify the axis to modify, i.e., if the packet might contain multiple axes of the same type, by including the the axis' custom_label using the following format:axis.mylabel
. Otherwise, the first axis of the given type will be modified.- verbose name: Axis
- default value: feature
- port type: ComboPort
- value type: str (can be None)
-
type
The type of items that the array can hold (strings, numbers, etc.) . Data will be restricted to this type. Use object for an array that may hold values of different types.- verbose name: Type
- default value: str
- port type: EnumPort
- value type: str (can be None)
-
monotonic
If True, the array can only contain monotonically increasing values. This does not apply if the dtype is of str or object type.- verbose name: Monotonic
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
categorical
If True, the array is assumed to be categorical. This only applies to instance axis arrays.- verbose name: Categorical
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
indexable
If True, the array can be indexed, allowing it to be used in the SelectRange node by specifying the array name as the "unit".- verbose name: Indexable
- default value: True
- port type: BoolPort
- value type: bool (can be None)
-
error_handling
How to handle errors when adding the array. If 'warn', a warning will be issued and the operation will continue. If 'ignore', the operation will continue without issuing a warning. If 'raise', an error will be raised and the operation will be aborted.- verbose name: Error Handling
- default value: warn
- port type: EnumPort
- value type: str (can be None)
-
instance_data_field
If True, the array will be added to the .d ata array of the instance axis, instead of creating a separate array for the instance axis. This is unique to the instance axis and included for backward compatibility purposes. This default will be changed to False in the future.- verbose name: Instance Data Field
- default value: True
- port type: BoolPort
- value type: bool (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
AppendAxis
Append a new one-element axis to the incoming packet.
This axis can be given a label for identification, and a position within the packet (though that is rarely needed). Besides packets, this operation can also be used with an incoming array to add new dimensions to an array.
Version 1.2.0
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: INOUT
-
new_axis
New axis type to use. This is the type of axis that should replace the previous one. The axis type is ignored if the data is not of Packet type.- verbose name: New Axis
- default value: space
- port type: EnumPort
- value type: str (can be None)
-
label
Axis label. Optionally the label of the axis to be added. This is useful to identify the axis in the event you have more than one axis of the same type in the same stream.- verbose name: Label
- default value: None
- port type: StringPort
- value type: str (can be None)
-
init_data
Optional index value for the default field (array) of the newly created axis. For frequency axis this will be the frequency value (.frequencies), for space the channel name (.names), for a feature axis the feature name (.names), for a time axis the time in seconds (.times), for an instance axis the name of the Marker (.data["Marker"]). If unspecified a dummy value will be used.- verbose name: Value For New Axis
- default value: None
- port type: StringPort
- value type: str (can be None)
-
position
Position of the new axis. The new axis will be inserted at this position. If the position is negative, the axis will be inserted from the end. For instance, -1 means the last axis, -2 means the second to last axis, etc. (Typically this does not need to be changed.)- verbose name: Position
- default value: -1
- port type: IntPort
- value type: int (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
ConcatInputs
Concatenate the given data (packets, chunks, blocks, arrays or lists) along a new or existing axis.
It is assumed that all data ports are either None or carry items of the same type and, in case of packets, with the same number and type of chunks, and the chunks to be concatenated have the same number of elements along all axes except for the one along which they are concatenated. Any meta-data is copied from the packet on the first input data port (in sequential order) that is non empty. If properties are specified, they will be applied to the axis of concatenated chunks whether or not a new axis is appended. If a new axis is created and the properties parameter is empty, sequential integers will be used as values. If append new axis is selected, the output will have two axes of the same type, one containing the concatenated values, and the other having the values of the first non-empty data port. This node has 10 input ports that can be wired into simultaneously, but can also take a list of packets, in addition or instead of the data ports, in the "dataN" port. If the node is given dictionaries (structures) to concatenate, all dictionaries must have the same fields, and the node will create a structure of arrays (SoA), meaning that the output is a dictionary with the same keys and each key is the concatenation of the values of that key in the input dictionaries. To merge dictionaries with unlike keys, use the DictMerge node. If scalar values are given, they will be concatenated into a list (regardless of the create_new and axis settings), and if sets are given, they will be unioned unless the create_new (axis) option is chosen, in which case they will be concatenated into a list of sets.
Version 1.5.1
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data1
Input data 1.- verbose name: Data1
- default value: None
- port type: DataPort
- value type: AnyIndexable (can be None)
- data direction: IN
-
data2
Input data 2.- verbose name: Data2
- default value: None
- port type: DataPort
- value type: AnyIndexable (can be None)
- data direction: IN
-
data3
Input data 3.- verbose name: Data3
- default value: None
- port type: DataPort
- value type: AnyIndexable (can be None)
- data direction: IN
-
data4
Input data 4.- verbose name: Data4
- default value: None
- port type: DataPort
- value type: AnyIndexable (can be None)
- data direction: IN
-
data5
Input data 5.- verbose name: Data5
- default value: None
- port type: DataPort
- value type: AnyIndexable (can be None)
- data direction: IN
-
data6
Input data 6.- verbose name: Data6
- default value: None
- port type: DataPort
- value type: AnyIndexable (can be None)
- data direction: IN
-
data7
Input data 7.- verbose name: Data7
- default value: None
- port type: DataPort
- value type: AnyIndexable (can be None)
- data direction: IN
-
data8
Input data 8.- verbose name: Data8
- default value: None
- port type: DataPort
- value type: AnyIndexable (can be None)
- data direction: IN
-
data9
Input data 9.- verbose name: Data9
- default value: None
- port type: DataPort
- value type: AnyIndexable (can be None)
- data direction: IN
-
data10
Input data 10.- verbose name: Data10
- default value: None
- port type: DataPort
- value type: AnyIndexable (can be None)
- data direction: IN
-
dataN
Additional input data.- verbose name: Datan
- default value: None
- port type: DataPort
- value type: list (can be None)
- data direction: IN
-
outdata
Data to process.- verbose name: Outdata
- default value: None
- port type: DataPort
- value type: AnyIndexable (can be None)
- data direction: OUT
-
axis
Axis along which to concatenate data. All items must be of the same type and compatible dimensions (meaning, of same dimension for all but the concatenation axis). For plain numeric data and collections, the typed axes are ignored and behave as if axis 0 was selected.- verbose name: Concatenate Along Axis
- default value: time
- port type: ComboPort
- value type: str (can be None)
-
create_new
Whether to create a new axis. If enabled, a new axis of the desired kind will be inserted and data will be concatenated along that axis.- verbose name: Append New Axis
- default value: True
- port type: BoolPort
- value type: bool (can be None)
-
required_inputs
Required number of inputs. If data is not received in at least this many inputs, None will be output for this tick.- verbose name: Required Inputs
- default value: 0
- port type: IntPort
- value type: int (can be None)
-
chunk_props
What properties to write into the returned chunks. If 'first', the properties of the first matching input will be used. If 'merged', the properties are merged across all successive inputs, where later properties override earlier ones.- verbose name: Assign Chunk Props
- default value: first
- port type: EnumPort
- value type: str (can be None)
-
new_axis_custom_label
You can optionally specify a custom_label for the newly created axis, to distinguish it from the original axis. This and the subsequent options apply only to packets.- verbose name: New Axis Custom Label
- default value: None
- port type: StringPort
- value type: str (can be None)
-
properties
Values for the primary property of the new axis, if any. For instance, this would be a list of channel names if the axis is 'space'. If not given and a new axis is inserted, successive integers starting from 0 will be used as the values (so if this is e.g., a frequency axis, then the frequencies will be 0, 1, 2, and so on up to the number of packets that are concatenated.- verbose name: Values For New Axis
- default value: None
- port type: ListPort
- value type: list (can be None)
-
correct_order
Correct axis order. If this is enabled, then axes will be re-ordered to match the axis order in the first data port. This only works if axes do not occur more than once in each block.- verbose name: Correct Order
- default value: True
- port type: BoolPort
- value type: bool (can be None)
-
allow_markers
Enable to allow concatenation of streams with markers. If set to auto, this will be enabled if and only if all packets have only marker streams.- verbose name: Allow Markers
- default value: auto
- port type: EnumPort
- value type: str (can be None)
-
verbose
Print diagnostic outputs about potential edge cases.- verbose name: Verbose
- default value: True
- port type: BoolPort
- value type: bool (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
FiniteDifferences
Calculate the discrete n'th derivative of the given data along a chosen axis using finite differences.
This node will calculate the difference between each value and the next (if order=1). For higher orders it will apply the procedure multiple times, which yields the discrete derivative of order n. This node can be used to compute, for instance, the velocity and acceleration from a time series of positions. The data tensor in the packet, will be replaced with a tensor containing the differences. This node can alternatively take a list of values into its data port, in which case it will output a list of the differences to the same port instead of a packet.
Version 1.1.1
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: INOUT
-
axis
Axis along which to compute the finite difference. The resulting axis will haveorder
elements less than the original (i.e., 3 less iforder
is set to 3), unlesskeep_shape
(keep output shape) property is set to True.- verbose name: Compute Differences Along Axis
- default value: axis
- port type: ComboPort
- value type: str (can be None)
-
order
Differencing order. If this is 3, the 3rd discrete derivative will be computed.- verbose name: Differencing Order
- default value: 1
- port type: IntPort
- value type: int (can be None)
-
keep_shape
If True then the output shape will be the same as the input shape. If data have not been seen then this is accomplished by prepending by zeros. For axes with timestamps only, if data have been seen then old data are held in a buffer. This option should only be used with axes having atimes
array (time
,instance
) so the buffer will be overwritten with real data. Otherwise the firstorder
diffs will always be diff'd against zero and will never make sense.- verbose name: Keep Output Shape (Streaming)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
scale_by_timestep
If True then differences along an axis with atimes
array will be scaled by the difference in times. This is important for calculating velocity and acceleration in units of x/sec and /sec^2, or when samples are irregular. Set this to false if using this node to calculate differences in timestamps (i.e., if preceded by the ExtractMarkerTimestamps node).- verbose name: Scale By Timestep
- default value: True
- port type: BoolPort
- value type: bool (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
FiniteDifferencesCentral
Calculate the discrete n'th derivative of the given data along a chosen axis using central finite differences.
This node will calculate the difference between next and previous (if order=1). For higher orders it will apply the procedure multiple times, which yields the discrete derivative of order n. This node can be used to compute, for instance, the velocity and acceleration from a time series of positions. It has a smoothing effect compare to the regular finite difference.
Version 1.0.0
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: Packet (can be None)
- data direction: INOUT
-
axis
Axis along which to compute the finite difference. The resulting axis will haveorder
elements less than the original (i.e., 3 less iforder
is set to 3), unlesskeep_shape
(keep output shape) property is set to True.- verbose name: Compute Differences Along Axis
- default value: time
- port type: ComboPort
- value type: str (can be None)
-
order
Differencing order. If this is 3, the 3rd discrete derivative will be computed.- verbose name: Differencing Order
- default value: 1
- port type: IntPort
- value type: int (can be None)
-
keep_shape
If True then the output shape will be the same as the input shape. If data have not been seen then this is accomplished by prepending by zeros. For axes with timestamps only, if data have been seen then old data are held in a buffer. This option should only be used with axes with times (time, instance) so the buffer will be overwritten with real data. Otherwise the firstorder
diffs will always be diff'd against zero and will never make sense.- verbose name: Keep Shape
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
scale_by_timestep
If True then differences along an axis with times attribute will be scaled by the difference in times. This is important for calculating velocity and acceleration in units of x/sec and /sec^2, or when samples are irregular.- verbose name: Scale By Timestep
- default value: True
- port type: BoolPort
- value type: bool (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
FoldIntoAxis
Fold an axis into another axis.
For instance, if you have a data array with 3 axes, e.g., space, feature, and time, and you fold the feature axis into the space axis, you end up with data that has only space and time. The number of elements in the destination axis (space) will be the product of the previous number of elements in that axis and the number of elements in the source axis (feature). This node currently assumes that the destination axis is indexed with names (e.g., space axis and feature axis). After folding, that axis will have new names of the form A-B where A are the previous names of the destination axis, and B are the names (or stringified values) of the source axis (all combinations of A's and B's are generated, like in a Cartesian product). Tip: if you have two occurrences of the same axis type (e.g., space, and space), and you merge one into the other, then the first occurrence of the space axis will be the destination axis (and therefore its channel labels will appear before the separator character), and the second occurrence will be the source axis (and thus its labels will come after the separator char). If your data is not symmetric (e.g., weights on a directed graph), and one axis is the 'from' space axis and the other is the 'to' space axis, you need to make sure that they occur in the expected order in the incoming data packet (to first), which you can ensure using the MoveAxisFirst node.
Version 1.0.1
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: Packet (can be None)
- data direction: INOUT
-
src_axis
Axis to fold. This is the type of the axis that shall be folded into another axis. This axis will drop out of the data.- verbose name: Source Axis
- default value: lag
- port type: ComboPort
- value type: str (can be None)
-
dst_axis
Axis to fold into. This is the axis into which the other one shall be folded. This axis will remain in the data but will have correspondingly more entries to hold all the data.- verbose name: Destination Axis
- default value: space
- port type: ComboPort
- value type: str (can be None)
-
round_digits
Number of digits after the comma. This is only used when numbers are being stringified (e.g., when folding a time or frequency axis into a space or feature axis.- verbose name: Round Digits
- default value: 3
- port type: IntPort
- value type: int (can be None)
-
separator
Separator character between destination and source axis entry name. For example, setting this to : will create new channels of the form Fp1:C4, and so on.- verbose name: Separator
- default value: -
- port type: StringPort
- value type: str (can be None)
-
instance_type
When folding an instance axis into another axis, specify the source data to use for generating labels.- verbose name: Instance-Axis Source Data
- default value: auto
- port type: EnumPort
- value type: str (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
LogSpacing
Keep elements along an axis with logarithmic spacing.
This node will select a subset of elements along the chosen axis, which can, e.g., be used to reduce the amount of data (i.e., dimensionality reduction). This node will pick elements not with equidistant spacing, but with a spacing that increases in an exponential fashion (so in other words the spacing would be equidistant after the logarithm has been taken). This is most useful when applied along the frequency axis.
Version 1.0.0
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: Packet (can be None)
- data direction: INOUT
-
axis
Axis along which elements shall be selected.- verbose name: Select Elements Along Axis
- default value: frequency
- port type: ComboPort
- value type: str (can be None)
-
points
Number of sampling points to keep. This many data points will be kept.- verbose name: Number Of Points To Keep
- default value: 30
- port type: IntPort
- value type: int (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
MoveAxisFirst
Move the given axis to the beginning of the list of axes.
Generally, data in NeuroPype is stored in multi-dimensional arrays (a.k.a. tensors), and these arrays have axes, such as space, time, frequency, instance, feature, and so on. These axes can generally be in any order, and nodes usually are robust to axis reorderings. However, some use cases may require some nodes to be reordered (see also ReorderAxes). The main use case for this node is when data has multiple axes of the same type, and a subsequent node shall be applied to a specific axis (e.g., one that is labelled with a particular custom label). Typically in such cases a node will simply act on the first axis of a given type (e.g., SelectRange), and by prepending this node prior to that operation, it is possible to pick a specific axis based on some criteria (currently involving the custom label), and make it the one that the next operation will act on.
Version 1.0.0
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: Packet (can be None)
- data direction: INOUT
-
axis
Axis type to select.- verbose name: Axis Type
- default value: time
- port type: ComboPort
- value type: str (can be None)
-
memory_layout
Optionally the new memory layout of the data. The default keep will keep the original layout, which never incurs any copying and this is fastest. The 'linear' option will reorder the data into the best-fitting linear (contiguous) order (which may be either C or FORTRAN). The C option reorders the memory such that the elements in the last given axis lie closest to each other ('vary fastest' when stepping through memory) and the elements in the first axis are the farthest apart. The FOTRAN option is the opposite of the C option. Such reordering can improve the speed of the subsequent processing node(s), traded off by the cost of copying the data in this node.- verbose name: Memory Layout
- default value: keep
- port type: EnumPort
- value type: str (can be None)
-
label
Axis label. Optionally the label of the axis to move first. Note that you can also write time.blah to specify the time axis that has label "blah".- verbose name: Axis Label
- default value: None
- port type: StringPort
- value type: str (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
OperateAxis
Perform an operation (subtract, add, multiply, divide) on the data values between pairs of elements in an axis (instance, feature, space), and expand the data tensor along that axis to add the result.
(Optionally, can output only the newly computed data and drop the original data.) Also creates a marker or name for each new data element (in instance.data[
Version 1.0.0
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: Packet (can be None)
- data direction: INOUT
-
operator
The operator representing the operation to be performed on data of the two elements.- verbose name: Operator
- default value: subtract
- port type: EnumPort
- value type: str (can be None)
-
operate_axis
Axis containing the data set to be operated on. Supports the instance, feature and space axes. If there is more than one axis of the same type, the first axis will be selected.- verbose name: Operate Axis
- default value: instance
- port type: EnumPort
- value type: str (can be None)
-
operate_field
When operating on the instance axis, the name of the .d ata field to be updated with the name of the result of the operation (i.e, 'target-control'), such as Marker, Group, Session, etc. If you specify the operands by name, this is the field that will be searched to find the instances to operate on. This field is ignored when operating on an axis other than the instance axis.- verbose name: Operate Field
- default value: Marker
- port type: StringPort
- value type: str (can be None)
-
operands
The element pairs for which data is to be operated on, and their order in the operation. Using subtract as an example: [0, 1] will subtract data of the second element from the first element (element0 - element1). If the axis has more than two elements, you can select which ones should be subtracted. Optionally, you can specify the names of markers (instance axis), feature names (feature axis), or channels (space axis) instead of element index numbers. I.e., ['left', 'right'] will perform a left-right subtraction (with operator set to 'subtract'). Several pairs of can be computed on by specifying a list of lists: [[5, 8],['left', 'right']]. Tip: write [0, -1] to operate on first and last elements.- verbose name: Operands
- default value: [0, 1]
- port type: ListPort
- value type: list (can be None)
-
output_operated_only
Only the newly computed data will be output, not the original data.- verbose name: Output Operated Only
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
verbose
Print to console the axis element names/markers after operation.- verbose name: Verbose
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
OverrideAxis
Override a specific axis in the data by a new axis.
This allows you to effectively 'relabel' an axis, for instance from frequency to time, or from space (=channels) to features. The main use case is when you have processing nodes that expect a particular axis type to be present in the data, but your data has axes of a different type. The new axis will have the same number of elements than the old axis. Since most axes can store per-element information, for instance the channel labels, it is possible to give a list of initialization values for the new axis type.
Version 1.5.1
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: Packet (can be None)
- data direction: INOUT
-
old_axis
Axis to replace. This is the type of the axis in the current data that you want to replace by a new axis. Note that you can also write feature.mylabel to reference an axis that has a specific custom label set, and thereby further refine what axis you want to override.- verbose name: Old Axis To Override/remove
- default value: feature
- port type: ComboPort
- value type: str (can be None)
-
new_axis
New axis type to use. This is the type of axis that should replace the previous one. You can also specify a desired new label for the axis in here by writing space.mylabel.- verbose name: New Axis To Insert
- default value: space
- port type: ComboPort
- value type: str (can be None)
-
init_data
Optional initial values for the new axis primary array. For example, use this field to provide frequencies (float in Hz) for a new frequency axis, channel names (string) for a new space axis, feature names (string) for a feature axis, time stamps (float, in seconds) for a new time axis, or lag offsets (float, in seconds) for a lag axis. For an instance axis, this list will be supplied to the InstanceAxis initializer'sdata
array and by default will populate the Marker field of the data array. See the InstanceAxis documentation for more information. If this parameter (values for new axis) is empty, the new axis will attempt to initialize itself with information from the old axis if 'carry over labels' or 'carry over numbers' (depending on destination axis type) is set. Otherwise the new axis will be initialized with dummy values. In any event, the length of the new axis will match the length of the old axis, since there is no change in the shape of the data. If values are provided in this parameter, AND carry_over_names is True, AND labels can be inferred from the old axis, AND the new axis expects labels as its indexing array, then these values can be combined with the old labels according to the format injoin_format
(joining is off by default).- verbose name: Values For New Axis
- default value: None
- port type: ListPort
- value type: list (can be None)
-
axis_occurrence
Index of the occurrence of the axis of desired type. (0
is the first axis of the desired type,1
is the second,-1
is the last,-2
is the second-to-last, and so on). This should be rarely used. Instead, give the target axis a custom label, if it doesn't already have one (usingSetAxisLabel
) and specify the label in theaxis
property (see help for that property).- verbose name: Axis Occurrence
- default value: 0
- port type: IntPort
- value type: int (can be None)
-
carry_over_names
Carry over labels from previous axis, if present. Retrieved label format depends on verbosity and decimals parameters and the specific axis implementation of get_labels.- verbose name: Carry Over Labels
- default value: True
- port type: BoolPort
- value type: bool (can be None)
-
carry_over_numbers
Carry over numbers of previous axis, if present. This can be used to force the numerical axis data of the old axis into the new axis (e.g., time vs. frequency).- verbose name: Carry Over Numbers
- default value: True
- port type: BoolPort
- value type: bool (can be None)
-
keep_other_arrays
If the old axis and new axis are the same type then it is possible to carry over any other arrays such as space positions, or frequency bandwidths.- verbose name: Keep Arrays When Same Axis Type
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
keep_props
If the old axis and new axis are the same type then it is possible to carry over any other axis properties.- verbose name: Keep Properties When Same Axis Type
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
only_signals
If set to true, only axes on signal chunks will be overridden.- verbose name: Only Signals
- default value: True
- port type: BoolPort
- value type: bool (can be None)
-
verbosity
Specify the verbosity level applied to the retrieval of the labels carried over from the previous axis.- verbose name: Verbosity
- default value: 0
- port type: IntPort
- value type: int (can be None)
-
decimals
Specify the number of places after the decimal to keep when converting old axis numeric to new axis strings. This (probably) only applies when verbosity > 0.- verbose name: Decimals
- default value: 3
- port type: IntPort
- value type: int (can be None)
-
join_format
Determine how to proceed when values for the new axis are provided, and carry_over_names is True, and the old axis has values that can be mapped to the new axis' primary array (i.e ., names for a Space axis). Use {new} and {old} to indicate how the newly provided values, and the values from the old axis, respectively, should be used and/or combined. By default only the newly provided values, if specified, are used. Common examples: '{new}' - Any old labels are ignored. '{new} ({old})'- verbose name: Join Format
- default value: {new}
- port type: StringPort
- value type: str (can be None)
-
axis_caching
If set to true, the axis will be cached and reused if the same inputs are encountered again for this node. This can be useful if the axis is expensive to create, but can cause churn and unnecessary overhead if details of the axis (e.g., array contents) differ with each update of this node.- verbose name: Axis Caching
- default value: True
- port type: BoolPort
- value type: bool (can be None)
-
custom_label
Custom label to be given to the new axis; if None, the custom_label from the old axis will be copied (if any).- verbose name: New Custom Label
- default value:
- port type: StringPort
- value type: str (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
RandomSubset
Select a random subset of instances in the given data.
Version 1.1.0
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: Packet (can be None)
- data direction: INOUT
-
subset_axis
Axis along which to subset the data.- verbose name: Subset Axis
- default value: instance
- port type: ComboPort
- value type: str (can be None)
-
count
Number of items to retain (you may only set this property orfraction
, not both).- verbose name: Count
- default value: None
- port type: IntPort
- value type: int (can be None)
-
fraction
Fraction of items to retain (you may only set this property orcount
not both).- verbose name: Fraction
- default value: None
- port type: FloatPort
- value type: float (can be None)
-
only_targets
Act only on instance elements that have theTargetMarkers
field set. This can be accomplished via theAssignTargets
node.- verbose name: Only Targets
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
random_seed
Seed for the random number generator. If not set, a random seed is chosen each time the node is run.- verbose name: Random Seed
- default value: None
- port type: IntPort
- value type: int (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
ReorderAxes
Reorder the axes in the given data.
Generally, data in NeuroPype is stored in multi-dimensional arrays (a.k.a. tensors), and these arrays have axes, such as space, time, frequency, instance, feature, and so on. These axes can generally be in any order, and nodes usually are robust to axis reorderings. However, in some rare cases a node might expect axes in a particular order (e.g., custom code). Besides Packets, this node can also be used with multidimensional arrays or lists of lists having a with regular top-level structure, to regroup items.
Version 1.1.1
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: INOUT
-
order
New axis order. Axes can be referenced by their type and/or name (i.e., 'space', or 'space.mylabel'), or by their index order (0, 1 etc.). The former is recommended since the exact order of the axes could be changed by previous nodes. This can formatted as a string (i.e.,space, time, frequency
), or as a list (or tuple) of strings. If referencing axes by type or name, two special symbols are allowed: ':' (one axis of any type) and '...' (zero or more axes of any type), i.e.,:, time, ...
. Do not mix index and name references. WARNING: This parameter is not safe to expose on the network.- verbose name: New Order
- default value: ...
- port type: Port
- value type: object (can be None)
-
memory_layout
Optionally the new memory layout of the data. The default keep will keep the original layout, which never incurs any copying and this is fastest. The 'linear' option will reorder the data into the best-fitting linear (contiguous) order (which may be either C or FORTRAN). The C option reorders the memory such that the elements in the last given axis lie closest to each other ('vary fastest' when stepping through memory) and the elements in the first axis are the farthest apart. The FOTRAN option is the opposite of the C option. Such reordering can improve the speed of the subsequent processing node(s), traded off by the cost of copying the data in this node.- verbose name: Memory Layout
- default value: keep
- port type: EnumPort
- value type: str (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
Reverse
Reorder the elements along an axis, and the corresponding data slices, so they are in reverse order.
This will act on every stream in the packet containing the specified axis. As with many nodes in the TensorMath
package, this node can also take a numerical array or list of strings, instead of a Packet, in which case the output will be an array or list.
Version 1.1.0
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: AnyIndexable (can be None)
- data direction: INOUT
-
axis
Axis along which the data will be reversed. You can also enter the axis label here as in feature.mylabel. If the input to this node is an array instead of a Packet, specify the array axis index (i.e., 0, 1).- verbose name: Axis
- default value: feature
- port type: ComboPort
- value type: str (can be None)
-
stream
Stream name on which to operate; if unspecified, all streams containing the specified axis will be modified. Wildcards are supported, somystream*
will match the first stream whose name starts withmystream
.- verbose name: Stream
- default value:
- port type: StringPort
- value type: str (can be None)
-
stream_name
- verbose name: Stream Name
- default value: None
- port type: AliasPort
- value type: str (can be None)
-
axis_label
Optionally the custom_label of the axis to reverse along. Note that you can generally enter the label as part of the axis to operate on, using either the syntax myaxis.mylabel or myaxis(label='mylabel').- verbose name: Axis Label
- default value:
- port type: StringPort
- value type: str (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
SelectRange
Select a subset (slice) of the data along any axis, such as space (channels), time (seconds), frequency (Hz), instance (segments or trials), feature (names), etc.
This node will take any nonempty chunk that has the specified axis, and then extract the desired selection range along that axis (retaining all the other axes, or dimensions of the data for that slice). The range can be given in a variety of formats and units (see the selection
and unit
property help). Note that the Instance axis (typically used for trials in a signal stream and event markers in a marker stream), has a special structure, so to select along that axis other than by index, use the SelectInstances
node instead of this one.
Version 1.6.0
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: AnyIndexable (can be None)
- data direction: INOUT
-
axis
Axis along which to select data. Use the space axis when you want to select channels, the instance axis to select trials or segments, the feature axis when the data happens to contain features (e.g., after feature extraction), or time and frequency axes. If there are multiple axes of the same type in the data, you can specify the axis label (which can be set with SetAxisLabel node), using the following syntax:axis.label
(i.e.,space.mylabel
). If the order of the axes is fixed, you can also specify the axis by its position, i.e.,0
for the first axis,1
for the second axis, and-1
for the last axis (0-base indexing). However, it is recommended to use the axis label instead, as the order of the axes may be changed by other nodes in the pipeline. When applied to arrays or lists, any named axis will be treated as the first axis of the data.- verbose name: Select Along Axis
- default value: time
- port type: ComboPort
- value type: str (can be None)
-
selection
The range of data to select along the desired axis. The simplest form is a list of indices (withunit
set toindices
) such as[0,1,2,5,6]
(indices always count from 0), or a list of values (i.e., channel names) withunit
set todefault
, e.g.,['C3','C4','Cz']
, though you may also omit the brackets and quotes, as inC3,C4,Cz
. If you want to select a range of indices or values (i.e., frequencies or timestamps), you can specify this in the form of an inclusive range, i.e.,10...20
, where the last index or value will be included. In this example, ifunit
isdefault` or
Hz, and axis is
frequency, all data with frequencies between 10Hz up to and including 20Hz will be selected. Another allowed format is a "slice" (in python), in the form
10:20, where the last value is not included. So with
axisas
frequencyand
unitas
default, this would select all frequencies from 10Hz up to but not including 20Hz. Note that, for continuous data (e.g., frequencies) these two modes may be equivalent since the final value may not occur in the data. The slice syntax can be more useful when selecting multiple adjacent intervals (e.g., frequency bands), and you do not want to double count the boundary values into multiple intervals. With the slice syntax, the value before or after the
:can be omitted, which is then assumed to stand for the first or last element. So
3:with
indiceswill select all items starting with the 4th one (the first item has an index of 0), and
:10will select the first 10 items, and
:will select all items. And
30:with axis as
timeand unit as
default(or
seconds) will select all data starting at 30 seconds and up to the end, or
:60with axis as
frequenciesand unit as
default(or
Hz) will select all frequencies up (but not including) to 60Hz. Negative numbers are allowed. If the unit is
indices, negative numbers count from the end of the list, so
-1is the last item,
-2the second to last, etc. For example,
-10:-1will select the last 9 items (the last item is not included since a slice is not inclusive), whereas
-10...-1will select the last 10 items, and is equivalent to
-10:. If the unit is something other than
indices, (i.e.,
default,
seconds,
Hz, etc.), negative numbers are interpreted as numeric values of that unit, so
-5...10with
axisas
timeand
unitas
default(or
seconds), will select all samples with a timestamp between -5 and 10 seconds (including 10), and
30:on data where the timestamps start at 0, will select all data except the first 30 seconds. (In most cases, if you don't want to select by index number, you should set the unit to
default. See the
unit`` property for more information.) A selection range can also be an array of values or (when using the 'indices' unit) of indices or a boolean mask, but it must be a vector (1D array, meaning that at most one dimension can be greater than 1). When your data is a packet, you can also specify a selection range for each chunk in the packet by providing the selection as either a packet or a dictionary of selections, where the keys are the chunk names.- verbose name: Selection Range
- default value: :
- port type: Port
- value type: object (can be None)
-
invert_selection
If True, the selection is inverted; that is, all items except those listed in selection_range are selected. Note that presently this feature only supports the case where selection_range is a list of indices or values, not a range (using:
or...
).- verbose name: Invert Selection
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
unit
Unit in which the selection is given. These can be indices (starting with 0 as the first item), or, more typically, a different unit is used for each type of axis. For instance, for the time axis, you generally want to set the unit toseconds
; in which case, the selection range10:50
is interpreted as "all the data starting at 10 seconds and up to (but not including) 50 seconds". For the frequency axis, the most useful unit would beHz
. For the space axis, it is common to specify a list of channel names inselection range
, e.g.,['C3','C4','Cz']
or'A1':'A32'
, in which case the unit should be set tonames
. If set todefault
, the most commonly used unit for the axis other than indices will be automatically used (that is,names
for space,seconds
for time,Hz
for frequency,names
for feature,parameter_types
for for statistic). So most of the time, you will either want to set this toindices
ordefault
. (Theauto
option is deprecated. Usedefault
to auto-select the correct unit for the axis, orindices
if you want to select by index number.)- verbose name: Unit Of Measurement For Selection
- default value: indices
- port type: ComboPort
- value type: str (can be None)
-
drop_if_nonrange
If the selection is not a range (list, array, slice, etc) but a plain index or value, whether to drop the affected axis. The legacy mode implements the NP 2023 and 2024 semantics, which kept the axis if and only if the data was a block, chunk or packet, and otherwise dropped it.- verbose name: Drop Axis If Selection Is A Scalar
- default value: legacy and warn
- port type: EnumPort
- value type: str (can be None)
-
apply_time_selection_to_markers
Apply the time axis selection to the instance axis of any accompanying marker streams.- verbose name: Apply Time Selection To Markers
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
apply_multiple_axes
Apply the select range to all occurrences of the axis in the data. Deprecated: Simply type the axis property as*myaxis
(i.e.,*space
) to have it apply to all occurrences of myaxis.- verbose name: Apply To All Occurrences Of Axis
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
SeparateAxisElements
Separate the given axis elements into new axis elements.
For each item in the mapping, the data value(s) associated with the key will be repeated to the same size as the mapping value. This node can be used to expand an axis that was compressed with the Combine Axis Elements node. For example, if Combine Axis Elements was used to group ROIs and calculate a single value for a brain area, this node can then be used to recreate the individual ROIs within an area, with the data value from the area repeated for each ROI.
Version 0.1
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: Packet (can be None)
- data direction: INOUT
-
mapping
Grouping of old axis elements into new axis elements. The syntax is {old_ele_0: [new_ele_00, new_ele_01, ...], old_ele_1: [new_ele_10, new_ele_11, new_ele_11, ...], ...} wherenew_ele_X
provide the items used to initialize the reconstructed axis, and eachold_ele_X
references a single item to be replaced in the old axis. Values for either can be provided as strings to be matched, integer indices, or floats. Example: {'mychan': [0,1,2], 'myotherchan': ['oldchanA','oldchanB','oldchanC']}. If mapping is None (default) then the target axis must have a 'original_elements' property.- verbose name: Element Grouping
- default value: None
- port type: Port
- value type: object (can be None)
-
axis
The type of axis to operate on. The axis type may be appended by the axis label, separated by a . (dot), e.g.,space.my_label
.- verbose name: Axis
- default value: space
- port type: ComboPort
- value type: str (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
SetAxisValues
Set values for the fields of an axis.
For example, set channel names on a space axis, timestamps on a time axis, feature names on a feature axis, frequencies on a frequency axis. The number of new values must equal the current number of values in the axis (the length of the axis). This node does not shrink or expand the axis to match the number of values. If the axis is an instance axis, array
will by default assumed to be a field in the instance.data array rather than its own array in the instance axis. For example, this can be used to set the Marker
or TargetValue
values for instances (trials), much like the SetInstanceDetails
node. If instance_data_field
is set to False, then array
is assumed to be an array of the instance axis. (This behavior is unique to the instance axis, and the instance_data_field
default will be set to False in a future release.)
Version 2.0.0
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: Packet (can be None)
- data direction: INOUT
-
stream
Name of stream containing the axis to operate on. If empty, the operation will be performed on all streams which contain the specified axis. Note that this does not require an exact match. Any stream with a name beginning with the value specified here will be matched.- verbose name: Stream
- default value: None
- port type: StringPort
- value type: str (can be None)
-
axis
The Axis to modify, by its type. You can more precisely specify the axis to modify, i.e., if the packet might contain multiple axes of the same type, by including the the axis' custom_label using the following format:axis.mylabel
. Otherwise, the first axis of the given type will be modified.- verbose name: Axis
- default value: feature
- port type: ComboPort
- value type: str (can be None)
-
array
The array (field) on the axis that will be set or updated. If unspecified, the default array for the specified axis will be used. This istimes
for a time axis,frequencies
for a frequency axis,names
for a space axis or feature axis.- verbose name: Array
- default value: None
- port type: StringPort
- value type: str (can be None)
-
array_name
- verbose name: Array Name
- default value: None
- port type: AliasPort
- value type: str (can be None)
-
values
New values for the axis array. If a constant, this will be repeated for every element presently in the axis. If a list (can be a list of lists) then it must be the same length as the axis. Note that the axis must continue to match the existing shape of the data tensor (the data tensor is not automatically expanded or contracted to match a new number of elements along an axis).- verbose name: Values
- default value: None
- port type: Port
- value type: object (can be None)
-
axis_occurrence
Index of the occurrence of the axis of desired type. (0
is the first axis of the desired type,1
is the second,-1
is the last,-2
is the second-to-last, and so on). This is no longer recommended; instead specify the axis label (which can be set withSetAxisLabel
if not already existing, in theaxis
property (i.e.,time.my_label
).- verbose name: Axis Occurrence
- default value: 0
- port type: IntPort
- value type: int (can be None)
-
handle_existing
How to handle existing values in the axis array. You may either replace all existing values with the new values, or set a value only for those elements which are missing a value (have an empty string or a NaN), skip the axis altogether if the array contains any non-empty values (values other than an empty string or NaN), or raise an error if the array contains any values (other than an empty string or NaN).- verbose name: Handle Existing Values
- default value: replace-all
- port type: EnumPort
- value type: str (can be None)
-
infer_dummy_values
If set to true, and values is None or empty, the node will attempt to replace the selected target axis array with a set of empty dummy values.- verbose name: Infer Dummy Values
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
only_signals
If set to true, non-signal streams (i.e ., marker streams) will be ignored.- verbose name: Only Signals
- default value: True
- port type: BoolPort
- value type: bool (can be None)
-
instance_data_field
If True and updating an instance axis, the array_name will be assumed to be a field in the instance.d ata array rather than its own array in the instance axis. This is unique to the instance axis and included for backward compatibility purposes. This default will be changed to False in the future.- verbose name: Instance Data Field
- default value: True
- port type: BoolPort
- value type: bool (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
Sort
Sort the data along an axis, either by the data values themselves (default), or by an index field of the chosen axis (e.g
., channel names). When sorting by values and if the data are multi-dimensional, the axis in question will be reset to a generic axis since the sort order will differ for every vector of data along that axis. Otherwise, the axis will be reordered to match the sort order. Note that it is not possible to sort by an axis field if that field is a multi-dimensional array (such as the .positions field of the space axis), since there is no universal way to sort by such a field. Besides the sorted data, this node will also emit a second output port containing the sort order (indices) of the data, which is of the same type as the input data. If the input was a packet, this will be a packet with a chunk for every chunk that had sortable data in it. To sort the data in descending order, use the Reverse node after this one.
Version 1.0.1
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: INOUT
-
order
Sorting order (indices) of the data.- verbose name: Order
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: OUT
-
axis
Axis along which the data will be sorted. You can also specify an axis by its label, as infeature.mylabel
.- verbose name: Axis
- default value: axis
- port type: ComboPort
- value type: str (can be None)
-
sort_by
Sort key to use. If set to value, the entries will be sorted from smallest to largest. If set to axis-index, then the primary index array of the axis, e.g., .times for the time axis, .frequencies for the frequency axis, will be used to sort the data. If set to any other string, it is assumed that the axis contains an array with that name and that will be used to sort the data along that axis.- verbose name: Sort By
- default value: value
- port type: ComboPort
- value type: str (can be None)
-
stream
Name of stream to process. Wildcards are supported, somystream*
will process all streams whose name starts withmystream
.- verbose name: Stream
- default value: None
- port type: StringPort
- value type: str (can be None)
-
stream_name
- verbose name: Stream Name
- default value: None
- port type: AliasPort
- value type: str (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
SqueezeAxes
Strip all axes whose length is 1.
This node can also be used to reduce the number of dimensions in a multi-dimensional array, or list of lists with a regular structure, if the input to this node is an array instead of a Packet. (See also StripSingletonAxis
to remove a single axis with a length of 1 while leaving others.)
Version 1.1.0
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: INOUT
-
verbose
Print a list of the original axes and those remaining.- verbose name: Verbose
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
StripSingletonAxis
Strip the given singleton axis from the data.
This node processes data where the extent along a given is one element. The node will then remove the axis from the data. The node can be used where data has an unnecessary axis of some type after an operation, and it needs to be removed for a successive operation to work as expected. This is often helpful since nodes in NeuroPype may expect a certain number (and types) of axes only. See also SqueezeAxes to strip all singleton axes.
Version 1.0.1
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: Packet (can be None)
- data direction: INOUT
-
axis
Axis to remove. Select the axis type or specify a specific axis that has a label, usingaxis.mylabel
syntax.- verbose name: Axis
- default value: time
- port type: ComboPort
- value type: str (can be None)
-
skip_non_singletons
If True, do not attempt to strip target axis if target axis is present but contains more than 1 element, and pass through output unchanged. If False, the node will raise an error if the target axis has more than 1 element.- verbose name: Skip If Not Singleton
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
TensorDot
Apply a tensor product / contraction between two arrays.
The output will generally have the concatenation of the axes of the two input arrays minus the respective contracted axes. A tensor product is a generalization of various kind of products, depending on the list of axes to contract, including inner product, outer product, matrix multiplication and kronecker product. The most common usage is as a generalized matrix multiplication, where a single axis in both arrays is specified for contraction, which then drops out from both arrays. Conventionally this would be the last axis of the first array and the first axis of the second array, but for packets, the most common use case is to use the same named axis in both arrays, e.g., space for multiplying a spatial filter. An example would be an ICA weights packet that has a space axis (channels) and a feature axis (components) as one operand and a multi-channel time series of space x time as the other operand. The resulting array will then have axes feature x time. This can be accomplished by setting axis1 to space and leaving axis2 set to (same) or, equivalently, setting axis2 also to space. This node avoids potential mistakes in lining up the correct axes with each other when performing plain-array matrix multiplication and automatically ensures that the correct output axis is present. The node also seamlessly supports additional axes in either operand, for example having a time series with an additional instance axis (segmented data) would work as expected in the previous example and yield segmented ICA components. Some other usages are a) leaving the axes empty (contracting no axes) to perform an outer product, which is analogous to the Kronecker product on matrices; the resulting array will have all the axes of both input arrays, and b) specifing (all) as the axis to contract in both arrays, which will perform an inner tensor product, resulting in a scalar output, i.e., a single number. When this node is used with two packets, the output will have all chunks of the first operand, but only the chunks that are also in the second operand will be contracted with the first operand, while the remaining ones are retained as is. When used with one packet and a plain array, the output will have the same chunks as the packet, and every chunk will be contracted with the plain array.
Version 0.9.0
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data1
Data 1 to process.- verbose name: Data1
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: IN
-
data2
Data 2 to process.- verbose name: Data2
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: IN
-
result
Resulting data.- verbose name: Result
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: OUT
-
axis1
Axis to contract (sum out) in the first array. This axis will drop out from the first operand. This can be a named axis (e.g., 'space') or an integer index (0 for the first axis, 1 for second, -1 for the last, etc.). Specifying a single axis amounts to a generalized matrix multiplication where either side may have additional axes that are preserved. It is also possible to list multiple axes as a comma-separated list, for example: time,space (a tensor double contraction). The field can also be left empty to contract no axis (yielding an outer product). Listing all axes, or equivalently, using the special keyword (all) contracts all axes (yielding an inner product / scalar output). Note that, when one (or both) of your operands are plain arrays, it is mandatory to use an integer index for that operand to be explicit.- verbose name: Axis In Data1
- default value: space
- port type: ComboPort
- value type: str (can be None)
-
axis2
Axis to contract (sum out) in the second array. The same conventions apply as for axis1. The special value (same) is a shorthand for entering the same text as in the above field. The axis listed here must have the same length in data2 as the corresponding axis in data1, since the contraction (inner product) is performed along these two axes. If a comma-separated list is given, the axes are "contracted" with each other in the order given.- verbose name: Axis In Data2
- default value: (same)
- port type: ComboPort
- value type: str (can be None)
-
stream
Name of stream to process. Wildcards are supported, somystream*
will process all streams whose name starts withmystream
.- verbose name: Stream
- default value: None
- port type: StringPort
- value type: str (can be None)
-
allow_markers
Allow processing chunks marked as containing markers. This is mainly to prevent accidental manipulation of marker streams in packets.- verbose name: Allow Markers
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
Unique
Reduce data to its unique values along an axis.
When applied along an axis of a multi-dimensional packet, array, or list of lists, the data is treated as a stack of slices along the given axis, and the data is reduced to the unique slices. Note that the order is by default stable, i.e., the order of appearance is preserved, but this can be overridden.
Version 0.8.0
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: INOUT
-
axis
Axis along which to reduce the data. For multi-dimensional data, the effect of this is that the array is treated as a stack of slices along the given axis, and the array is reduced to the unique slices. You can also enter the axis label here as in feature.mylabel. For packet data, this axis will be replaced by a generic axis with a label 'unique'.- verbose name: Axis
- default value: axis
- port type: ComboPort
- value type: str (can be None)
-
order
Order in which to return the unique elements. If set to 'stable', the order of appearance is preserved. If set to 'sorted', the unique elements are sorted (note that for lists of non-numeric data, this mode requires the data to be sortable).- verbose name: Order
- default value: stable
- port type: EnumPort
- value type: str (can be None)
-
stream
Name of stream to process. Wildcards are supported, somystream*
will process all streams whose name starts withmystream
.- verbose name: Stream
- default value: None
- port type: StringPort
- value type: str (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
UpperTriangular
Extract the upper triangular part of a symmetric matrix.
This also works with data that is a multi-way array but which has two dimensions of same length, such that the slices along these two dimensions can be interpreted as matrices. This node allows to specify the axes that constitute the edges of the matrix, and will replace these two axes by a new axis of type feature that has only the upper-triangular elements, vectorized. The new axis will appear at the beginning of the data. A common use case is when one calculates a value between all pairs of channels, but only wants to retain half of the values due to symmetry. In this case, one would specify both axes as space.
Version 1.1.0
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: INOUT
-
axis1
First axis of matrix. This is the first axis type that runs along the matrix from which we want select the upper triangular part. You can also enter the axis label here as inspace.mylabel
. (If the incoming data is an array instead of a Packet, you may specify the axis index here.)- verbose name: Axis1
- default value: space
- port type: ComboPort
- value type: str (can be None)
-
axis2
Second axis of matrix. This is the second axis type that runs along the matrix from which we want select the upper triangular part. You can also enter the axis label here as inspace.mylabel
. (If the incoming data is an array instead of a Packet, you may specify the axis index here.)- verbose name: Axis2
- default value: space
- port type: ComboPort
- value type: str (can be None)
-
use_lower
Use lower triangular matrix instead. If selected, the lower triangular part is taken instead.- verbose name: Use Lower Triangular Instead
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
diagonal_offset
Diagonal offset. Allows to shift the diagonal up (positive values) or down (negative values). 0 is the regular diagonal.- verbose name: Diagonal Offset
- default value: 0
- port type: IntPort
- value type: int (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
VectorCross
Compute the cross product of two (sets of) 3d vectors represented by the given axis in the data.
This node interprets all values along the given axis as a vector, and returns its length. If the data has more axes, e.g., channels, then the vector length is taken separately for each channel/etc of these axes. If the data is an array and no numeric axis was specified, the axis defaults to -1 (i.e., the last axis of the data).
Version 1.0.0
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data1
Operand 1 process.- verbose name: Data1
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: IN
-
data2
Operand 2 process.- verbose name: Data2
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: IN
-
result
Resulting data.- verbose name: Result
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: OUT
-
axis
Axis along which to take the cross product. This axis will drop out of the data and be replaced by a dummy one-element axis (of type feature).- verbose name: Act Along Axis
- default value: space
- port type: ComboPort
- value type: str (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
axis_pairing
How to pair axes of the two operands. In 'positional' mode, axes are paired by their position according to a right alignment, that is, the last axis of the first operand is paired with the last axis of the second operand, and so on, while any missing axes behave as if they were unnamed axes of length 1 (this is the same way plain n-dimensional arrays pair in Python/numpy). In 'matched' mode, axes are paired by their type and optionally label, where the axis order of the first operand is preserved in the output, optionally with additional axes that only occur in the second operand prepended on the left. The other operand then has its axes reordered to match. All axis classes are treated as distinct, except for the plain axis, which is treated as a wildcard axis that can pair with any other axis. The 'default' value resolves to a value that may be overridden in special contexts (mainly the ambient Inference node) and otherwise resolves to the setting of the configuration variable default_axis_pairing, which is set to 'positional' in 2024.x. See also the 'label_handling' property for how labels are treated in this mode. Note that axis pairing can be subtle, and it is recommended to not blindly trust that the default behavior is always what the user intended.- verbose name: Axis Pairing
- default value: default
- port type: EnumPort
- value type: str (can be None)
-
label_pairing
How to treat axis labels when pairing axes in 'matched' mode. In 'always' mode, labels are always considered significant, and axes with different labels are always considered distinct, which means that, if the two operands each have an axis of same type but with different labels, each operand will have a singleton axis inserted to pair with the respective axis in the other operand. In 'ignore' mode, labels are entirely ignored when pairing axes; this means that, if multiple axes of the same type occur in one or more operands, the last space axis in the first operand is paired with the last space axis in the second operand, etc. as in positional mode. In 'auto' mode, labels are only considered significant if they are necessary for distinguishing two or more axes of the same type in any of the operands, or if they occur on a plain axis.- verbose name: Label Pairing
- default value: auto
- port type: EnumPort
- value type: str (can be None)
-
lists_as_arrays
Whether to treat lists as numeric arrays, as opposed to a recursive data structure. This is equivalent to converting any list operand(s) to arrays before passing them to the node. Broadly, enabling this allows for more efficient processing of large lists of either numbers, or lists of many smaller arrays, with some limitations and caveats, as follows. If one operand was a list and the other an array, an array will be returned, and if all were lists, a list will be returned (if the operand lists themselves contained arrays, the result is still a "pure" list of potentially nested lists of numbers). A limitation is that input lists may contain ONLY numbers or arrays of the same shape (e..g., no lists of blocks or packets, dictionaries, or irregular array shapes in this mode). In contrast, when the option is disabled, then if one operand is a list and the other is not a list (e.g., a number, array, block, packet, etc), then each element of the list is separately undergoing the operation while the other operand is held fixed. This has the consequence that a) the result will generally be a list if at least one operand is a list and b) the result will be mathematically different when one is a list and the other is an array, because the array will be separately combined with each list element. Note the default for this option was enabled by default in NeuroPype 2023. The option can also be set globally or in a context using the WithOptions node, for example for pipeline-wide backwards compatibility.- verbose name: Lists As Arrays
- default value: False
- port type: BoolPort
- value type: bool (can be None)
VectorDot
Compute the dot product (inner product) of two (sets of) vectors represented by the given axis in the data.
This node interprets all values along the given axis as a vector, and returns its length. If the data has more axes, e.g., channels, then the vector length is taken separately for each channel/etc of these axes. The chosen axis will be replaced by a one-element feature axis, unless drop_axis is set. If the data is an array and no numeric axis was specified, the axis defaults to -1 (i.e., the last axis of the data).
Version 1.0.0
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data1
Operand 1 process.- verbose name: Data1
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: IN
-
data2
Operand 2 process.- verbose name: Data2
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: IN
-
result
Resulting data.- verbose name: Result
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: OUT
-
axis
Axis along which to take the cross product. This axis will drop out of the data and be replaced by a dummy one-element axis (of type feature).- verbose name: Act Along Axis
- default value: space
- port type: ComboPort
- value type: str (can be None)
-
drop_axis
Drop the axis from the data.- verbose name: Drop Axis
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
axis_pairing
How to pair axes of the two operands. In 'positional' mode, axes are paired by their position according to a right alignment, that is, the last axis of the first operand is paired with the last axis of the second operand, and so on, while any missing axes behave as if they were unnamed axes of length 1 (this is the same way plain n-dimensional arrays pair in Python/numpy). In 'matched' mode, axes are paired by their type and optionally label, where the axis order of the first operand is preserved in the output, optionally with additional axes that only occur in the second operand prepended on the left. The other operand then has its axes reordered to match. All axis classes are treated as distinct, except for the plain axis, which is treated as a wildcard axis that can pair with any other axis. The 'default' value resolves to a value that may be overridden in special contexts (mainly the ambient Inference node) and otherwise resolves to the setting of the configuration variable default_axis_pairing, which is set to 'positional' in 2024.x. See also the 'label_handling' property for how labels are treated in this mode. Note that axis pairing can be subtle, and it is recommended to not blindly trust that the default behavior is always what the user intended.- verbose name: Axis Pairing
- default value: default
- port type: EnumPort
- value type: str (can be None)
-
label_pairing
How to treat axis labels when pairing axes in 'matched' mode. In 'always' mode, labels are always considered significant, and axes with different labels are always considered distinct, which means that, if the two operands each have an axis of same type but with different labels, each operand will have a singleton axis inserted to pair with the respective axis in the other operand. In 'ignore' mode, labels are entirely ignored when pairing axes; this means that, if multiple axes of the same type occur in one or more operands, the last space axis in the first operand is paired with the last space axis in the second operand, etc. as in positional mode. In 'auto' mode, labels are only considered significant if they are necessary for distinguishing two or more axes of the same type in any of the operands, or if they occur on a plain axis.- verbose name: Label Pairing
- default value: auto
- port type: EnumPort
- value type: str (can be None)
-
lists_as_arrays
Whether to treat lists as numeric arrays, as opposed to a recursive data structure. This is equivalent to converting any list operand(s) to arrays before passing them to the node. Broadly, enabling this allows for more efficient processing of large lists of either numbers, or lists of many smaller arrays, with some limitations and caveats, as follows. If one operand was a list and the other an array, an array will be returned, and if all were lists, a list will be returned (if the operand lists themselves contained arrays, the result is still a "pure" list of potentially nested lists of numbers). A limitation is that input lists may contain ONLY numbers or arrays of the same shape (e..g., no lists of blocks or packets, dictionaries, or irregular array shapes in this mode). In contrast, when the option is disabled, then if one operand is a list and the other is not a list (e.g., a number, array, block, packet, etc), then each element of the list is separately undergoing the operation while the other operand is held fixed. This has the consequence that a) the result will generally be a list if at least one operand is a list and b) the result will be mathematically different when one is a list and the other is an array, because the array will be separately combined with each list element. Note the default for this option was enabled by default in NeuroPype 2023. The option can also be set globally or in a context using the WithOptions node, for example for pipeline-wide backwards compatibility.- verbose name: Lists As Arrays
- default value: False
- port type: BoolPort
- value type: bool (can be None)
VectorNorm
Compute a norm of the vectors represented by the given axis.
This node interprets all values along the given axis as a vector, and returns its norm. If the data has more axes, e.g., channels, then the vector length is taken separately for each channel/etc of these axes. The chosen axis will be replaced by a one-element feature axis, unless drop_axis is set. If the data is an array and no numeric axis was specified, the axis defaults to -1 (i.e., the last axis of the data).
Version 1.0.0
Ports/Properties
-
metadata
User-definable meta-data associated with the node. Usually reserved for technical purposes.- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)
-
data
Data to process.- verbose name: Data
- default value: None
- port type: DataPort
- value type: AnyNumeric (can be None)
- data direction: INOUT
-
axis
Axis along which to take the statistic. This axis will drop out of the data and be replaced by a dummy one-element axis (of type feature). You may specify an axis with its label (i.e.,space.mylabel
) or in the case of incoming data that is an array instead of a Packet, the index of the axis.- verbose name: Act Along Axis
- default value: space
- port type: ComboPort
- value type: str (can be None)
-
ord
Order of the norm. The default is 2, which corresponds to the Euclidean norm or vector length. Other values are 1 (l1 norm aka Manhattan distance), 0 (number of nonzeros), inf (maximum value), and fractional p-norms for p >= 1.- verbose name: Order Of Norm
- default value: 2
- port type: FloatPort
- value type: float (can be None)
-
drop_axis
Drop the axis from the data.- verbose name: Drop Axis
- default value: False
- port type: BoolPort
- value type: bool (can be None)
-
set_breakpoint
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)