Skip to main content

A Digital Micrograph 4 (DM4) file reader.

Project description

dm4reader

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.

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.1.tar.gz (8.1 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.1-py2.py3-none-any.whl (6.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file dm4-1.0.1.tar.gz.

File metadata

  • Download URL: dm4-1.0.1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for dm4-1.0.1.tar.gz
Algorithm Hash digest
SHA256 cba9494ba649ac1dee4c2855396d3b629f1e83ee3de7b399869d20dd0ea8ebb6
MD5 111b27256157e5f1e4b86121bb288938
BLAKE2b-256 7a7868dcbd83329d8d6ac7d8a2f3845d4d58f1a0bc54c4c97613764885e32049

See more details on using hashes here.

File details

Details for the file dm4-1.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: dm4-1.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.6 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.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d59eb9781171933606d199a099933892e30111569f200cd9befb76c12e6dec28
MD5 94bd33cdc413e9a47590cbcdaacb7480
BLAKE2b-256 26478ebd96e534f7ba542a5818c11317c72a4f0914d7fe59377693dbfbcfcb1a

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