用于可视化小型三维数据集的命令行工具和python库

smalldataviewer的Python项目详细描述


smalldataviewer

TravisPyPIPyPI - Python Version

基于matplotlib的简单工具,用于查看少量的三维图像数据; 有助于调试。支持Python2.7和3.4+。

改编自this matplotlib recipe

Small ssTEM Volume

安装

pip install smalldataviewer[all]

all安装包括所有这些可选附加功能:

  • hdf5:通过h5py支持hdf5文件
  • img:通过imageio的体积图像和动画图像
  • fits:通过使用astropy
  • imageio[fits]匹配图像
  • itk:itk图像通过imageio[simpleitk],它使用SimpleITK

对n5和zarr阵列的支持也可以通过z5py获得。 这必须与conda一起安装(conda install -c conda-forge -c cpape z5py)。

用法

DataViewer打开数据卷的matplotlib图。

  • 可以使用鼠标滚轮滚动尺寸0
  • 垂直轴上的维度1为
  • 维度2显示在水平轴
  • 维度3,如果它存在,则是颜色元组

作为可执行文件

可作为命令行实用程序在smalldataviewersdv

usage: smalldataviewer [-h] [--version] [-i INTERNAL_PATH] [-t TYPE]
                       [-o ORDER] [-f OFFSET] [-s SHAPE] [-v] [-l]
                       path

positional arguments:
  path                  Path to file containing a 3D dataset

optional arguments:
  -h, --help            show this help message and exit
  --version             Print version information and exit
  -i INTERNAL_PATH, --internal_path INTERNAL_PATH
                        Internal path of dataset inside HDF5, N5, zarr or npz
                        file. If JSON, assumes the outer object is a dict, and
                        internal_path is the key of the array
  -t TYPE, --type TYPE  Dataset file type. Inferred from extension if not
                        given.
  -o ORDER, --order ORDER
                        Order of non-channel axes for axis labelling purposes
                        (data is not transposed): dimension 0 will be scrolled
                        through, dimension 1 will be on the up-down axis,
                        dimension 2 will be on the left-right axis, and
                        dimension 3, if it exists, will be used as the colour
                        channels. Default "zyx".
  -f OFFSET, --offset OFFSET
                        3D offset of ROI from (0, 0, 0) in pixels, in the form
                        "<scroll>,<vertical>,<horizontal>"
  -s SHAPE, --shape SHAPE
                        3D shape of ROI in pixels, in the form
                        "<scroll>,<vertical>,<horizontal>"
  -v, --verbose         Increase logging verbosity
  -l, --label           Whether to treat images as a label volume

例如

smalldataviewer my_data.hdf5 -i /my_group/my_volume

注意:由于python保存文件的环境 描述符打开,在其下matplotlib块的可执行格式 将数据完整地读入内存。如果你的数据太大 这,看一看带有--offset-f)和--shape的小块 (-s)选项。

作为库

importsmalldataviewerassdvimportnumpyasnpdata=np.random.random((30,100,100))viewer=sdv.DataViewer(data)viewer.show()# or matplotlib.pyplot.show()viewer2=sdv.DataViewer.from_file("my_data.npz",offset=(10,20,30),shape=(256,512,512),internal_path="volume")viewer2.show()reader=sdv.FileReader("my_cat_video.gif")data2=reader.read()# returns a numpy arrayviewer3=sdv.DataViewer(data2)viewer3.show()

注意:FileReader(并通过扩展Dataviewer.from_file)读取请求的数据 从文件到内存。 传递文件的可索引表示,如numpy memmap或hdf5数据集, 不会的。 但是,可能需要将其复制到内存中以提高性能,或者取决于脚本的其余部分。

贡献

安装开发环境(不包括z5py) make install-dev

使用make test

在当前python环境中运行测试

使用make test-all

对所有受支持的python版本运行测试

如果要添加对新文件类型的支持:

  1. tests/common添加一个函数,该函数创建此类文件并返回 它需要一个内部路径,并将其添加到file_constructors

  2. smalldataviewer.files.FileReader中添加一个读取此类文件的方法, 返回numpy数组,并从可能的文件中添加映射 NORMALISED_TYPES中单个文件类型的扩展名 (参见示例的现有方法)。

  3. 不要忘记在smalldataviewer.ext中指定任何依赖项, extras_requiresetup.py,和requirements.txt

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java未从Facebook OAuth接收名字、姓氏和姓氏   我自己代码中的java ConcurrentModificationException   java在Android上获得单像素TIFF图像   java图形输出中的swing集成弹出窗口“通知”   将数据库表中的所有数据集插入jTable Java   java如何使用Hibernate获取不完整的集合?   打印无法从java连接到打印机   java使用分隔符拆分带引号的字符串   java Axis2禁用严格验证(wsdl2java中的Eosv)允许什么,如何使其更加严格?   java有人能帮我处理循环代码吗   java将JsonObject数组转换为整数   JavaXWiki扩展:检测事件空间创建   java如何设置图表的文本方向以使用poi旋转所有文本?   eche RecyclerView项的java Set自定义字体   java单元测试带有私有构造函数的spring组件,无需注入   用户界面如何在java中动态显示一组多个元素?   如何从java应用程序调用IDL(交互式数据语言)?   Java的内置库实现