From ee4c4249a74fa8eb2b01f4fb7b8a870893aa628b Mon Sep 17 00:00:00 2001 From: liadomide Date: Wed, 29 Apr 2020 22:05:45 +0300 Subject: [PATCH 1/8] TVB-2680 Explicit imports to avoid conflict or naming with attr --- scientific_library/tvb/datatypes/graph.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scientific_library/tvb/datatypes/graph.py b/scientific_library/tvb/datatypes/graph.py index 8b178a6588..89b485e8a9 100644 --- a/scientific_library/tvb/datatypes/graph.py +++ b/scientific_library/tvb/datatypes/graph.py @@ -38,7 +38,8 @@ """ import numpy from tvb.basic.neotraits.api import HasTraits, Attr, NArray, List, narray_summary_info -from tvb.datatypes import time_series, connectivity +from tvb.datatypes.connectivity import Connectivity +from tvb.datatypes.time_series import TimeSeries class Covariance(HasTraits): @@ -47,7 +48,7 @@ class Covariance(HasTraits): array_data = NArray(dtype=numpy.complex128) source = Attr( - field_type=time_series.TimeSeries, + field_type=TimeSeries, label="Source time-series", doc="Links to the time-series on which NodeCovariance is applied.") @@ -70,7 +71,7 @@ class CorrelationCoefficients(HasTraits): array_data = NArray() source = Attr( - field_type=time_series.TimeSeries, + field_type=TimeSeries, label="Source time-series", doc="Links to the time-series on which Correlation (coefficients) is applied.") @@ -95,7 +96,7 @@ class ConnectivityMeasure(HasTraits): array_data = NArray() - connectivity = Attr(field_type=connectivity.Connectivity) + connectivity = Attr(field_type=Connectivity) def summary_info(self): summary = {"Graph type": self.__class__.__name__} From d3b14d191f6747b43fc568b83b5866bd1526df45 Mon Sep 17 00:00:00 2001 From: liadomide Date: Wed, 29 Apr 2020 22:07:19 +0300 Subject: [PATCH 2/8] TVB-2680 Fix filter on data_1 and data_2 inputs in Topographic Viewer --- framework_tvb/tvb/adapters/visualizers/topographic.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/framework_tvb/tvb/adapters/visualizers/topographic.py b/framework_tvb/tvb/adapters/visualizers/topographic.py index f978edc9d1..f9ecfb98cc 100644 --- a/framework_tvb/tvb/adapters/visualizers/topographic.py +++ b/framework_tvb/tvb/adapters/visualizers/topographic.py @@ -197,11 +197,9 @@ def __init__(self, prefix='', project_id=None): self.data_0 = TraitDataTypeSelectField(TopographicViewerModel.data_0, self, name='data_0', conditions=self.get_filters()) self.data_1 = TraitDataTypeSelectField(TopographicViewerModel.data_1, self, name='data_1', - conditions=FilterChain(fields=[FilterChain.datatype + '._nr_dimensions'], - operations=["=="], values=[1])) + conditions=self.get_filters()) self.data_2 = TraitDataTypeSelectField(TopographicViewerModel.data_2, self, name='data_2', - conditions=FilterChain(fields=[FilterChain.datatype + '._nr_dimensions'], - operations=["=="], values=[1])) + conditions=self.get_filters()) @staticmethod def get_view_model(): From e60302ab1fa4103b633be8918cf3d7ea5772248d Mon Sep 17 00:00:00 2001 From: liadomide Date: Wed, 29 Apr 2020 22:11:02 +0300 Subject: [PATCH 3/8] TVB-2680 Review *Index(DataTypeMatrix) by moving common columns into the base class --- .../tvb/adapters/datatypes/db/fcd.py | 7 +--- .../tvb/adapters/datatypes/db/graph.py | 32 +------------------ .../adapters/datatypes/db/region_mapping.py | 5 --- .../tvb/adapters/datatypes/db/structural.py | 10 ++---- .../tvb/core/entities/model/model_datatype.py | 20 ++++++++++-- 5 files changed, 21 insertions(+), 53 deletions(-) diff --git a/framework_tvb/tvb/adapters/datatypes/db/fcd.py b/framework_tvb/tvb/adapters/datatypes/db/fcd.py index 5249e92ebf..8a30038163 100644 --- a/framework_tvb/tvb/adapters/datatypes/db/fcd.py +++ b/framework_tvb/tvb/adapters/datatypes/db/fcd.py @@ -28,20 +28,16 @@ # # import json -from sqlalchemy import Column, Integer, ForeignKey, String, Float +from sqlalchemy import Column, Integer, ForeignKey, String from sqlalchemy.orm import relationship from tvb.datatypes.fcd import Fcd from tvb.adapters.datatypes.db.time_series import TimeSeriesIndex from tvb.core.entities.model.model_datatype import DataTypeMatrix -from tvb.core.neotraits.db import from_ndarray class FcdIndex(DataTypeMatrix): id = Column(Integer, ForeignKey(DataTypeMatrix.id), primary_key=True) - array_data_min = Column(Float) - array_data_max = Column(Float) - array_data_mean = Column(Float) fk_source_gid = Column(String(32), ForeignKey(TimeSeriesIndex.gid), nullable=not Fcd.source.required) source = relationship(TimeSeriesIndex, foreign_keys=fk_source_gid, primaryjoin=TimeSeriesIndex.gid == fk_source_gid) @@ -50,6 +46,5 @@ class FcdIndex(DataTypeMatrix): def fill_from_has_traits(self, datatype): # type: (Fcd) -> None super(FcdIndex, self).fill_from_has_traits(datatype) - self.array_data_min, self.array_data_max, self.array_data_mean = from_ndarray(datatype.array_data) self.labels_ordering = json.dumps(datatype.labels_ordering) self.fk_source_gid = datatype.source.gid.hex diff --git a/framework_tvb/tvb/adapters/datatypes/db/graph.py b/framework_tvb/tvb/adapters/datatypes/db/graph.py index f8163e42c6..1cd7576f77 100644 --- a/framework_tvb/tvb/adapters/datatypes/db/graph.py +++ b/framework_tvb/tvb/adapters/datatypes/db/graph.py @@ -28,81 +28,51 @@ # # -import json -from sqlalchemy import Column, Integer, ForeignKey, String, Float +from sqlalchemy import Column, Integer, ForeignKey, String from sqlalchemy.orm import relationship from tvb.datatypes.graph import Covariance, CorrelationCoefficients, ConnectivityMeasure from tvb.adapters.datatypes.db.connectivity import ConnectivityIndex from tvb.adapters.datatypes.db.time_series import TimeSeriesIndex from tvb.core.entities.model.model_datatype import DataTypeMatrix -from tvb.core.neotraits.db import from_ndarray class CovarianceIndex(DataTypeMatrix): id = Column(Integer, ForeignKey(DataTypeMatrix.id), primary_key=True) - array_data_min = Column(Float) - array_data_max = Column(Float) - array_data_mean = Column(Float) - fk_source_gid = Column(String(32), ForeignKey(TimeSeriesIndex.gid), nullable=not Covariance.source.required) source = relationship(TimeSeriesIndex, foreign_keys=fk_source_gid, primaryjoin=TimeSeriesIndex.gid == fk_source_gid) - subtype = Column(String) - def fill_from_has_traits(self, datatype): # type: (Covariance) -> None super(CovarianceIndex, self).fill_from_has_traits(datatype) - self.subtype = datatype.__class__.__name__ - self.array_data_min, self.array_data_max, self.array_data_mean = from_ndarray(datatype.array_data) self.fk_source_gid = datatype.source.gid.hex class CorrelationCoefficientsIndex(DataTypeMatrix): id = Column(Integer, ForeignKey(DataTypeMatrix.id), primary_key=True) - array_data_min = Column(Float) - array_data_max = Column(Float) - array_data_mean = Column(Float) - fk_source_gid = Column(String(32), ForeignKey(TimeSeriesIndex.gid), nullable=not CorrelationCoefficients.source.required) source = relationship(TimeSeriesIndex, foreign_keys=fk_source_gid, primaryjoin=TimeSeriesIndex.gid == fk_source_gid) - subtype = Column(String) - labels_ordering = Column(String) def fill_from_has_traits(self, datatype): # type: (CorrelationCoefficients) -> None super(CorrelationCoefficientsIndex, self).fill_from_has_traits(datatype) - self.subtype = datatype.__class__.__name__ self.labels_ordering = datatype.labels_ordering - self.array_data_min, self.array_data_max, self.array_data_mean = from_ndarray(datatype.array_data) self.fk_source_gid = datatype.source.gid.hex class ConnectivityMeasureIndex(DataTypeMatrix): id = Column(Integer, ForeignKey(DataTypeMatrix.id), primary_key=True) - subtype = Column(String) - fk_connectivity_gid = Column(String(32), ForeignKey(ConnectivityIndex.gid), nullable=ConnectivityMeasure.connectivity.required) connectivity = relationship(ConnectivityIndex, foreign_keys=fk_connectivity_gid, primaryjoin=ConnectivityIndex.gid == fk_connectivity_gid) - array_data_min = Column(Float) - array_data_max = Column(Float) - array_data_mean = Column(Float) - - shape = Column(String, nullable=False) - def fill_from_has_traits(self, datatype): # type: (ConnectivityMeasure) -> None super(ConnectivityMeasureIndex, self).fill_from_has_traits(datatype) - self.subtype = datatype.__class__.__name__ - self.array_data_min, self.array_data_max, self.array_data_mean = from_ndarray(datatype.array_data) self.fk_connectivity_gid = datatype.connectivity.gid.hex - self.shape = json.dumps(datatype.array_data.shape) - self.ndim = len(datatype.array_data.shape) diff --git a/framework_tvb/tvb/adapters/datatypes/db/region_mapping.py b/framework_tvb/tvb/adapters/datatypes/db/region_mapping.py index 8fb3b40249..9c6978ce3a 100644 --- a/framework_tvb/tvb/adapters/datatypes/db/region_mapping.py +++ b/framework_tvb/tvb/adapters/datatypes/db/region_mapping.py @@ -64,10 +64,6 @@ def fill_from_has_traits(self, datatype): class RegionVolumeMappingIndex(DataTypeMatrix): id = Column(Integer, ForeignKey(DataTypeMatrix.id), primary_key=True) - array_data_min = Column(Float) - array_data_max = Column(Float) - array_data_mean = Column(Float) - fk_connectivity_gid = Column(String(32), ForeignKey(ConnectivityIndex.gid), nullable=not RegionVolumeMapping.connectivity.required) connectivity = relationship(ConnectivityIndex, foreign_keys=fk_connectivity_gid, @@ -80,6 +76,5 @@ class RegionVolumeMappingIndex(DataTypeMatrix): def fill_from_has_traits(self, datatype): # type: (RegionVolumeMapping) -> None super(RegionVolumeMappingIndex, self).fill_from_has_traits(datatype) - self.array_data_min, self.array_data_max, self.array_data_mean = from_ndarray(datatype.array_data) self.fk_connectivity_gid = datatype.connectivity.gid.hex self.fk_volume_gid = datatype.volume.gid.hex diff --git a/framework_tvb/tvb/adapters/datatypes/db/structural.py b/framework_tvb/tvb/adapters/datatypes/db/structural.py index 528fcc533b..5876d06005 100644 --- a/framework_tvb/tvb/adapters/datatypes/db/structural.py +++ b/framework_tvb/tvb/adapters/datatypes/db/structural.py @@ -27,21 +27,16 @@ # Frontiers in Neuroinformatics (7:10. doi: 10.3389/fninf.2013.00010) # # -from sqlalchemy import Column, Integer, ForeignKey, String, Float +from sqlalchemy import Column, Integer, ForeignKey, String from sqlalchemy.orm import relationship from tvb.datatypes.structural import StructuralMRI from tvb.adapters.datatypes.db.volume import VolumeIndex from tvb.core.entities.model.model_datatype import DataTypeMatrix -from tvb.core.neotraits.db import from_ndarray class StructuralMRIIndex(DataTypeMatrix): id = Column(Integer, ForeignKey(DataTypeMatrix.id), primary_key=True) - array_data_min = Column(Float) - array_data_max = Column(Float) - array_data_mean = Column(Float) - weighting = Column(String, nullable=False) fk_volume_gid = Column(String(32), ForeignKey(VolumeIndex.gid), nullable=not StructuralMRI.volume.required) @@ -51,5 +46,4 @@ def fill_from_has_traits(self, datatype): # type: (StructuralMRI) -> None super(StructuralMRIIndex, self).fill_from_has_traits(datatype) self.weighting = datatype.weighting - self.array_data_min, self.array_data_max, self.array_data_mean = from_ndarray(datatype.array_data) - self.fk_volume_gid = datatype.volume.gid.hex \ No newline at end of file + self.fk_volume_gid = datatype.volume.gid.hex diff --git a/framework_tvb/tvb/core/entities/model/model_datatype.py b/framework_tvb/tvb/core/entities/model/model_datatype.py index 77be3c85b8..19ef4ffe70 100644 --- a/framework_tvb/tvb/core/entities/model/model_datatype.py +++ b/framework_tvb/tvb/core/entities/model/model_datatype.py @@ -35,13 +35,14 @@ .. moduleauthor:: Bogdan Neacsa .. moduleauthor:: Yann Gordon """ +import json from datetime import datetime from copy import copy from sqlalchemy.orm import relationship, backref from sqlalchemy import Boolean, Integer, String, Float, Column, ForeignKey from tvb.basic.neotraits.api import HasTraits from tvb.core.entities.generic_attributes import GenericAttributes -from tvb.core.neotraits.db import HasTraitsIndex, Base +from tvb.core.neotraits.db import HasTraitsIndex, Base, from_ndarray from tvb.core.entities.model.model_project import Project from tvb.core.entities.model.model_operation import Operation, OperationGroup from tvb.core.entities.model.model_burst import BurstConfiguration @@ -201,10 +202,23 @@ def fill_from_generic_attributes(self, attrs): class DataTypeMatrix(DataType): - # These columns will need to be populates in fill_from_has_traits for each subclass - # because we do not have a HasTraits inherited class equivalent at this level id = Column(Integer, ForeignKey(DataType.id), primary_key=True) + subtype = Column(String, nullable=True) + ndim = Column(Integer, default=0) + shape = Column(String, nullable=True) + array_data_min = Column(Float) + array_data_max = Column(Float) + array_data_mean = Column(Float) + + def fill_from_has_traits(self, datatype): + super(DataTypeMatrix, self).fill_from_has_traits(datatype) + self.subtype = datatype.__class__.__name__ + + if hasattr(datatype, "array_data"): + self.array_data_min, self.array_data_max, self.array_data_mean = from_ndarray(datatype.array_data) + self.shape = json.dumps(datatype.array_data.shape) + self.ndim = len(datatype.array_data.shape) class DataTypeGroup(DataType): From e9494fbd8741ed1e48352edf3d813bdc67b75172 Mon Sep 17 00:00:00 2001 From: liadomide Date: Wed, 29 Apr 2020 22:40:15 +0300 Subject: [PATCH 4/8] TVB-2680 Review methods ABCAdapter.load_** to accept both UUID or str for gid params --- framework_tvb/tvb/core/adapters/abcadapter.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/framework_tvb/tvb/core/adapters/abcadapter.py b/framework_tvb/tvb/core/adapters/abcadapter.py index f24d86e984..121df1ee2c 100644 --- a/framework_tvb/tvb/core/adapters/abcadapter.py +++ b/framework_tvb/tvb/core/adapters/abcadapter.py @@ -41,6 +41,7 @@ import psutil import numpy import importlib +import typing from functools import wraps from datetime import datetime from abc import ABCMeta, abstractmethod @@ -463,17 +464,17 @@ def load_entity_by_gid(data_gid): @staticmethod def load_traited_by_gid(data_gid): - # type: (uuid.UUID) -> HasTraits + # type: (typing.Union[uuid.UUID, str]) -> HasTraits """ Load a generic HasTraits instance, specified by GID. """ - index = load_entity_by_gid(data_gid.hex) + index = ABCAdapter.load_entity_by_gid(data_gid.hex) return h5.load_from_index(index) @staticmethod def load_with_references(dt_gid): - # type: (uuid.UUID) -> HasTraits - dt_index = load_entity_by_gid(dt_gid) + # type: (typing.Union[uuid.UUID, str]) -> HasTraits + dt_index = ABCAdapter.load_entity_by_gid(dt_gid) h5_path = h5.path_for_stored_index(dt_index) dt, _ = h5.load_with_references(h5_path) return dt From 2a0e351a9badf12219c222bbfd813554be2d8a1d Mon Sep 17 00:00:00 2001 From: liadomide Date: Wed, 29 Apr 2020 22:45:21 +0300 Subject: [PATCH 5/8] TVB-2680 Make sure all attributes in ConnectivityMeasureH5 are correctly stored on the disk. Adjust code in HistogramViewer.prepare_parameters to match the ViewModel syntax --- .../tvb/adapters/datatypes/h5/graph_h5.py | 10 ++++++++++ .../tvb/adapters/visualizers/histogram.py | 15 ++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/framework_tvb/tvb/adapters/datatypes/h5/graph_h5.py b/framework_tvb/tvb/adapters/datatypes/h5/graph_h5.py index c1025c134e..34bd38dade 100644 --- a/framework_tvb/tvb/adapters/datatypes/h5/graph_h5.py +++ b/framework_tvb/tvb/adapters/datatypes/h5/graph_h5.py @@ -70,3 +70,13 @@ def __init__(self, path): def get_array_data(self): return self.array_data[:] + + def store(self, datatype, scalars_only=False, store_references=True): + # type: (ConnectivityMeasure, bool, bool) -> None + super(ConnectivityMeasureH5, self).store(datatype, scalars_only, store_references) + self.title.store(datatype.title) + + def load_into(self, datatype): + # type: (ConnectivityMeasure) -> None + super(ConnectivityMeasureH5, self).load_into(datatype) + datatype.title = self.title.load() \ No newline at end of file diff --git a/framework_tvb/tvb/adapters/visualizers/histogram.py b/framework_tvb/tvb/adapters/visualizers/histogram.py index fc21c2cbcf..3dc9d24efb 100644 --- a/framework_tvb/tvb/adapters/visualizers/histogram.py +++ b/framework_tvb/tvb/adapters/visualizers/histogram.py @@ -81,12 +81,11 @@ class HistogramViewer(ABCDisplayer): """ The viewer takes as input a result DataType as computed by BCT analyzers. """ - _ui_name = "Connectivity Measure Visualizer" + _ui_name = "Histogram Visualizer" def get_form_class(self): return HistogramViewerForm - # TODO: migrate to neotraits def launch(self, view_model): # type: (HistogramViewerModel) -> dict """ @@ -103,7 +102,7 @@ def get_required_memory_size(self, view_model): """ Return the required memory to run this algorithm. """ - input_data = self.load_entity_by_gid(view_model.input_data.hex) + input_data = self.load_entity_by_gid(view_model.input_data) return numpy.prod(input_data.shape) * 2 def generate_preview(self, view_model, figure_size=None): @@ -113,16 +112,18 @@ def generate_preview(self, view_model, figure_size=None): params = self.prepare_parameters(view_model.input_data) return self.build_display_result("histogram/view", params) - def prepare_parameters(self, input_data): + def prepare_parameters(self, connectivity_measure_gid): """ Prepare all required parameters for a launch. """ - labels_list = input_data.connectivity.region_labels.tolist() - values_list = input_data.array_data.tolist() + conn_measure = self.load_with_references(connectivity_measure_gid) + assert isinstance(conn_measure, ConnectivityMeasure) + labels_list = conn_measure.connectivity.region_labels.tolist() + values_list = conn_measure.array_data.tolist() # A gradient of colors will be used for each node colors_list = values_list - params = dict(title="Connectivity Measure - " + input_data.title, labels=json.dumps(labels_list), + params = dict(title="Connectivity Measure - " + conn_measure.title, labels=json.dumps(labels_list), data=json.dumps(values_list), colors=json.dumps(colors_list), xposition='center' if min(values_list) < 0 else 'bottom', minColor=min(colors_list), maxColor=max(colors_list)) From 91e850cf79e16279ec547f6f1d5bb51cb28e53cb Mon Sep 17 00:00:00 2001 From: liadomide Date: Wed, 29 Apr 2020 22:47:29 +0300 Subject: [PATCH 6/8] TVB-2680 Review signature of overwritten method H5File.store --- .../tvb/adapters/datatypes/h5/connectivity_h5.py | 2 +- framework_tvb/tvb/adapters/datatypes/h5/patterns_h5.py | 8 ++++---- framework_tvb/tvb/adapters/datatypes/h5/sensors_h5.py | 2 +- .../tvb/tests/framework/datatypes/dummy_datatype_h5.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/framework_tvb/tvb/adapters/datatypes/h5/connectivity_h5.py b/framework_tvb/tvb/adapters/datatypes/h5/connectivity_h5.py index 7a0178018a..aefca114ae 100644 --- a/framework_tvb/tvb/adapters/datatypes/h5/connectivity_h5.py +++ b/framework_tvb/tvb/adapters/datatypes/h5/connectivity_h5.py @@ -56,7 +56,7 @@ def get_centres(self): def get_region_labels(self): return self.region_labels.load() - def store(self, datatype, scalars_only=False, store_references=False): + def store(self, datatype, scalars_only=False, store_references=True): # type: (Connectivity, bool, bool) -> None super(ConnectivityH5, self).store(datatype, scalars_only, store_references) self.region_labels.store(datatype.region_labels.astype(STORE_STRING)) diff --git a/framework_tvb/tvb/adapters/datatypes/h5/patterns_h5.py b/framework_tvb/tvb/adapters/datatypes/h5/patterns_h5.py index 264dcb68f9..6781a823ea 100644 --- a/framework_tvb/tvb/adapters/datatypes/h5/patterns_h5.py +++ b/framework_tvb/tvb/adapters/datatypes/h5/patterns_h5.py @@ -41,8 +41,8 @@ def __init__(self, path): self.connectivity = Reference(StimuliRegion.connectivity, self) self.weight = DataSet(StimuliRegion.weight, self) - def store(self, datatype, scalars_only=False): - super(StimuliRegionH5, self).store(datatype, scalars_only) + def store(self, datatype, scalars_only=False, store_references=True): + super(StimuliRegionH5, self).store(datatype, scalars_only, store_references) self.connectivity.store(datatype.connectivity) @@ -56,7 +56,7 @@ def __init__(self, path): self.focal_points_surface = DataSet(NArray(dtype=int), self, name='focal_points_surface') self.focal_points_triangles = DataSet(StimuliSurface.focal_points_triangles, self) - def store(self, datatype, scalars_only=False): - super(StimuliSurfaceH5, self).store(datatype, scalars_only) + def store(self, datatype, scalars_only=False, store_references=True): + super(StimuliSurfaceH5, self).store(datatype, scalars_only, store_references) self.focal_points_surface.store(datatype.focal_points_surface) diff --git a/framework_tvb/tvb/adapters/datatypes/h5/sensors_h5.py b/framework_tvb/tvb/adapters/datatypes/h5/sensors_h5.py index 75358c8f55..cd8ac2140a 100644 --- a/framework_tvb/tvb/adapters/datatypes/h5/sensors_h5.py +++ b/framework_tvb/tvb/adapters/datatypes/h5/sensors_h5.py @@ -49,7 +49,7 @@ def get_locations(self): def get_labels(self): return self.labels.load() - def store(self, datatype, scalars_only=False, store_references=False): + def store(self, datatype, scalars_only=False, store_references=True): # type: (Sensors, bool, bool) -> None super(SensorsH5, self).store(datatype, scalars_only, store_references) self.labels.store(datatype.labels.astype(STORE_STRING)) diff --git a/framework_tvb/tvb/tests/framework/datatypes/dummy_datatype_h5.py b/framework_tvb/tvb/tests/framework/datatypes/dummy_datatype_h5.py index 4b1c37a8a4..326ecb64cb 100644 --- a/framework_tvb/tvb/tests/framework/datatypes/dummy_datatype_h5.py +++ b/framework_tvb/tvb/tests/framework/datatypes/dummy_datatype_h5.py @@ -38,7 +38,7 @@ def __init__(self, path): self.row1 = Scalar(DummyDataType.row1, self) self.row2 = Scalar(DummyDataType.row2, self) - def store(self, datatype, scalars_only=False, store_references=False): + def store(self, datatype, scalars_only=False, store_references=True): # type: (DummyDataType, bool, bool) -> None super(DummyDataTypeH5, self).store(datatype, scalars_only, store_references) From b3d7de952eb368e7b43002eadb8f341cf280a329 Mon Sep 17 00:00:00 2001 From: Lia Domide Date: Thu, 30 Apr 2020 11:26:38 +0300 Subject: [PATCH 7/8] Update abcadapter.py --- framework_tvb/tvb/core/adapters/abcadapter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework_tvb/tvb/core/adapters/abcadapter.py b/framework_tvb/tvb/core/adapters/abcadapter.py index 121df1ee2c..8f1e31db77 100644 --- a/framework_tvb/tvb/core/adapters/abcadapter.py +++ b/framework_tvb/tvb/core/adapters/abcadapter.py @@ -468,7 +468,7 @@ def load_traited_by_gid(data_gid): """ Load a generic HasTraits instance, specified by GID. """ - index = ABCAdapter.load_entity_by_gid(data_gid.hex) + index = ABCAdapter.load_entity_by_gid(data_gid) return h5.load_from_index(index) @staticmethod From b7548283bb19304ddc87986a8f79876e91da5e7d Mon Sep 17 00:00:00 2001 From: popaula937 Date: Thu, 30 Apr 2020 14:04:00 +0300 Subject: [PATCH 8/8] TVB-2680. Monitors can use the default store() method. Sync store() signature from BurstConfigurationH5 with base. --- .../file/simulator/burst_configuration_h5.py | 2 +- .../entities/file/simulator/monitor_h5.py | 23 ------------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/framework_tvb/tvb/core/entities/file/simulator/burst_configuration_h5.py b/framework_tvb/tvb/core/entities/file/simulator/burst_configuration_h5.py index 8e5fdbab16..861eccfde9 100644 --- a/framework_tvb/tvb/core/entities/file/simulator/burst_configuration_h5.py +++ b/framework_tvb/tvb/core/entities/file/simulator/burst_configuration_h5.py @@ -47,7 +47,7 @@ def __init__(self, path): self.range1 = Scalar(Attr(str, required=False), self, name='range1') self.range2 = Scalar(Attr(str, required=False), self, name='range2') - def store(self, burst_config, scalars_only=False, store_references=False): + def store(self, burst_config, scalars_only=False, store_references=True): self.name.store(burst_config.name) self.status.store(burst_config.status) self.error_message.store(burst_config.error_message or 'None') diff --git a/framework_tvb/tvb/core/entities/file/simulator/monitor_h5.py b/framework_tvb/tvb/core/entities/file/simulator/monitor_h5.py index 78d644191f..595da4e6ff 100644 --- a/framework_tvb/tvb/core/entities/file/simulator/monitor_h5.py +++ b/framework_tvb/tvb/core/entities/file/simulator/monitor_h5.py @@ -76,11 +76,6 @@ def __init__(self, path): self.region_mapping = Reference(Projection.region_mapping, self) self.obnoise = Reference(Projection.obsnoise, self) - def store(self, datatype, scalars_only=False, store_references=False): - # type: (Projection, bool, bool) -> None - super(ProjectionH5, self).store(datatype, scalars_only, store_references) - self.region_mapping.store(datatype.region_mapping.gid) - class EEGH5(ProjectionH5): @@ -91,12 +86,6 @@ def __init__(self, path): self.reference = Scalar(EEG.reference, self) self.sigma = Scalar(EEG.sigma, self) - def store(self, datatype, scalars_only=False, store_references=False): - # type: (Projection, bool, bool) -> None - super(EEGH5, self).store(datatype, scalars_only, store_references) - self.projection.store(datatype.projection.gid) - self.sensors.store(datatype.sensors.gid) - class MEGH5(ProjectionH5): @@ -105,12 +94,6 @@ def __init__(self, path): self.projection = Reference(MEG.projection, self) self.sensors = Reference(MEG.sensors, self) - def store(self, datatype, scalars_only=False, store_references=False): - # type: (Projection, bool, bool) -> None - super(MEGH5, self).store(datatype, scalars_only, store_references) - self.projection.store(datatype.projection.gid) - self.sensors.store(datatype.sensors.gid) - class iEEGH5(ProjectionH5): @@ -120,12 +103,6 @@ def __init__(self, path): self.sensors = Reference(iEEG.sensors, self) self.sigma = Scalar(iEEG.sigma, self) - def store(self, datatype, scalars_only=False, store_references=False): - # type: (Projection, bool, bool) -> None - super(iEEGH5, self).store(datatype, scalars_only, store_references) - self.projection.store(datatype.projection.gid) - self.sensors.store(datatype.sensors.gid) - class BoldH5(MonitorH5):