Package: smalldataviewer
smalldataviewerSimple matplotlib-based tool for viewing small amounts of 3D image data;
helpful for debugging. Supports python 2.7 and 3.4+.Adapted fromthis matplotlib recipe.Installationpipinstallsmalldataviewer[all]Theallinstallation includes all of these optional extras:hdf5: HDF5 file support viah5pyimg: volumetric and animated images viaimageiofits: FITS images viaimageio[fits], which usesastropyitk: ITK images viaimageio[simpleitk], which usesSimpleITKSupport for N5 and zarr arrays is also available viaz5py.
This must be installed with conda (conda install -c conda-forge -c cpape z5py).UsageTheDataVieweropens amatplotlibfigure of the data volume.Dimension 0 can be scrolled through with the mouse wheelDimension 1 is shown on the vertical axisDimension 2 is shown on the horizontal axisDimension 3, if it exists, is a colour tupleAs executableAvailable as a command-line utility atsmalldataviewerorsdvusage: 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 volumee.g.smalldataviewermy_data.hdf5-i/my_group/my_volumeNote: because of the circumstances under which python holds file
descriptors open, and under which matplotlib blocks, the executable form
reads the data into memory in its entirety. If your data are too big for
this, look at small chunks with the--offset(-f) and--shape(-s) options.As libraryimportsmalldataviewerassdvimportnumpyasnpdata=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()Note:FileReader(and by extensionDataviewer.from_file) reads the requested data
from the file into memory.
Passing an indexable representation of a file, like a numpy memmap or an hdf5 dataset,
will not.
However, you may need to copy it into memory for performance, or depending on the rest of your script.ContributingInstall a development environment (not including z5py) withmake install-devRun tests in your current python environment withmake testRun tests against all supported python versions withmake test-allIf you would like to add support for a new file type:Add totests/commona function which creates such a file and returns whether
it needs an internal path, and add it tofile_constructors.Add tosmalldataviewer.files.FileReadera method which reads such a file,
returning a numpy array, and add a mapping from likely file
extensions to a single file type inNORMALISED_TYPES(see existing methods for examples).Don't forget to specify any dependencies insmalldataviewer.ext,extras_requireinsetup.py, andrequirements.txt