Skip to content

← formatting package

BatchInstances

Group and batch instances based on some some criterion along a new feature axis.

The data will be concatenated and padded along that axis. This can be used in cases where you want to group trials (represented as instances in Neuropype) by certain criteria in the instance.data field (typically Marker, but could be any other attribute). You specify the instance.data field holding the criteria (such as 'Marker'), and a feature axis will be created for each unique value found in that field, and the instances (trials) will be stacked along the corresponding axis based on their value (for example, all trials with marker "A" would go in one axis, all trials with marker "B" in another), etc. This allows you to segregate trials into batches for comparative analysis. (Note that if all you want is the mean of trials matching each criteria, instead of the individual trials themselves, you can used the GroupedMean node.) Version 0.5.1

Ports/Properties

data

Data to process.

  • verbose name: Data
  • default value: None
  • port type: DataPort
  • value type: Packet (can be None)
  • data direction: INOUT

group_by

Group instances that have the same value or combination of values for the given instance field(s). If given, then the grouped instances will be batched along a new axis.

  • verbose name: Stack By Field(S)
  • default value: []
  • port type: ListPort
  • value type: list (can be None)

verify_unique

Ensure that the given fields (if any), are unique within each group. If this is not the case, an error will be thrown.

  • verbose name: Verify Unique Values In Field(S)
  • default value: []
  • port type: ListPort
  • value type: list (can be None)

pad_maxitems

Optional max # of items for padding. If this is None, it amounts to the max items in any of the groups. If < 1, then it is taken as a quantile of the item counts (e.g., 0.9 would be 90th percentile). If given as an integer >= 1, it is taken as the max # of items.

  • verbose name: Pad Maxitems
  • default value: None
  • port type: FloatPort
  • value type: float (can be None)

pad_value

Value to use for padding. This value will be inserted to fill up groups that have less than the max # of items. Can be set to NaN or Inf.

  • verbose name: Pad Value
  • default value: 0.0
  • port type: Port
  • value type: object (can be None)

handle_overlength

How to handle groups that have more items than pad_maxitems. In the truncate-group modes, the excess items are removed from the group, either at the beginning (-pre variant), or at the end (-post variant). In the drop-group mode, the entire group is dropped from the data set.

  • verbose name: Handle Overlength
  • default value: truncate-group-pre
  • port type: EnumPort
  • value type: str (can be None)

new_axis

New axis type to insert to index the groups. A new axis of this type will be inserted. You can also specify a desired new label for the axis in here by writing feature.mylabel.

  • verbose name: New Axis To Insert
  • default value: feature
  • port type: ComboPort
  • value type: str (can be None)

sort_order

If alphabetical (default), instance axis elements are returned in alphabetical order, otherwise they are returned in order of first appearance.

  • verbose name: Sort Order
  • default value: alphabetical
  • 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)

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)