Pyterse
Python package of TERSE/PROLIX diffraction and cryo-EM data compression algorithm
The pyterse python package uses the c++ TERSE/PROLIX(TRPX) compression algorithm scheme (https://github.com/senikm/trpx) and adds python binders to it's main class.
Before you consider pyterse
- Your data is signed or unsigned integral type.
- Your data is grayscale.
- Preferably has high dynamic range.
How to install the package
Create a virtual environment
conda create -n pyterse python pip numpy pillow
Install the package
pip install pyterse
Testing the functionality of the library
Basic commands
from pyterse import Terse
terse = Terse()
terse = Terse(data)
terse = Terse(data, data.size, block_size)
- Example:
terse = Terse(data, 512* 512, 12)
- Add additional entry to Terse object:
terse.push_back(data)
- Save compressed data to a file:
terse.save('filename.trpx')
- Load compressed data from a file:
loaded_terse = Terse.load('filename.trpx')
decompressed_frame = loaded_terse.prolix()
- Decompress a specific entry:
decompressed_frame = loaded_terse.prolix(n)
- Add and retrieve metadata to the terse object:
terse.set_attribute('distance', '487.0')
terse.get_attribute('distance')
terse.get_attributes()