A Digital Micrograph 4 (DM4) file reader.
Project description
dm4
A simple pure python file reader for Digital Micrograph’s DM4 file format
This package would not have been possible without the documentation provided by Dr Chris Boothroyd at http://www.er-c.org/cbb/info/dmformat/ Thank you.
Installation
Install using pip from the command line:
pip install dm4
Example
Below is a short example of reading the image data from a dm4 file. A more complete example can be found in the tests.:
import dm4
dm4data = dm4.DM4File.open("sample.dm4")
tags = dm4data.read_directory()
image_data_tag = tags.named_subdirs['ImageList'].unnamed_subdirs[1].named_subdirs['ImageData']
image_tag = image_data_tag.named_tags['Data']
XDim = dm4data.read_tag_data(image_data_tag.named_subdirs['Dimensions'].unnamed_tags[0])
YDim = dm4data.read_tag_data(image_data_tag.named_subdirs['Dimensions'].unnamed_tags[1])
np_array = np.array(dm4data.read_tag_data(image_tag), dtype=np.uint16)
np_array = np.reshape(np_array, (YDim, XDim))
output_fullpath = "sample.tif"
image = PIL.Image.fromarray(np_array, 'I;16')
image.save(output_fullpath)
Todo
Reading arrays of groups has not been implemented.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dm4-1.0.2.tar.gz.
File metadata
- Download URL: dm4-1.0.2.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5e74b24cd2cfdd1755da59823770ee60a080a549bfd5df7bec1e3089fb2c486
|
|
| MD5 |
e9a8e8280947c1a190a11d3f93c60fcc
|
|
| BLAKE2b-256 |
225caf2db878a679bb1b843e9069591f825eb23a533778ba969c1ecf5ba205a1
|
File details
Details for the file dm4-1.0.2-py2.py3-none-any.whl.
File metadata
- Download URL: dm4-1.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8eae01dcf7afe74f9398774536a2aa1c936b551f791f436e94a3e2d4e6aafbc9
|
|
| MD5 |
4d83732db0eca804b01cdf4ccf804836
|
|
| BLAKE2b-256 |
0e21e73f91ba50d4e4c1d0cfc5916aeee101ae878dbba17f25d0a4c8b0205243
|