用于可视化小型三维数据集的命令行工具和python库
smalldataviewer的Python项目详细描述
smalldataviewer
基于matplotlib的简单工具,用于查看少量的三维图像数据; 有助于调试。支持Python2.7和3.4+。
安装
pip install smalldataviewer[all]
all
安装包括所有这些可选附加功能:
hdf5
:通过h5py支持hdf5文件img
:通过imageio的体积图像和动画图像fits
:通过使用astropy 的itk
:itk图像通过imageio[simpleitk]
,它使用SimpleITK
imageio[fits]
匹配图像
对n5和zarr阵列的支持也可以通过z5py获得。
这必须与conda一起安装(conda install -c conda-forge -c cpape z5py
)。
用法
DataViewer
打开数据卷的matplotlib
图。
- 可以使用鼠标滚轮滚动尺寸0
- 垂直轴上的维度1为
- 维度2显示在水平轴 上
- 维度3,如果它存在,则是颜色元组
作为可执行文件
可作为命令行实用程序在smalldataviewer
或sdv
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
使用make test-all
如果要添加对新文件类型的支持:
向
tests/common
添加一个函数,该函数创建此类文件并返回 它需要一个内部路径,并将其添加到file_constructors
。在
smalldataviewer.files.FileReader
中添加一个读取此类文件的方法, 返回numpy数组,并从可能的文件中添加映射NORMALISED_TYPES
中单个文件类型的扩展名 (参见示例的现有方法)。不要忘记在
smalldataviewer.ext
中指定任何依赖项,extras_require
在setup.py
,和requirements.txt