本文整理匯總了Python中tvb.core.adapters.abcdisplayer.ABCDisplayer.dump_with_precision方法的典型用法代碼示例。如果您正苦於以下問題:Python ABCDisplayer.dump_with_precision方法的具體用法?Python ABCDisplayer.dump_with_precision怎麽用?Python ABCDisplayer.dump_with_precision使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tvb.core.adapters.abcdisplayer.ABCDisplayer
的用法示例。
在下文中一共展示了ABCDisplayer.dump_with_precision方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_metric_matrix
# 需要導入模塊: from tvb.core.adapters.abcdisplayer import ABCDisplayer [as 別名]
# 或者: from tvb.core.adapters.abcdisplayer.ABCDisplayer import dump_with_precision [as 別名]
def get_metric_matrix(self, datatype_group, selected_metric=None):
self.model = PseIsoModel.from_db(datatype_group.fk_operation_group)
if selected_metric is None:
selected_metric = self.model.metrics.keys()[0]
data_matrix = self.model.apriori_data[selected_metric]
data_matrix = numpy.rot90(data_matrix)
data_matrix = numpy.flipud(data_matrix)
matrix_data = ABCDisplayer.dump_with_precision(data_matrix.flat)
matrix_guids = self.model.datatypes_gids
matrix_guids = numpy.rot90(matrix_guids)
matrix_shape = json.dumps(data_matrix.squeeze().shape)
x_min = self.model.apriori_x[0]
x_max = self.model.apriori_x[self.model.apriori_x.size - 1]
y_min = self.model.apriori_y[0]
y_max = self.model.apriori_y[self.model.apriori_y.size - 1]
vmin = data_matrix.min()
vmax = data_matrix.max()
return dict(matrix_data=matrix_data,
matrix_guids=json.dumps(matrix_guids.flatten().tolist()),
matrix_shape=matrix_shape,
color_metric=selected_metric,
x_min=x_min,
x_max=x_max,
y_min=y_min,
y_max=y_max,
vmin=vmin,
vmax=vmax)
示例2: compute_raw_matrix_params
# 需要導入模塊: from tvb.core.adapters.abcdisplayer import ABCDisplayer [as 別名]
# 或者: from tvb.core.adapters.abcdisplayer.ABCDisplayer import dump_with_precision [as 別名]
def compute_raw_matrix_params(matrix):
"""
Serializes matrix data, shape and stride metadata to json
"""
matrix_data = ABCDisplayer.dump_with_precision(matrix.flat)
matrix_shape = json.dumps(matrix.shape)
return dict(matrix_data=matrix_data,
matrix_shape=matrix_shape)
示例3: launch
# 需要導入模塊: from tvb.core.adapters.abcdisplayer import ABCDisplayer [as 別名]
# 或者: from tvb.core.adapters.abcdisplayer.ABCDisplayer import dump_with_precision [as 別名]
def launch(self, datatype):
"""Construct data for visualization and launch it."""
# get data from coher datatype, convert to json
frequency = ABCDisplayer.dump_with_precision(datatype.get_data('frequency').flat)
array_data = datatype.get_data('array_data')
params = self.compute_raw_matrix_params(array_data)
params.update(frequency=frequency)
params.update(matrix_strides=json.dumps([x / array_data.itemsize for x in array_data.strides]))
return self.build_display_result("cross_coherence/view", params)
示例4: launch
# 需要導入模塊: from tvb.core.adapters.abcdisplayer import ABCDisplayer [as 別名]
# 或者: from tvb.core.adapters.abcdisplayer.ABCDisplayer import dump_with_precision [as 別名]
def launch(self, data_0, data_1=None, data_2=None):
connectivity = data_0.connectivity
sensor_locations = TopographyCalculations.normalize_sensors(connectivity.centres)
sensor_number = len(sensor_locations)
arrays = []
titles = []
min_vals = []
max_vals = []
data_array = []
data_arrays = []
for measure in [data_0, data_1, data_2]:
if measure is not None:
if len(measure.connectivity.centres) != sensor_number:
raise Exception("Use the same connectivity!!!")
arrays.append(measure.array_data.tolist())
titles.append(measure.title)
min_vals.append(measure.array_data.min())
max_vals.append(measure.array_data.max())
color_bar_min = min(min_vals)
color_bar_max = max(max_vals)
for i, array_data in enumerate(arrays):
try:
data_array = TopographyCalculations.compute_topography_data(array_data, sensor_locations)
if numpy.any(numpy.isnan(array_data)):
titles[i] = titles[i] + " - Topography contains nan"
if not numpy.any(array_data):
titles[i] = titles[i] + " - Topography data is all zeros"
data_arrays.append(ABCDisplayer.dump_with_precision(data_array.flat))
except KeyError as err:
self.log.exception(err)
raise LaunchException("The measure points location is not compatible with this viewer ", err)
params = dict(matrix_datas=data_arrays,
matrix_shape=json.dumps(data_array.squeeze().shape),
titles=titles,
vmin=color_bar_min,
vmax=color_bar_max)
return self.build_display_result("topographic/view", params,
pages={"controlPage": "topographic/controls"})
示例5: launch
# 需要導入模塊: from tvb.core.adapters.abcdisplayer import ABCDisplayer [as 別名]
# 或者: from tvb.core.adapters.abcdisplayer.ABCDisplayer import dump_with_precision [as 別名]
def launch(self, input_data, **kwarg):
shape = input_data.read_data_shape()
start_time = input_data.source.start_time
wavelet_sample_period = input_data.source.sample_period * \
max((1, int(input_data.sample_period / input_data.source.sample_period)))
end_time = input_data.source.start_time + (wavelet_sample_period * shape[1])
if len(input_data.frequencies):
freq_lo = input_data.frequencies[0]
freq_hi = input_data.frequencies[-1]
else:
freq_lo = 0
freq_hi = 1
slices = (slice(shape[0]),
slice(shape[1]),
slice(0, 1, None),
slice(0, shape[3], None),
slice(0, 1, None))
data_matrix = input_data.get_data('power', slices)
data_matrix = data_matrix.sum(axis=3)
scale_range_start = max(1, int(0.25 * shape[1]))
scale_range_end = max(1, int(0.75 * shape[1]))
scale_min = data_matrix[:, scale_range_start:scale_range_end, :].min()
scale_max = data_matrix[:, scale_range_start:scale_range_end, :].max()
matrix_data = ABCDisplayer.dump_with_precision(data_matrix.flat)
matrix_shape = json.dumps(data_matrix.squeeze().shape)
params = dict(canvasName="Wavelet Spectrogram for: " + input_data.source.type,
xAxisName="Time (%s)" % str(input_data.source.sample_period_unit),
yAxisName="Frequency (%s)" % str("kHz"),
title=self._ui_name,
matrix_data=matrix_data,
matrix_shape=matrix_shape,
start_time=start_time,
end_time=end_time,
freq_lo=freq_lo,
freq_hi=freq_hi,
vmin=scale_min,
vmax=scale_max)
return self.build_display_result("wavelet/wavelet_view", params,
pages={"controlPage": "wavelet/controls"})