image.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:pisap 作者: neurospin 项目源码 文件源码
def plot_data(data, scroll_axis=2):
    """ Plot an image associated data.
    Currently support on 1D, 2D or 3D data.

    Parameters
    ----------
    data: array
        the data to be displayed.
    scroll_axis: int (optional, default 2)
        the scroll axis for 3d data.
    """
    # Check input parameters
    if data.ndim not in range(1, 4):
        raise ValueError("Unsupported data dimension.")

    # Deal with complex data
    if numpy.iscomplex(data).any():
        data = numpy.abs(data)

    # Create application
    app = pyqtgraph.mkQApp()

    # Create the widget
    if data.ndim == 3:
        indices = [i for i in range(3) if i != scroll_axis]
        indices = [scroll_axis] + indices
        widget = pyqtgraph.image(numpy.transpose(data, indices))
    elif data.ndim == 2:
        widget = pyqtgraph.image(data)
    else:
        widget = pyqtgraph.plot(data)

    # Run application
    app.exec_()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号