本文整理匯總了Python中tvb.core.adapters.abcdisplayer.ABCDisplayer.get_one_dimensional_list方法的典型用法代碼示例。如果您正苦於以下問題:Python ABCDisplayer.get_one_dimensional_list方法的具體用法?Python ABCDisplayer.get_one_dimensional_list怎麽用?Python ABCDisplayer.get_one_dimensional_list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tvb.core.adapters.abcdisplayer.ABCDisplayer
的用法示例。
在下文中一共展示了ABCDisplayer.get_one_dimensional_list方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: compute_parameters
# 需要導入模塊: from tvb.core.adapters.abcdisplayer import ABCDisplayer [as 別名]
# 或者: from tvb.core.adapters.abcdisplayer.ABCDisplayer import get_one_dimensional_list [as 別名]
def compute_parameters(input_data, colors=None, rays=None):
"""
Having as inputs a Connectivity matrix(required) and two arrays that
represent the rays and colors of the nodes from the matrix(optional)
this method will build the required parameter dictionary that will be
sent to the HTML/JS 3D representation of the connectivity matrix.
"""
if colors is not None:
color_list = colors.array_data.tolist()
color_list = ABCDisplayer.get_one_dimensional_list(color_list, input_data.number_of_regions,
"Invalid input size for Sphere Colors")
color_list = numpy.nan_to_num(numpy.array(color_list, dtype=numpy.float64)).tolist()
else:
color_list = [1.0] * input_data.number_of_regions
if rays is not None:
rays_list = rays.array_data.tolist()
rays_list = ABCDisplayer.get_one_dimensional_list(rays_list, input_data.number_of_regions,
"Invalid input size for Sphere Sizes")
rays_list = numpy.nan_to_num(numpy.array(rays_list, dtype=numpy.float64)).tolist()
else:
rays_list = [1.0] * input_data.number_of_regions
params = dict(raysArray=json.dumps(rays_list), rayMin=min(rays_list), rayMax=max(rays_list),
colorsArray=json.dumps(color_list), colorMin=min(color_list), colorMax=max(color_list))
return params, {}
示例2: _prepare_colors
# 需要導入模塊: from tvb.core.adapters.abcdisplayer import ABCDisplayer [as 別名]
# 或者: from tvb.core.adapters.abcdisplayer.ABCDisplayer import get_one_dimensional_list [as 別名]
def _prepare_colors(self, colors, expected_size, step=None):
"""
From the input array, all values smaller than step will get a different color
"""
if colors is None:
return [self.DEFAULT_COLOR] * expected_size, None
colors = numpy.nan_to_num(numpy.array(colors.array_data, dtype=numpy.float64)).tolist()
colors = ABCDisplayer.get_one_dimensional_list(colors, expected_size, "Invalid size for colors array!")
result = []
if step is None:
step = (max(colors) + min(colors)) / 2
for val in colors:
if val < step:
result.append(self.OTHER_COLOR)
else:
result.append(self.DEFAULT_COLOR)
return result, step
示例3: _normalize_rays
# 需要導入模塊: from tvb.core.adapters.abcdisplayer import ABCDisplayer [as 別名]
# 或者: from tvb.core.adapters.abcdisplayer.ABCDisplayer import get_one_dimensional_list [as 別名]
def _normalize_rays(self, rays, expected_size):
"""
Make sure all rays are in the interval [self.MIN_RAY, self.MAX_RAY]
"""
if rays is None:
value = (self.MAX_RAY + self.MIN_RAY) / 2
return [value] * expected_size, 0.0, 0.0
rays = rays.array_data.tolist()
rays = ABCDisplayer.get_one_dimensional_list(rays, expected_size, "Invalid size for rays array.")
min_x = min(rays)
max_x = max(rays)
if min_x >= self.MIN_RAY and max_x <= self.MAX_RAY:
# No need to normalize
return rays, min_x, max_x
result = []
diff = max_x - min_x
if min_x == max_x:
diff = self.MAX_RAY - self.MIN_RAY
for ray in rays:
result.append(self.MIN_RAY + self.MAX_RAY * (ray - min_x) / diff)
result = numpy.nan_to_num(numpy.array(result, dtype=numpy.float64)).tolist()
return result, min(rays), max(rays)