diff --git a/framework_tvb/tvb/adapters/datatypes/db/mapped_value.py b/framework_tvb/tvb/adapters/datatypes/db/mapped_value.py index 3fbc1d38e21dcc2dc7fa526b67bae2dc7bc9f942..cec2fc29ca1ef58218a1a1107758a783d09249d9 100644 --- a/framework_tvb/tvb/adapters/datatypes/db/mapped_value.py +++ b/framework_tvb/tvb/adapters/datatypes/db/mapped_value.py @@ -33,10 +33,12 @@ """ import json -from sqlalchemy.orm import relationship + from sqlalchemy import Column, String, Integer, ForeignKey +from sqlalchemy.orm import relationship from tvb.adapters.datatypes.db.time_series import TimeSeriesIndex from tvb.adapters.datatypes.h5.mapped_value_h5 import ValueWrapper +from tvb.core.entities.file.simulator.datatype_measure_h5 import DatatypeMeasure from tvb.core.entities.model.model_datatype import DataType @@ -85,3 +87,9 @@ class DatatypeMeasureIndex(DataType): result = result + " -- " + entry + ' : ' + str(metric_value) return result + + def fill_from_has_traits(self, datatype): + # type: (DatatypeMeasure) -> None + super(DatatypeMeasureIndex, self).fill_from_has_traits(datatype) + self.metrics = json.dumps(datatype.metrics) + self.fk_source_gid = datatype.analyzed_datatype.gid.hex diff --git a/framework_tvb/tvb/config/init/datatypes_registry.py b/framework_tvb/tvb/config/init/datatypes_registry.py index d98c5d4442b998e657430061fcee145a60d76d9f..b6568260160e8658123939f9f16fed4ac9e2e3f9 100644 --- a/framework_tvb/tvb/config/init/datatypes_registry.py +++ b/framework_tvb/tvb/config/init/datatypes_registry.py @@ -53,7 +53,7 @@ from tvb.adapters.datatypes.h5.fcd_h5 import FcdH5 from tvb.adapters.datatypes.h5.graph_h5 import ConnectivityMeasureH5, CorrelationCoefficientsH5, CovarianceH5 from tvb.adapters.datatypes.h5.local_connectivity_h5 import LocalConnectivityH5 from tvb.adapters.datatypes.h5.mapped_value_h5 import ValueWrapperH5, ValueWrapper -from tvb.core.entities.file.simulator.datatype_measure_h5 import DatatypeMeasureH5 +from tvb.core.entities.file.simulator.datatype_measure_h5 import DatatypeMeasureH5, DatatypeMeasure from tvb.adapters.datatypes.h5.mode_decompositions_h5 import PrincipalComponentsH5, IndependentComponentsH5 from tvb.adapters.datatypes.h5.patterns_h5 import StimuliRegionH5, StimuliSurfaceH5 from tvb.adapters.datatypes.h5.projections_h5 import ProjectionMatrixH5 @@ -132,6 +132,6 @@ def populate_datatypes_registry(): REGISTRY.register_datatype(SpatioTemporalPattern, None, SpatioTemporalPatternIndex) REGISTRY.register_datatype(StimuliRegion, StimuliRegionH5, StimuliRegionIndex) REGISTRY.register_datatype(StimuliSurface, StimuliSurfaceH5, StimuliSurfaceIndex) - REGISTRY.register_datatype(None, DatatypeMeasureH5, DatatypeMeasureIndex) + REGISTRY.register_datatype(DatatypeMeasure, DatatypeMeasureH5, DatatypeMeasureIndex) REGISTRY.register_datatype(ConnectivityAnnotations, ConnectivityAnnotationsH5, ConnectivityAnnotationsIndex) REGISTRY.register_datatype(ValueWrapper, ValueWrapperH5, ValueWrapperIndex) diff --git a/framework_tvb/tvb/core/entities/file/simulator/datatype_measure_h5.py b/framework_tvb/tvb/core/entities/file/simulator/datatype_measure_h5.py index 5512029e47e890cc6e70d61eb19134a59c039610..23c93281affa27ccc5cf66a17094526217e871d9 100644 --- a/framework_tvb/tvb/core/entities/file/simulator/datatype_measure_h5.py +++ b/framework_tvb/tvb/core/entities/file/simulator/datatype_measure_h5.py @@ -28,11 +28,21 @@ # # -from tvb.basic.neotraits.api import Attr +from tvb.basic.neotraits.api import HasTraits, Attr from tvb.core.neotraits.h5 import Json, Reference, H5File from tvb.datatypes.time_series import TimeSeries +class DatatypeMeasure(HasTraits): + metrics = Attr(dict) + + analyzed_datatype = Attr( + field_type=TimeSeries, + label="TimeSeries", + doc="""Links to the time-series on which the metrics are computed.""" + ) + + class DatatypeMeasureH5(H5File): def __init__(self, path):