Skip to main content

Python package to parse and provide access to headers and data streams in Amira (R) files

Project description

PyPI PyPI - Python Version https://travis-ci.org/emdb-empiar/ahds.svg?branch=master Documentation Status https://coveralls.io/repos/github/emdb-empiar/ahds/badge.svg

Overview

ahds is a Python package to parse and handle Amira (R) files. It was developed to facilitate reading of Amira (R) files as part of the EMDB-SFF toolkit.

License

ahds is free software and is provided under the terms of the Apache License, Version 2.0.

Copyright 2017 EMBL - European Bioinformatics Institute

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific
language governing permissions and limitations under the License.

Use Cases

  • Detect and parse Amira (R) headers and return structured data

  • Decode data (HxRLEByte, HxZip)

  • Easy extensibility to handle previously unencountered data streams

ahds was written and is maintained by Paul K. Korir but there is a list of contributors. Feel free to join this initiative.

Installation

ahds works with Python 2.7, 3.5, 3.6 and 3.7. It requires numpy to build.

pip install numpy

Afterwards you may run

pip install ahds

Getting Started

You can begin playing with ahds out of the box using the provided console command ahds.

me@home ~$ ahds ahds/data/FieldOnTetraMesh.am
********************************************************************************************************************************************
AMIRA (R) HEADER AND DATA STREAMS
--------------------------------------------------------------------------------------------------------------------------------------------
+-ahds/data/FieldOnTetraMesh.am                                                                  AmiraFile [is_parent? True ]
|  +-meta                                                                                            Block [is_parent? False]
|  |  +-file: ahds/data/FieldOnTetraMesh.am
|  |  +-header_length: 182
|  |  +-data_streams: 1
|  |  +-streams_loaded: False
|  +-header                                                                                    AmiraHeader [is_parent? True ]
|  |  +-filetype: AmiraMesh
|  |  +-dimension: 3D
|  |  +-format: BINARY
|  |  +-endian: BIG
|  |  +-version: 2.0
|  |  +-extra_format: None
|  |  +-Parameters                                                                                   Block [is_parent? False]
|  |  +-Tetrahedra                                                                                   Block [is_parent? False]
|  |  |  +-length: 23685
|  +-data_streams                                                                                    Block [is_parent? False]
********************************************************************************************************************************************

The ahds command takes the following arguments

me@home ~$ ahds -h
usage: ahds [-h] [-s] [-d] [-l] file [file ...]

Python tool to read and display Amira files

positional arguments:
  file                a valid Amira file with an optional block path

optional arguments:
  -h, --help          show this help message and exit
  -s, --load-streams  whether to load data streams or not [default: False]
  -d, --debug         display debugging information [default: False]
  -l, --literal       display the literal header [default: False]

You can specify a dotted path after the filename to only render that the content of that field in the header:

me@home ~$ ahds ahds/data/FieldOnTetraMesh.am header
***********************************************************************************************************************************
ahds: Displaying path 'header'
-----------------------------------------------------------------------------------------------------------------------------------
+-header                                                                                       AmiraHeader [is_parent? True ]
|  +-filetype: AmiraMesh
|  +-dimension: 3D
|  +-format: BINARY
|  +-endian: BIG
|  +-version: 2.0
|  +-extra_format: None
|  +-Parameters                                                                                      Block [is_parent? False]
|  +-Tetrahedra                                                                                      Block [is_parent? False]
|  |  +-length: 23685

For debugging you can display the literal header (the exact header present in the file) using the -l/--literal flag. Also, you can display the parsed data structure using the -d/--debug flag.

me@home ~$ ahds --literal --debug ahds/data/FieldOnTetraMesh.am
***********************************************************************************************************************************
ahds: Displaying literal header
-----------------------------------------------------------------------------------------------------------------------------------
# AmiraMesh 3D BINARY 2.0
# CreationDate: Tue Nov  2 11:46:31 2004


nTetrahedra 23685

TetrahedronData { float[3] Data } @1
Field { float[3] f } Constant(@1)

# Data section follows
***********************************************************************************************************************************
ahds: Displaying parsed header data
-----------------------------------------------------------------------------------------------------------------------------------
[{'designation': {'dimension': '3D',
                  'filetype': 'AmiraMesh',
                  'format': 'BINARY',
                  'version': '2.0'}},
 {'comment': {'date': 'Tue Nov  2 11:46:31 2004'}},
 {'array_declarations': [{'array_dimension': 23685,
                          'array_name': 'Tetrahedra'}]},
 {'data_definitions': [{'array_reference': 'Tetrahedra',
                        'data_dimension': 3,
                        'data_index': 1,
                        'data_name': 'Data',
                        'data_type': 'float'},
                       {'array_reference': 'Field',
                        'data_dimension': 3,
                        'data_index': 1,
                        'data_name': 'f',
                        'data_type': 'float',
                        'interpolation_method': 'Constant'}]}]

********************************************************************************************************************************************
AMIRA (R) HEADER AND DATA STREAMS
--------------------------------------------------------------------------------------------------------------------------------------------
+-ahds/data/FieldOnTetraMesh.am                                                                  AmiraFile [is_parent? True ]
|  +-meta                                                                                            Block [is_parent? False]
|  |  +-file: ahds/data/FieldOnTetraMesh.am
|  |  +-header_length: 182
|  |  +-data_streams: 1
|  |  +-streams_loaded: False
|  +-header                                                                                    AmiraHeader [is_parent? True ]
|  |  +-filetype: AmiraMesh
|  |  +-dimension: 3D
|  |  +-format: BINARY
|  |  +-endian: BIG
|  |  +-version: 2.0
|  |  +-extra_format: None
|  |  +-Parameters                                                                                   Block [is_parent? False]
|  |  +-Tetrahedra                                                                                   Block [is_parent? False]
|  |  |  +-length: 23685
|  +-data_streams                                                                                    Block [is_parent? False]
********************************************************************************************************************************************

By default, data streams are not read — only the header is parsed. You may obtain the data streams using the -s/--load-streams flag.

me@home ~$ ahds --load-streams ahds/data/FieldOnTetraMesh.am
********************************************************************************************************************************************
AMIRA (R) HEADER AND DATA STREAMS
--------------------------------------------------------------------------------------------------------------------------------------------
+-ahds/data/FieldOnTetraMesh.am                                                                  AmiraFile [is_parent? True ]
|  +-meta                                                                                            Block [is_parent? False]
|  |  +-file: ahds/data/FieldOnTetraMesh.am
|  |  +-header_length: 182
|  |  +-data_streams: 1
|  |  +-streams_loaded: True
|  +-header                                                                                    AmiraHeader [is_parent? True ]
|  |  +-filetype: AmiraMesh
|  |  +-dimension: 3D
|  |  +-format: BINARY
|  |  +-endian: BIG
|  |  +-version: 2.0
|  |  +-extra_format: None
|  |  +-Parameters                                                                                   Block [is_parent? False]
|  |  +-Tetrahedra                                                                                   Block [is_parent? False]
|  |  |  +-length: 23685
|  +-data_streams                                                                                    Block [is_parent? True ]
|  |  +-Data                                                                           AmiraMeshDataStream [is_parent? False]
|  |  |  +-data_index: 1
|  |  |  +-dimension: 3
|  |  |  +-type: float
|  |  |  +-interpolation_method: None
|  |  |  +-shape: 23685
|  |  |  +-format: None
|  |  |  +-data: [  0.8917308   0.9711809 300.       ],...,[  1.4390504   1.1243758 300.       ]
********************************************************************************************************************************************

Future Plans

  • Write out valid Amira (R) files

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

ahds-0.2.1.dev1.tar.gz (38.8 kB view details)

Uploaded Source

Built Distributions

ahds-0.2.1.dev1-cp37-cp37m-macosx_10_9_x86_64.whl (47.2 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

ahds-0.2.1.dev1-cp27-cp27m-macosx_10_14_intel.whl (47.0 kB view details)

Uploaded CPython 2.7mmacOS 10.14+ Intel (x86-64, i386)

File details

Details for the file ahds-0.2.1.dev1.tar.gz.

File metadata

  • Download URL: ahds-0.2.1.dev1.tar.gz
  • Upload date:
  • Size: 38.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for ahds-0.2.1.dev1.tar.gz
Algorithm Hash digest
SHA256 92ce8e1eaf1a61023ce8b6a84330573b734a0a97dc24a44e362552042be50e18
MD5 a957b27c8012aa674945d68a232bf41b
BLAKE2b-256 5386002fb48498229ae8e4bcc8ed5348d29ffcac4e01c525515f3cff9a72effd

See more details on using hashes here.

File details

Details for the file ahds-0.2.1.dev1-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: ahds-0.2.1.dev1-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 47.2 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for ahds-0.2.1.dev1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b3a818f116f61937753a713768803215f8ffd4ede1dfe6c32ddd7591ce1cf804
MD5 996a562f73dbb59d4e9764642978587a
BLAKE2b-256 9db2b126e98641ed32beb67e5f03c22640a41e1292b82a42fba6fb8e38c1538e

See more details on using hashes here.

File details

Details for the file ahds-0.2.1.dev1-cp27-cp27m-macosx_10_14_intel.whl.

File metadata

  • Download URL: ahds-0.2.1.dev1-cp27-cp27m-macosx_10_14_intel.whl
  • Upload date:
  • Size: 47.0 kB
  • Tags: CPython 2.7m, macOS 10.14+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for ahds-0.2.1.dev1-cp27-cp27m-macosx_10_14_intel.whl
Algorithm Hash digest
SHA256 3aa5459cafbd31705e3a716ea0a718b6272f11611cf991654cac2ffc09696c97
MD5 830a1a8698991e773885a56b96331526
BLAKE2b-256 012ad2ffcc244e7f839887e92fe025558eb7bae1365df463e836f3df761c21f6

See more details on using hashes here.

Supported by

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