diff --git a/framework_tvb/tvb/adapters/visualizers/annotations_viewer.py b/framework_tvb/tvb/adapters/visualizers/annotations_viewer.py index 38de2c4392..682beb0476 100644 --- a/framework_tvb/tvb/adapters/visualizers/annotations_viewer.py +++ b/framework_tvb/tvb/adapters/visualizers/annotations_viewer.py @@ -75,13 +75,13 @@ class ConnectivityAnnotationsViewForm(ABCAdapterForm): def __init__(self): super(ConnectivityAnnotationsViewForm, self).__init__() # Used for filtering - annotations_index_filter = FilterChain(fields=[FilterChain.datatype + '.number_of_regions'], operations=["=="], - values=['fk_connectivity_gid']) + connectivity_index_filter = FilterChain(fields=[FilterChain.datatype + '.number_of_regions'], operations=["=="], + values=['fk_connectivity_gid']) self.connectivity_index = TraitDataTypeSelectField(ConnectivityAnnotationsViewModel.connectivity_index, 'connectivity_index', runtime_conditions=('annotations_index', - annotations_index_filter)) + connectivity_index_filter)) self.annotations_index = TraitDataTypeSelectField(ConnectivityAnnotationsViewModel.annotations_index, 'annotations_index', conditions=self.get_filters()) diff --git a/framework_tvb/tvb/adapters/visualizers/surface_view.py b/framework_tvb/tvb/adapters/visualizers/surface_view.py index 640eda8122..1da22ec20e 100644 --- a/framework_tvb/tvb/adapters/visualizers/surface_view.py +++ b/framework_tvb/tvb/adapters/visualizers/surface_view.py @@ -159,12 +159,18 @@ class BaseSurfaceViewerForm(ABCAdapterForm): def __init__(self): super(BaseSurfaceViewerForm, self).__init__() + self.region_map = TraitDataTypeSelectField(BaseSurfaceViewerModel.region_map, name='region_map') + conn_filter = FilterChain( fields=[FilterChain.datatype + '.ndim', FilterChain.datatype + '.has_surface_mapping'], - operations=["==", "=="], values=[1, True]) + operations=["==", "=="], values=[1, "1"]) + cm_runtime_filter = FilterChain(fields=[FilterChain.datatype + '.gid'], operations=["=="], + values=['fk_connectivity_gid:fk_connectivity_gid']) self.connectivity_measure = TraitDataTypeSelectField(BaseSurfaceViewerModel.connectivity_measure, - name='connectivity_measure', conditions=conn_filter) + name='connectivity_measure', conditions=conn_filter, + runtime_conditions=('region_map', cm_runtime_filter)) + self.shell_surface = TraitDataTypeSelectField(BaseSurfaceViewerModel.shell_surface, name='shell_surface') @staticmethod @@ -184,6 +190,10 @@ class SurfaceViewerModel(BaseSurfaceViewerModel): class SurfaceViewerForm(BaseSurfaceViewerForm): def __init__(self): super(SurfaceViewerForm, self).__init__() + rm_runtime_condition = FilterChain(fields=[FilterChain.datatype + '.fk_surface_gid'], operations=["=="], + values=[FilterChain.DEFAULT_RUNTIME_VALUE]) + self.region_map.runtime_conditions = ('surface', rm_runtime_condition) + self.surface = TraitDataTypeSelectField(SurfaceViewerModel.surface, name='surface') @staticmethod diff --git a/framework_tvb/tvb/adapters/visualizers/time_series_volume.py b/framework_tvb/tvb/adapters/visualizers/time_series_volume.py index dec8124928..e3785acfd2 100644 --- a/framework_tvb/tvb/adapters/visualizers/time_series_volume.py +++ b/framework_tvb/tvb/adapters/visualizers/time_series_volume.py @@ -76,7 +76,11 @@ def __init__(self): super(TimeSeriesVolumeVisualiserForm, self).__init__() self.time_series = TraitDataTypeSelectField(TimeSeriesVolumeVisualiserModel.time_series, name='time_series', conditions=self.get_filters()) - self.background = TraitDataTypeSelectField(TimeSeriesVolumeVisualiserModel.background, name='background') + + volume_index_filter = FilterChain(fields=[FilterChain.datatype + '.voxel_size'], operations=["=="], + values=['fk_volume_gid']) + self.background = TraitDataTypeSelectField(TimeSeriesVolumeVisualiserModel.background, name='background', + runtime_conditions=('time_series', volume_index_filter)) @staticmethod def get_view_model(): diff --git a/framework_tvb/tvb/interfaces/web/controllers/flow_controller.py b/framework_tvb/tvb/interfaces/web/controllers/flow_controller.py index 17ace651b4..eb096cb714 100644 --- a/framework_tvb/tvb/interfaces/web/controllers/flow_controller.py +++ b/framework_tvb/tvb/interfaces/web/controllers/flow_controller.py @@ -256,11 +256,16 @@ def _fill_reversed_filter_value(runtime_filters, i): datatype_index = dao.get_datatype_by_gid(runtime_filters['runtime_reverse_filtering_values'][i]) if datatype_index: linked_datatype_field = runtime_filters['runtime_values'][i] - linked_datatype_gid = getattr(datatype_index, linked_datatype_field) + split_linked_datatype_field = linked_datatype_field.split(':') + linked_datatype_gid = getattr(datatype_index, split_linked_datatype_field[0]) linked_datatype_index = dao.get_datatype_by_gid(linked_datatype_gid) filter_field = runtime_filters['runtime_fields'][i].replace(FilterChain.datatype + '.', '') + filter_value = getattr(linked_datatype_index, filter_field) runtime_filters['runtime_values'][i] = filter_value + runtime_filters['runtime_fields'][i] = FilterChain.datatype + '.' + (split_linked_datatype_field[1] if + len(split_linked_datatype_field) > 1 + else filter_field) @expose_fragment('form_fields/options_field') @settings @@ -327,7 +332,7 @@ def get_runtime_filtered_form(self, algorithm_id, default_filters, user_filters, values=user_filters['user_values']) runtime_filters = runtime_filter_dict[key] runtime_filter_values_copy = runtime_filters['runtime_values'].copy() - + runtime_filter_fields_copy = runtime_filters['runtime_fields'].copy() for i in range(len(runtime_filters['runtime_fields'])): if (len(runtime_filters['runtime_reverse_filtering_values'][i])) > 0: self._fill_reversed_filter_value(runtime_filters, i) @@ -345,6 +350,7 @@ def get_runtime_filtered_form(self, algorithm_id, default_filters, user_filters, if select_field_attr.runtime_conditions: select_field_attr.runtime_conditions[1].values = runtime_filter_values_copy + select_field_attr.runtime_conditions[1].fields = runtime_filter_fields_copy return {'adapter_form': form} diff --git a/framework_tvb/tvb/interfaces/web/static/js/filters.js b/framework_tvb/tvb/interfaces/web/static/js/filters.js index 60d2e8c2ec..be85759036 100644 --- a/framework_tvb/tvb/interfaces/web/static/js/filters.js +++ b/framework_tvb/tvb/interfaces/web/static/js/filters.js @@ -103,11 +103,7 @@ function _FIL_gatherData(divId, uiValue){ if (children[i].className.endsWith('runtime_trigger')) { let value_from_field = $('#' + children[i].className.replace('_runtime_trigger', '')).val(); if(value === "default_runtime_value"){ - if (!uiValue) { - value = value_from_field; - } else { - value = uiValue; - } + value = value_from_field; runtime_reverse_filtering_values.push(''); }else{ runtime_reverse_filtering_values.push(value_from_field); @@ -192,7 +188,7 @@ function applyUserFilters(datatypeIndex, divId, name, gatheredData) { }); } -function applyRuntimeFilters(name, selected_value, dynamic_filters){ +function applyRuntimeFilters(name, selected_value){ if($('.' + name + '_runtime_trigger').length === 0){ return; @@ -241,7 +237,8 @@ function applyRuntimeFilters(name, selected_value, dynamic_filters){ for(var key in fields_and_user_filters){ const divId = key + 'data_select'; for(var i=0; i {{ ght.generate_help_tooltip(field) }}