Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dm4-1.0.2.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dm4-1.0.2-py2.py3-none-any.whl (6.8 kB view details)

Uploaded Python 2Python 3

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

Hashes for dm4-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c5e74b24cd2cfdd1755da59823770ee60a080a549bfd5df7bec1e3089fb2c486
MD5 e9a8e8280947c1a190a11d3f93c60fcc
BLAKE2b-256 225caf2db878a679bb1b843e9069591f825eb23a533778ba969c1ecf5ba205a1

See more details on using hashes here.

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

Hashes for dm4-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8eae01dcf7afe74f9398774536a2aa1c936b551f791f436e94a3e2d4e6aafbc9
MD5 4d83732db0eca804b01cdf4ccf804836
BLAKE2b-256 0e21e73f91ba50d4e4c1d0cfc5916aeee101ae878dbba17f25d0a4c8b0205243

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page