• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python abcdisplayer.ABCDisplayer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tvb.core.adapters.abcdisplayer.ABCDisplayer的典型用法代码示例。如果您正苦于以下问题:Python ABCDisplayer类的具体用法?Python ABCDisplayer怎么用?Python ABCDisplayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ABCDisplayer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: compute_parameters

    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, {}
开发者ID:gummadhav,项目名称:tvb-framework,代码行数:26,代码来源:connectivity.py


示例2: prepare_mapped_sensors_as_measure_points_params

def prepare_mapped_sensors_as_measure_points_params(project_id, sensors, eeg_cap=None):
    """
    Compute sensors positions by mapping them to the ``eeg_cap`` surface
    If ``eeg_cap`` is not specified the mapping will use a default EEGCal DataType in current project.
    If no default EEGCap is found, return sensors as they are (not projected)

    :returns: dictionary to be used in Viewers for rendering measure_points
    :rtype: dict
    """

    if eeg_cap is None:
        eeg_cap = dao.try_load_last_entity_of_type(project_id, EEGCap)

    if eeg_cap:
        datatype_kwargs = json.dumps({'surface_to_map': eeg_cap.gid})
        sensor_locations = ABCDisplayer.paths2url(sensors, 'sensors_to_surface') + '/' + datatype_kwargs
        sensor_no = sensors.number_of_sensors
        sensor_labels = ABCDisplayer.paths2url(sensors, 'labels')

        return {'urlMeasurePoints': sensor_locations,
                'urlMeasurePointsLabels': sensor_labels,
                'noOfMeasurePoints': sensor_no,
                'minMeasure': 0,
                'maxMeasure': sensor_no,
                'urlMeasure': ''}

    return prepare_sensors_as_measure_points_params(sensors)
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:27,代码来源:sensors.py


示例3: get_sensor_measure_points

 def get_sensor_measure_points(sensors):
     """
         Returns urls from where to fetch the measure points and their labels
     """
     measure_points = ABCDisplayer.paths2url(sensors, 'locations')
     measure_points_no = sensors.number_of_sensors
     measure_points_labels = ABCDisplayer.paths2url(sensors, 'labels')
     return measure_points, measure_points_labels, measure_points_no
开发者ID:unimauro,项目名称:tvb-framework,代码行数:8,代码来源:brain.py


示例4: retrieve_measure_points

 def retrieve_measure_points(self, time_series):
     """
     To be overwritten method, for retrieving the measurement points (region centers, EEG sensors).
     """
     if isinstance(time_series, TimeSeriesSurface):
         return [], [], 0
     measure_points = ABCDisplayer.paths2url(time_series.connectivity, 'centres')
     measure_points_labels = ABCDisplayer.paths2url(time_series.connectivity, 'region_labels')
     measure_points_no = time_series.connectivity.number_of_regions
     return measure_points, measure_points_labels, measure_points_no
开发者ID:unimauro,项目名称:tvb-framework,代码行数:10,代码来源:brain.py


示例5: prepare_sensors_as_measure_points_params

def prepare_sensors_as_measure_points_params(sensors):
    """
    Returns urls from where to fetch the measure points and their labels
    """
    sensor_locations = ABCDisplayer.paths2url(sensors, 'locations')
    sensor_no = sensors.number_of_sensors
    sensor_labels = ABCDisplayer.paths2url(sensors, 'labels')

    return {'urlMeasurePoints': sensor_locations,
            'urlMeasurePointsLabels': sensor_labels,
            'noOfMeasurePoints': sensor_no,
            'minMeasure': 0,
            'maxMeasure': sensor_no,
            'urlMeasure': ''}
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:14,代码来源:sensors.py


示例6: compute_params

    def compute_params(self, region_mapping_volume=None, measure=None, data_slice='', background=None):

        region_mapping_volume = self._ensure_region_mapping(region_mapping_volume)

        volume = region_mapping_volume.volume
        volume_shape = region_mapping_volume.read_data_shape()
        volume_shape = (1, ) + volume_shape

        if measure is None:
            params = self._compute_region_volume_map_params(region_mapping_volume)
        else:
            params = self._compute_measure_params(region_mapping_volume, measure, data_slice)

        url_voxel_region = ABCDisplayer.paths2url(region_mapping_volume, "get_voxel_region", parameter="")

        params.update(volumeShape=json.dumps(volume_shape),
                      volumeOrigin=json.dumps(volume.origin.tolist()),
                      voxelUnit=volume.voxel_unit,
                      voxelSize=json.dumps(volume.voxel_size.tolist()),
                      urlVoxelRegion=url_voxel_region)

        if background is None:
            background = dao.try_load_last_entity_of_type(self.current_project_id, StructuralMRI)

        params.update(self._compute_background(background))
        return params
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:26,代码来源:region_volume_mapping.py


示例7: get_metric_matrix

    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)
开发者ID:maedoc,项目名称:tvb-framework,代码行数:28,代码来源:pse_isocline.py


示例8: launch

    def launch(self, **kwargs):
        self.log.debug("Plot started...")
        input_data = kwargs['input_data']
        shape = list(input_data.read_data_shape())
        state_list = input_data.source.labels_dimensions.get(input_data.source.labels_ordering[1], [])
        mode_list = range(shape[3])
        available_scales = ["Linear", "Logarithmic"]

        params = dict(matrix_shape=json.dumps([shape[0], shape[2]]),
                      plotName=input_data.source.type,
                      url_base=ABCDisplayer.paths2url(input_data, "get_fourier_data", parameter=""),
                      xAxisName="Frequency [kHz]",
                      yAxisName="Power",
                      available_scales=available_scales,
                      state_list=state_list,
                      mode_list=mode_list,
                      normalize_list=["no", "yes"],
                      normalize="no",
                      state_variable=state_list[0],
                      mode=mode_list[0],
                      xscale=available_scales[0],
                      yscale=available_scales[0],
                      x_values=json.dumps(input_data.frequency[slice(shape[0])].tolist()),
                      xmin=input_data.freq_step,
                      xmax=input_data.max_freq)
        return self.build_display_result("fourier_spectrum/view", params)
开发者ID:maedoc,项目名称:tvb-framework,代码行数:26,代码来源:fourier_spectrum.py


示例9: launch

    def launch(self, connectivity):
        """Construct data for visualization and launch it."""

        pars = {"labels": json.dumps(connectivity.region_labels.tolist()),
                "url_base": ABCDisplayer.paths2url(connectivity, attribute_name="weights", flatten="True")
                }

        return self.build_display_result("connectivity_edge_bundle/view", pars)
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:8,代码来源:connectivity_edge_bundle.py


示例10: retrieve_measure_points_prams

    def retrieve_measure_points_prams(self, time_series):
        """
        To be overwritten method, for retrieving the measurement points (region centers, EEG sensors).
        """
        if self.connectivity is None:
            self.measure_points_no = 0
            return {'urlMeasurePoints': [],
                    'urlMeasurePointsLabels': [],
                    'noOfMeasurePoints': 0}

        measure_points = ABCDisplayer.paths2url(self.connectivity, 'centres')
        measure_points_labels = ABCDisplayer.paths2url(self.connectivity, 'region_labels')
        self.measure_points_no = self.connectivity.number_of_regions

        return {'urlMeasurePoints': measure_points,
                'urlMeasurePointsLabels': measure_points_labels,
                'noOfMeasurePoints': self.measure_points_no}
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:17,代码来源:brain.py


示例11: _compute_background

 def _compute_background(background):
     if background is not None:
         min_value, max_value = background.get_min_max_values()
         url_volume_data = ABCDisplayer.paths2url(background, 'get_volume_view', parameter='')
     else:
         min_value, max_value = 0, 0
         url_volume_data = None
     return dict( minBackgroundValue=min_value, maxBackgroundValue=max_value,
                  urlBackgroundVolumeData = url_volume_data )
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:9,代码来源:region_volume_mapping.py


示例12: compute_raw_matrix_params

    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)
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:9,代码来源:matrix_viewer.py


示例13: launch

    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)
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:11,代码来源:cross_coherence.py


示例14: compute_sensor_surfacemapped_measure_points

    def compute_sensor_surfacemapped_measure_points(project_id, sensors, eeg_cap=None):
        """
        Compute sensors positions by mapping them to the ``eeg_cap`` surface
        If ``eeg_cap`` is not specified the mapping will use a default.
        It returns a url from where to fetch the positions
        If no default is available it returns None
        :returns: measure points, measure points labels, measure points number
        :rtype: tuple
        """

        if eeg_cap is None:
            eeg_cap = dao.get_values_of_datatype(project_id, EEGCap)[0]
            if eeg_cap:
                eeg_cap = ABCDisplayer.load_entity_by_gid(eeg_cap[-1][2])

        if eeg_cap:
            datatype_kwargs = json.dumps({'surface_to_map': eeg_cap.gid})
            measure_points = ABCDisplayer.paths2url(sensors, 'sensors_to_surface') + '/' + datatype_kwargs
            measure_points_no = sensors.number_of_sensors
            measure_points_labels = ABCDisplayer.paths2url(sensors, 'labels')
            return measure_points, measure_points_labels, measure_points_no
开发者ID:unimauro,项目名称:tvb-framework,代码行数:21,代码来源:brain.py


示例15: get_shell_surface_urls

    def get_shell_surface_urls(shell_surface=None, project_id=0):

        if shell_surface is None:
            shell_surface = dao.get_values_of_datatype(project_id, FaceSurface)[0]

            if not shell_surface:
                raise Exception('No face object found in database.')

            shell_surface = ABCDisplayer.load_entity_by_gid(shell_surface[0][2])

        face_vertices, face_normals, _, face_triangles = shell_surface.get_urls_for_rendering()
        return json.dumps([face_vertices, face_normals, face_triangles])
开发者ID:unimauro,项目名称:tvb-framework,代码行数:12,代码来源:brain.py


示例16: _compute_measure_params

    def _compute_measure_params(self, region_mapping_volume, measure, data_slice):
        # prepare the url that will project the measure onto the region volume map
        metadata = measure.get_metadata('array_data')
        min_value, max_value = metadata[measure.METADATA_ARRAY_MIN], metadata[measure.METADATA_ARRAY_MAX]
        measure_shape = measure.get_data_shape('array_data')
        if not data_slice:
            data_slice = self.get_default_slice(measure_shape, region_mapping_volume.connectivity.number_of_regions)
            data_slice = slice_str(data_slice)
        datatype_kwargs = json.dumps({'mapped_array': measure.gid})
        url_volume_data = ABCDisplayer.paths2url(region_mapping_volume, "get_mapped_array_volume_view")
        url_volume_data += '/' + datatype_kwargs + '?mapped_array_slice=' + data_slice + ';'

        return dict(  minValue=min_value, maxValue=max_value,
                      urlVolumeData=url_volume_data,
                      measureShape=slice_str(measure_shape),
                      measureSlice=data_slice)
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:16,代码来源:region_volume_mapping.py


示例17: _prepare_colors

 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
开发者ID:gummadhav,项目名称:tvb-framework,代码行数:17,代码来源:connectivity.py


示例18: launch

    def launch(self, input_data, **kwargs):
        """
        Draw interactive display.
        """
        self.log.debug("Plot started...")

        params = dict(plotName=input_data.source.type,
                      xAxisName="Frequency [kHz]",
                      yAxisName="CohSpec",
                      available_xScale=["Linear", "Logarithmic"],
                      available_spectrum=json.dumps(input_data.spectrum_types),
                      spectrum_list=input_data.spectrum_types,
                      xscale="Linear",
                      spectrum=input_data.spectrum_types[0],
                      url_base=ABCDisplayer.paths2url(input_data, "get_spectrum_data", parameter=""),
                      # TODO investigate the static xmin and xmax values
                      xmin=0.02,
                      xmax=0.8)
        return self.build_display_result("complex_coherence/view", params)
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:19,代码来源:complex_imaginary_coherence.py


示例19: launch

    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"})
开发者ID:maedoc,项目名称:tvb-framework,代码行数:43,代码来源:topographic.py


示例20: launch

    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"})
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:42,代码来源:wavelet_spectrogram.py



注:本文中的tvb.core.adapters.abcdisplayer.ABCDisplayer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python input_tree.InputTreeManager类代码示例发布时间:2022-05-27
下一篇:
Python abcadapter.ABCAdapter类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap