The Virtual Brain Project

Table Of Contents

Previous topic

config Package

Next topic

logger Package

This Page

filters Package

chain

The following are the categories that will be available for filters in the UI. In case of adding a new category, the first input ‘model.DataType.subject’ is the field from the model that will be used , display represents the way this field will be visible in the UI to the user, operations mark all the possible operations that can be done on that field (so far supported are: “==”, ”!=”, “<”, “>”, “in”, “not in”). Type represents the type of input that is expected. So far string, date and list are supported.

In order to define a default filter, from the adapter interface add:

'conditions': FilterChain(fields= [FilterChain.datatype + ".subject", FilterChain.datatype + ".some_attribute",
                          values= [["John Doe", "JohnDoe1"], "Some Attr Value"], operations= ["in", "=="])

If you want to add a filter to a XML interface:

<input required="True">
    <name value="data1"/>
    <label value="First dataset:"/>
    <description value="First set of signals"/>
    <type value="tvb.datatypes.arrays.MappedArray" field="data" default="default_data">
        <conditions>
            <cond_fields value_list="['datatype_class._nr_dimensions']"/>
            <cond_operations value_list="['==']"/>
            <cond_values value_list="['2']"/>
        </conditions>
    </type>
</input>
class tvb.basic.filters.chain.FilterChain(display_name='', fields=None, values=None, operations=None, operator_between_fields='and')[source]

Bases: object

Class used to filter tables displayed in UI, based on few criteria. Initialize filter with a list of fields, and corresponding values.

add_condition(field_name, operation_string, value)[source]

Append to the list of conditions.

algorithm = '$$ALGORITHM_INPUT$$'
algorithm_category = '$$ALGORITHM_CATEGORY_INPUT$$'
algorithm_category_replacement = 'model.AlgorithmCategory'
algorithm_replacement = 'model.Algorithm'
datatype = '$$DATATYPE_INPUT$$'
datatype_replacement = 'model.DataType'
classmethod from_json(input_dict)[source]

From a JSON dictionary create a filter instance.

classmethod get_filters_for_type(data_name)[source]

Return the list of filters to appear in UI.

get_python_filter_equivalent(datatype_to_check=None, algorithm_to_check=None, algocategory_to_check=None, operation_to_check=None)[source]

Python evaluate of the filter against a current given DataType Check a filter instance next to a given input.

Parameters:datatype_to_check – the dataType to be checked against this filter instance
Returns:true if input passed false if input failed
get_sql_filter_equivalent(datatype_to_check='model.DataType', operation_to_check='model.Operation', algorithm_to_check='model.Algorithm', algocategory_to_check='model.AlgorithmCategory')[source]

Returns the computed SQL string from the given filter. The method may return None if the filter is None or the fields of the filter are not set.

The input to this method should be a string representing the name under which the variable you want to be filtered was binded in the callers namespace. e.g.

def foo(var_to_filter, filter_entity):
filter_entity.get_sql_filter_equivalent(‘var_to_filter’)
operation = '$$OPERATION_INPUT$$'
operation_replacement = 'model.Operation'
to_json()[source]

Return a dictionary representation of the filter, to be used when needed.

class tvb.basic.filters.chain.UIFilter(linked_elem_name, linked_elem_field, linked_elem_parent_name=None, linked_elem_parent_option=None)[source]

Helper class for the UI filters.

to_dict()[source]

Prepare for passing in UI

exceptions

exception tvb.basic.filters.exceptions.InvalidFilterChainInput(message)[source]

Bases: tvb.basic.traits.exceptions.TVBException

Exception raised if a input that does not match the declared filter is passed as input.

exception tvb.basic.filters.exceptions.InvalidFilterEntity(message)[source]

Bases: tvb.basic.traits.exceptions.TVBException

Exception raised if a filter entity has contradicting values for operations and values. for example: in None, not in 1