filternode properties

Filter node iconThe Filter node filters (discards) fields, renames fields, and maps fields from one import node to another.

Example

node = stream.create("filter", "My node")
node.setPropertyValue("default_include", True)
node.setKeyedPropertyValue("new_name", "Drug", "Chemical")
node.setKeyedPropertyValue("include", "Drug", False)

Using the default_include property. Note that setting the value of the default_include property doesn't automatically include or exclude all fields; it simply determines the default for the current selection. This is functionally equivalent to selecting the Include All Fields option in the Filter node properties. For example, suppose you run the following script:

node = modeler.script.stream().create("filter", "Filter")
node.setPropertyValue("default_include", False)
# Include these two fields in the list
for f in ["Age", "Sex"]:
    node.setKeyedPropertyValue("include", f, True)

This will cause the node to pass the fields Age and Sex and discard all others. Now suppose you run the same script again but name two different fields:

node = modeler.script.stream().create("filter", "Filter")
node.setPropertyValue("default_include", False)
# Include these two fields in the list
for f in ["BP", "Na"]:
    node.setKeyedPropertyValue("include", f, True)

This will add two more fields to the filter so that a total of four fields are passed (Age, Sex, BP, Na). In other words, resetting the value of default_include to False doesn't automatically reset all fields.

Alternatively, if you now change default_include to True, either using a script or in the Filter node dialog box, this would flip the behavior so the four fields listed above would be discarded rather than included. When in doubt, experimenting with the controls in the Filter node properties may be helpful in understanding this interaction.

Table 1. filternode properties
filternode properties Data type Property description
default_include flag Keyed property to specify whether the default behavior is to pass or filter fields: Note that setting this property doesn't automatically include or exclude all fields; it simply determines whether selected fields are included or excluded by default.
include flag Keyed property for field inclusion and removal.
new_name string