From 134d9a02ad205adadeaf25be4e9a61855ba86b94 Mon Sep 17 00:00:00 2001 From: "Robert.Vincze" Date: Thu, 21 Jan 2021 17:06:52 +0200 Subject: [PATCH] TVB-2757: Add filter on RM only inside the Surface Viewer (not the RM viewer as well) + add filtering of Connectivity Measures based on currently selected RM --- .../tvb/adapters/visualizers/surface_view.py | 16 ++++++++++------ .../adapters/visualizers/time_series_volume.py | 2 +- .../web/controllers/flow_controller.py | 10 ++++++++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/framework_tvb/tvb/adapters/visualizers/surface_view.py b/framework_tvb/tvb/adapters/visualizers/surface_view.py index f9be6168a7..aab808f095 100644 --- a/framework_tvb/tvb/adapters/visualizers/surface_view.py +++ b/framework_tvb/tvb/adapters/visualizers/surface_view.py @@ -158,17 +158,17 @@ class BaseSurfaceViewerForm(ABCAdapterForm): def __init__(self): super(BaseSurfaceViewerForm, self).__init__() - rm_runtime_condition = FilterChain(fields=[FilterChain.datatype + '.fk_surface_gid'], operations=["=="], - values=[FilterChain.DEFAULT_RUNTIME_VALUE]) - self.region_map = TraitDataTypeSelectField(BaseSurfaceViewerModel.region_map, name='region_map', - runtime_conditions=('surface', rm_runtime_condition)) + 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') @@ -189,6 +189,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 d2c803c2bf..13723bc7ad 100644 --- a/framework_tvb/tvb/adapters/visualizers/time_series_volume.py +++ b/framework_tvb/tvb/adapters/visualizers/time_series_volume.py @@ -77,7 +77,7 @@ def __init__(self): conditions=self.get_filters()) volume_index_filter = FilterChain(fields=[FilterChain.datatype + '.voxel_size'], operations=["=="], - values=['fk_volume_gid']) + values=['fk_volume_gid']) self.background = TraitDataTypeSelectField(TimeSeriesVolumeVisualiserModel.background, name='background', runtime_conditions=('time_series', volume_index_filter)) diff --git a/framework_tvb/tvb/interfaces/web/controllers/flow_controller.py b/framework_tvb/tvb/interfaces/web/controllers/flow_controller.py index b468567dce..997b05fc6d 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}