Commit 926b4624 authored by liadomide's avatar liadomide

TVB-2598 Use self.log (from ABCAdapter parent) instead of defining static LOG

parent e45b2c36
......@@ -42,7 +42,6 @@ import numpy
from scipy.signal.signaltools import correlate
from tvb.basic.neotraits.api import HasTraits, Attr, Float
from tvb.basic.neotraits.info import narray_describe
from tvb.basic.logger.builder import get_logger
from tvb.core.adapters.abcadapter import ABCAsynchronous, ABCAdapterForm
from tvb.core.adapters.exceptions import LaunchException
from tvb.adapters.datatypes.h5.graph_h5 import CorrelationCoefficientsH5
......@@ -59,8 +58,6 @@ from tvb.datatypes.time_series import TimeSeries
from tvb.datatypes.temporal_correlations import CrossCorrelation
from tvb.datatypes.graph import CorrelationCoefficients
LOG = get_logger(__name__)
class CrossCorrelate(HasTraits):
"""
......@@ -86,7 +83,8 @@ class CrossCorrelateAdapterForm(ABCAdapterForm):
def __init__(self, prefix='', project_id=None):
super(CrossCorrelateAdapterForm, self).__init__(prefix, project_id)
self.time_series = TraitDataTypeSelectField(CrossCorrelateAdapterModel.time_series, self, name=self.get_input_name(),
self.time_series = TraitDataTypeSelectField(CrossCorrelateAdapterModel.time_series, self,
name=self.get_input_name(),
conditions=self.get_filters(), has_all_option=True)
@staticmethod
......@@ -209,7 +207,7 @@ class CrossCorrelateAdapter(ABCAsynchronous):
"""
# (tpts, nodes, nodes, state-variables, modes)
result_shape = self._result_shape(small_ts.data.shape)
LOG.info("result shape will be: %s" % str(result_shape))
self.log.info("result shape will be: %s" % str(result_shape))
result = numpy.zeros(result_shape)
......@@ -225,8 +223,8 @@ class CrossCorrelateAdapter(ABCAsynchronous):
for n2 in range(result_shape[2]):
result[:, n1, n2, var, mode] = correlate(data[:, n1], data[:, n2], mode="same")
LOG.debug("result")
LOG.debug(narray_describe(result))
self.log.debug("result")
self.log.debug(narray_describe(result))
offset = (small_ts.sample_period *
numpy.arange(-numpy.floor(result_shape[0] / 2.0), numpy.ceil(result_shape[0] / 2.0)))
......@@ -422,7 +420,7 @@ class PearsonCorrelationCoefficientAdapter(ABCAsynchronous):
# (nodes, nodes, state-variables, modes)
input_shape = ts_h5.data.shape
result_shape = self._result_shape(input_shape)
LOG.info("result shape will be: %s" % str(result_shape))
self.log.info("result shape will be: %s" % str(result_shape))
result = numpy.zeros(result_shape)
......@@ -441,8 +439,8 @@ class PearsonCorrelationCoefficientAdapter(ABCAsynchronous):
data = ts_h5.data[current_slice].squeeze()
result[:, :, var, mode] = numpy.corrcoef(data.T)
LOG.debug("result")
LOG.debug(narray_describe(result))
self.log.debug("result")
self.log.debug(narray_describe(result))
return result
......
......@@ -43,7 +43,6 @@ from scipy import linalg
from scipy.spatial.distance import pdist
from sklearn.cluster import DBSCAN
from sklearn.manifold import SpectralEmbedding
from tvb.basic.logger.builder import get_logger
from tvb.basic.neotraits.api import HasTraits, Attr, Float
from tvb.basic.neotraits.info import narray_describe
from tvb.core.adapters.abcadapter import ABCAsynchronous, ABCAdapterForm
......@@ -61,8 +60,6 @@ from tvb.datatypes.fcd import Fcd
from tvb.datatypes.graph import ConnectivityMeasure
from tvb.datatypes.time_series import TimeSeriesRegion
LOG = get_logger(__name__)
class FcdCalculator(HasTraits):
"""
......@@ -190,7 +187,7 @@ class FunctionalConnectivityDynamicsAdapter(ABCAsynchronous):
self.input_time_series_index.data_length_2d,
self.input_time_series_index.data_length_3d,
self.input_time_series_index.data_length_4d)
LOG.debug("time_series shape is %s" % str(self.input_shape))
self.log.debug("time_series shape is %s" % str(self.input_shape))
self.actual_sp = float(view_model.sp) / self.input_time_series_index.sample_period
self.actual_sw = float(view_model.sw) / self.input_time_series_index.sample_period
actual_ts_length = self.input_shape[0]
......@@ -292,8 +289,8 @@ class FunctionalConnectivityDynamicsAdapter(ABCAsynchronous):
return result
def _compute_fcd_matrix(self, ts_h5):
LOG.debug("timeseries_h5.data")
LOG.debug(narray_describe(ts_h5.data[:]))
self.log.debug("timeseries_h5.data")
self.log.debug(narray_describe(ts_h5.data[:]))
input_shape = ts_h5.data.shape
result_shape = self._result_shape(input_shape)
......@@ -321,8 +318,8 @@ class FunctionalConnectivityDynamicsAdapter(ABCAsynchronous):
fcd[j, i, var, mode] = fcd[i, j, var, mode]
j += 1
LOG.debug("FCD")
LOG.debug(narray_describe(fcd))
self.log.debug("FCD")
self.log.debug(narray_describe(fcd))
num_eig = 3 # number of the eigenvector that will be extracted
......
......@@ -43,15 +43,12 @@ from tvb.core.neotraits.view_model import ViewModel, DataTypeGidAttr
from tvb.datatypes.time_series import TimeSeries
from tvb.core.adapters.abcadapter import ABCAsynchronous, ABCAdapterForm
from tvb.core.entities.filters.chain import FilterChain
from tvb.basic.logger.builder import get_logger
from tvb.adapters.datatypes.h5.time_series_h5 import TimeSeriesRegionH5
from tvb.adapters.datatypes.db.time_series import TimeSeriesIndex, TimeSeriesRegionIndex
from tvb.core.neotraits.forms import ScalarField, TraitDataTypeSelectField
from tvb.core.neotraits.db import prepare_array_shape_meta
from tvb.core.neocom import h5
LOG = get_logger(__name__)
class BalloonModelAdapterModel(ViewModel):
time_series = DataTypeGidAttr(
......@@ -103,7 +100,8 @@ class BalloonModelAdapterForm(ABCAdapterForm):
def __init__(self, prefix='', project_id=None):
super(BalloonModelAdapterForm, self).__init__(prefix, project_id)
self.time_series = TraitDataTypeSelectField(BalloonModelAdapterModel.time_series, self, name=self.get_input_name(),
self.time_series = TraitDataTypeSelectField(BalloonModelAdapterModel.time_series, self,
name=self.get_input_name(),
conditions=self.get_filters(), has_all_option=True)
self.dt = ScalarField(BalloonModelAdapterModel.dt, self)
self.neural_input_transformation = ScalarField(BalloonModelAdapterModel.neural_input_transformation, self)
......@@ -157,7 +155,7 @@ class BalloonModelAdapter(ABCAsynchronous):
self.input_time_series_index.data_length_3d,
self.input_time_series_index.data_length_4d)
LOG.debug("time_series shape is %s" % str(self.input_shape))
self.log.debug("time_series shape is %s" % str(self.input_shape))
# -------------------- Fill Algorithm for Analysis -------------------##
algorithm = BalloonModel()
......
......@@ -42,15 +42,12 @@ from tvb.core.adapters.abcadapter import ABCAsynchronous, ABCAdapterForm
from tvb.core.neotraits.view_model import ViewModel, DataTypeGidAttr
from tvb.datatypes.time_series import TimeSeries
from tvb.core.entities.filters.chain import FilterChain
from tvb.basic.logger.builder import get_logger
from tvb.adapters.datatypes.h5.mode_decompositions_h5 import IndependentComponentsH5
from tvb.adapters.datatypes.db.mode_decompositions import IndependentComponentsIndex
from tvb.adapters.datatypes.db.time_series import TimeSeriesIndex
from tvb.core.neotraits.forms import ScalarField, TraitDataTypeSelectField
from tvb.core.neocom import h5
LOG = get_logger(__name__)
class ICAAdapterModel(ViewModel, FastICA):
time_series = DataTypeGidAttr(
......@@ -114,8 +111,8 @@ class ICAAdapter(ABCAsynchronous):
self.input_time_series_index.data_length_2d,
self.input_time_series_index.data_length_3d,
self.input_time_series_index.data_length_4d)
LOG.debug("Time series shape is %s" % str(self.input_shape))
LOG.debug("Provided number of components is %s" % view_model.n_components)
self.log.debug("Time series shape is %s" % str(self.input_shape))
self.log.debug("Provided number of components is %s" % view_model.n_components)
# -------------------- Fill Algorithm for Analysis -------------------##
algorithm = FastICA()
......
......@@ -43,7 +43,6 @@ import numpy
import json
from collections import OrderedDict
from tvb.analyzers.metrics_base import BaseTimeseriesMetricAlgorithm
from tvb.basic.logger.builder import get_logger
from tvb.basic.neotraits._attr import List
from tvb.core.adapters.abcadapter import ABCAsynchronous, ABCAdapterForm
from tvb.adapters.datatypes.h5.mapped_value_h5 import DatatypeMeasureH5
......@@ -60,7 +59,6 @@ import tvb.analyzers.metric_variance_of_node_variance
from tvb.core.neotraits.view_model import ViewModel, DataTypeGidAttr
from tvb.datatypes.time_series import TimeSeries
LOG = get_logger(__name__)
ALGORITHMS = BaseTimeseriesMetricAlgorithm.get_known_subclasses(include_itself=False)
algo_names = list(ALGORITHMS)
......@@ -174,7 +172,7 @@ class TimeseriesMetricsAdapter(ABCAsynchronous):
if algorithms is None:
algorithms = list(ALGORITHMS)
LOG.debug("time_series shape is %s" % str(self.input_shape))
self.log.debug("time_series shape is %s" % str(self.input_shape))
dt_timeseries = h5.load_from_index(self.input_time_series_index)
metrics_results = {}
......@@ -190,11 +188,11 @@ class TimeseriesMetricsAdapter(ABCAsynchronous):
algorithm_filter = TimeseriesMetricsAdapterForm.get_extra_algorithm_filters().get(algorithm_name)
if algorithm_filter is not None \
and not algorithm_filter.get_python_filter_equivalent(self.input_time_series_index):
LOG.warning('Measure algorithm will not be computed because of incompatibility on input. '
'Filters failed on algo: ' + str(algorithm_name))
self.log.warning('Measure algorithm will not be computed because of incompatibility on input. '
'Filters failed on algo: ' + str(algorithm_name))
continue
else:
LOG.debug("Applying measure: " + str(algorithm_name))
self.log.debug("Applying measure: " + str(algorithm_name))
unstored_result = algorithm.evaluate()
# ----------------- Prepare a Float object(s) for result ----------------##
......
......@@ -42,15 +42,12 @@ from tvb.core.adapters.abcadapter import ABCAsynchronous, ABCAdapterForm
from tvb.core.neotraits.view_model import ViewModel, DataTypeGidAttr
from tvb.datatypes.time_series import TimeSeries
from tvb.core.entities.filters.chain import FilterChain
from tvb.basic.logger.builder import get_logger
from tvb.adapters.datatypes.h5.spectral_h5 import CoherenceSpectrumH5
from tvb.adapters.datatypes.db.spectral import CoherenceSpectrumIndex
from tvb.adapters.datatypes.db.time_series import TimeSeriesIndex
from tvb.core.neotraits.forms import ScalarField, TraitDataTypeSelectField
from tvb.core.neocom import h5
LOG = get_logger(__name__)
class NodeCoherenceModel(ViewModel, NodeCoherence):
time_series = DataTypeGidAttr(
......@@ -113,7 +110,7 @@ class NodeCoherenceAdapter(ABCAsynchronous):
self.input_time_series_index.data_length_2d,
self.input_time_series_index.data_length_3d,
self.input_time_series_index.data_length_4d)
LOG.debug("Time series shape is %s" % str(self.input_shape))
self.log.debug("Time series shape is %s" % str(self.input_shape))
# -------------------- Fill Algorithm for Analysis -------------------##
self.algorithm = NodeCoherence()
if view_model.nfft is not None:
......
......@@ -42,18 +42,14 @@ from tvb.core.adapters.abcadapter import ABCAsynchronous, ABCAdapterForm
from tvb.core.neotraits.view_model import ViewModel, DataTypeGidAttr
from tvb.datatypes.time_series import TimeSeries
from tvb.core.entities.filters.chain import FilterChain
from tvb.basic.logger.builder import get_logger
from tvb.adapters.datatypes.h5.spectral_h5 import ComplexCoherenceSpectrumH5
from tvb.adapters.datatypes.db.spectral import ComplexCoherenceSpectrumIndex
from tvb.adapters.datatypes.db.time_series import TimeSeriesIndex
from tvb.core.neotraits.forms import TraitDataTypeSelectField
from tvb.core.neocom import h5
LOG = get_logger(__name__)
class NodeComplexCoherenceModel(ViewModel, NodeComplexCoherence):
time_series = DataTypeGidAttr(
linked_datatype=TimeSeries,
label="Time Series",
......@@ -66,7 +62,8 @@ class NodeComplexCoherenceForm(ABCAdapterForm):
def __init__(self, prefix='', project_id=None):
super(NodeComplexCoherenceForm, self).__init__(prefix, project_id)
self.time_series = TraitDataTypeSelectField(NodeComplexCoherenceModel.time_series, self, name=self.get_input_name(),
self.time_series = TraitDataTypeSelectField(NodeComplexCoherenceModel.time_series, self,
name=self.get_input_name(),
conditions=self.get_filters())
@staticmethod
......@@ -142,7 +139,7 @@ class NodeComplexCoherenceAdapter(ABCAsynchronous):
self.input_time_series_index.data_length_2d,
self.input_time_series_index.data_length_3d,
self.input_time_series_index.data_length_4d)
LOG.debug("Time series shape is %s" % (str(self.input_shape)))
self.log.debug("Time series shape is %s" % (str(self.input_shape)))
# -------------------- Fill Algorithm for Analysis -------------------##
self.algorithm = NodeComplexCoherence()
self.memory_factor = 1
......@@ -174,10 +171,10 @@ class NodeComplexCoherenceAdapter(ABCAsynchronous):
self.algorithm.time_series = small_ts
partial_result = self.algorithm.evaluate()
LOG.debug("got partial_result")
LOG.debug("partial segment_length is %s" % (str(partial_result.segment_length)))
LOG.debug("partial epoch_length is %s" % (str(partial_result.epoch_length)))
LOG.debug("partial windowing_function is %s" % (str(partial_result.windowing_function)))
self.log.debug("got partial_result")
self.log.debug("partial segment_length is %s" % (str(partial_result.segment_length)))
self.log.debug("partial epoch_length is %s" % (str(partial_result.epoch_length)))
self.log.debug("partial windowing_function is %s" % (str(partial_result.windowing_function)))
# LOG.debug("partial frequency vector is %s" % (str(partial_result.frequency)))
spectra_h5.write_data_slice(partial_result)
......
......@@ -44,15 +44,12 @@ from tvb.core.neotraits.view_model import ViewModel, DataTypeGidAttr
from tvb.datatypes.time_series import TimeSeries
from tvb.datatypes.graph import Covariance
from tvb.core.entities.filters.chain import FilterChain
from tvb.basic.logger.builder import get_logger
from tvb.adapters.datatypes.h5.graph_h5 import CovarianceH5
from tvb.adapters.datatypes.db.graph import CovarianceIndex
from tvb.adapters.datatypes.db.time_series import TimeSeriesIndex
from tvb.core.neotraits.forms import TraitDataTypeSelectField
from tvb.core.neocom import h5
LOG = get_logger(__name__)
class NodeCovariance(HasTraits):
"""
......@@ -77,7 +74,8 @@ class NodeCovarianceAdapterModel(ViewModel, NodeCovariance):
class NodeCovarianceAdapterForm(ABCAdapterForm):
def __init__(self, prefix='', project_id=None):
super(NodeCovarianceAdapterForm, self).__init__(prefix, project_id)
self.time_series = TraitDataTypeSelectField(NodeCovarianceAdapterModel.time_series, self, name=self.get_input_name(),
self.time_series = TraitDataTypeSelectField(NodeCovarianceAdapterModel.time_series, self,
name=self.get_input_name(),
conditions=self.get_filters(), has_all_option=True)
@staticmethod
......@@ -176,8 +174,7 @@ class NodeCovarianceAdapter(ABCAsynchronous):
covariance_h5.close()
return covariance_index
@staticmethod
def _compute_node_covariance(small_ts, input_ts_h5):
def _compute_node_covariance(self, small_ts, input_ts_h5):
"""
Compute the temporal covariance between nodes in a TimeSeries dataType.
A nodes x nodes matrix is returned for each (state-variable, mode).
......@@ -186,7 +183,7 @@ class NodeCovarianceAdapter(ABCAsynchronous):
# (nodes, nodes, state-variables, modes)
result_shape = (data_shape[2], data_shape[2], data_shape[1], data_shape[3])
LOG.info("result shape will be: %s" % str(result_shape))
self.log.info("result shape will be: %s" % str(result_shape))
result = numpy.zeros(result_shape)
......@@ -197,8 +194,8 @@ class NodeCovarianceAdapter(ABCAsynchronous):
data = data - data.mean(axis=0)[numpy.newaxis, 0]
result[:, :, var, mode] = numpy.cov(data.T)
LOG.debug("result")
LOG.debug(narray_describe(result))
self.log.debug("result")
self.log.debug(narray_describe(result))
covariance = Covariance(source=small_ts, array_data=result)
return covariance
......
......@@ -42,15 +42,12 @@ from tvb.core.adapters.abcadapter import ABCAsynchronous, ABCAdapterForm
from tvb.core.neotraits.view_model import ViewModel, DataTypeGidAttr
from tvb.datatypes.time_series import TimeSeries
from tvb.core.entities.filters.chain import FilterChain
from tvb.basic.logger.builder import get_logger
from tvb.adapters.datatypes.h5.mode_decompositions_h5 import PrincipalComponentsH5
from tvb.adapters.datatypes.db.mode_decompositions import PrincipalComponentsIndex
from tvb.adapters.datatypes.db.time_series import TimeSeriesIndex
from tvb.core.neotraits.forms import TraitDataTypeSelectField
from tvb.core.neocom import h5
LOG = get_logger(__name__)
class PCAAdapterModel(ViewModel, PCA):
time_series = DataTypeGidAttr(
......@@ -115,7 +112,7 @@ class PCAAdapter(ABCAsynchronous):
self.input_time_series_index.data_length_2d,
self.input_time_series_index.data_length_3d,
self.input_time_series_index.data_length_4d)
LOG.debug("Time series shape is %s" % str(self.input_shape))
self.log.debug("Time series shape is %s" % str(self.input_shape))
# -------------------- Fill Algorithm for Analysis -------------------##
self.algorithm = PCA()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment