Skip to content

Commit

Permalink
TVB-2757: Add filter on RM only inside the Surface Viewer (not the RM…
Browse files Browse the repository at this point in the history
… viewer as well) + add filtering of Connectivity Measures based on currently selected RM
  • Loading branch information
VinczeRobert committed Jan 21, 2021
1 parent 6027002 commit 134d9a0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
16 changes: 10 additions & 6 deletions framework_tvb/tvb/adapters/visualizers/surface_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
10 changes: 8 additions & 2 deletions framework_tvb/tvb/interfaces/web/controllers/flow_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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}

Expand Down

0 comments on commit 134d9a0

Please sign in to comment.