filternode properties

The Filter node filters (discards) fields, renames fields, and maps fields from one source 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 does not automatically include or exclude all fields; it simply determines the default for the current selection. This is functionally equivalent to clicking the Include fields by default button in the Filter node dialog box. 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. After running the previous script, now suppose you add the following lines to the script to name two more fields:

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 dialog box 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 does not automatically include or exclude all fields; it simply determines whether selected fields are included or excluded by default. See example below for additional comments.
include flag Keyed property for field inclusion and removal.
new_name string