tsio: A command line utility for extracting images from microscopy-related files
A Command Line Interface (CLI) application for extracting images from microscopy files to common image file formats, such as JPEG, PNT, and/or TIFF. Supported microscopy files include:
- dcm (DICOM) - medical image file format standard
- dm3/dm4 (DigitalMicrograph) - (S)TEM image file format by GATAN
- emd (Velox) - (S)TEM image file format by ThermoFisher
Prerequisites
All of the prerequisites may already be installed and configured by the superuser, a.k.a. root, of the computer. The prerequisites only need to be installed and configured once per machine.
Python
The Python programming language is needed to run the tsio Command Line
Interface (CLI) application and/or use in other Python scripts. Both macOS
and Ubuntu Linux have the Python programming language installed, but it is
generally reserved for the operating system (OS) to use and is an older
version. It is best practice to install a newer version that is separate from
the system-provided Python version.
Ubuntu
-
Add the "deadsnakes" Ubuntu Personal Package Archives (PPA).
sudo add-apt-repository ppa:deadsnakes/ppa
-
Obtain the latest packages from the PPA.
sudo update -
Install Python v3.11 or newer.
sudo apt install python3.11
-
Install the
venvpackage.sudo apt install python3.11-venv
macOS
-
Install Homebrew if it is not already installed.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Install Python v3.11 or newer.
brew install python@3.11
pipx
The pipx utility enables distribution of Python-based CLI applications, like
tsio, to be installed for all users with all of the appropriate dependencies
within an isolated environment. It is the recommended installation for the
tsio application.
Ubuntu
-
Create a virtual environment for
pipxand Python v3.11 or newer.sudo python3.11 -m venv --upgrade-deps /opt/pipx
-
Install
pipxfor all users.sudo /opt/pipx/bin/pip install pipx
-
Ensure the
pipxcommand is available to all users.sudo ln -s /opt/pipx/bin/pipx /usr/local/bin/pipx
-
Add
pipxto thePATHenvironment variable.pipx ensurepath -
Add
pipxfor all users.sudo pipx ensurepath --global
Post-installation, the pipx application can be upgraded with the following
command:
sudo /opt/pipx/bin/pip install --upgrade pipx
macOS
-
Install
pipxusing Homebrew.brew install pipx
-
Add
pipxto thePATHenvironment variable.pipx ensurepath -
Add
pipxfor all users.sudo pipx ensurepath --global
Post-installation, the pipx application can be upgraded with the following
command:
brew update && brew upgrade pipx
Installation
The tsio code includes a Python application with a Command Line Interface
(CLI). It can be installed as a standalone application.
pipx (recommended)
-
Obtain a package key from Theia Scientific personnel. Save it for Step 3.
-
Ensure
pipxis installed. See the Prerequisites.$ pipx --version 1.9.0
-
Install
tsiocommand globally for all users.sudo pipx install --global --python python3.11 "tsio"
-
Verify
tsiocommand is available.$ tsio --version tsio 0.1.0
Source
-
Clone the tsio repository.
git clone https://github.com/Theia-Scientific/tsio.git && cd tsio
-
Create a virtual environment.
python3.11 -m venv .venv
-
Activate the virtual environment.
source .venv/bin/activate
or if direnv is installed:
cp .envrc.example .envrc
followed by:
direnv allow -
Upgrade
pipto the latest version.pip install --upgrade pip
-
Locally install the package, utility, and its dependencies. This will create the
tsiocommand within the virtual environment. This also installs the Slack feature for sending notifications to a Slack channel.pip install -e .
Upgrade
pipx (recommended)
-
Upgrade the
tsioapplication viapipx.sudo pipx upgrade --global tsio
-
Verify new version.
$ tsio --version tsio 0.1.0
Source
-
Navigate to the root of the source tree.
cd ~/Code/tsio
-
Activate the virtual environment.
source .venv/bin/activate
or if direnv is installed, the virtual environment will automatically be activated.
-
Pull the latest changes on
main.git pull -
Upgrade the
tsioapplication within the virtual environment.pip install --upgrade -e .
-
Verify new version.
$ tsio --version tsio 0.1.0
Usage
Convert a single page TIFF to a JPEG. Creating a JPEG image file is the default because this is useful for Machine Learning (ML) tools, supported by all web browsers, and it creates the smallest file, making this the quickest for obtaining a thumbnail of the microscopy image file.
$ tsio image.tif
$ ls
image.jpg image.tif
Convert a single page TIFF to a PNG. All of the following commands are equivalent.
# Use the long option.
$ tsio --to png image.tif
$ ls
image.png image.tif
# Use the `=` syntax for specifying an option value.
$ tsio --to=png image.tif
$ ls
image.png image.tif
# Use the short option.
$ tsio -t png image.tif
$ ls
image.png image.tif
# Use the short option with the `=` syntax.
$ tsio -t=png image.tif
$ ls
image.png image.tif
Extract all the "frames" from a multi-page TIFF.
$ tsio multi-page.tif
$ ls
multi-page/ multi-page.tif
$ ls multi-page/
0.jpg 1.jpg 2.jpg 3.jpg 4.jpg
# Use the `-o,--output` option to extract to different location.
$ tsio --output /path/to/directory tiff png multi-page.tif
$ ls
multi-page.tif
$ ls /path/to/directory
0.jpg 1.jpg 2.jpg 3.jpg 4.jpg
Extract an image from a DM3 or DM4 file.
$ tsio ./00001.dm3
$ ls
00001.dm3 00001.jpg
$ tsio ./00001.dm4
$ ls
00001.dm4 00001.jpg
Extract all the "frames" from a EMD file.
$ tsio multiple-frames.emd
$ ls
multiple-frames/ multiple-frames.emd
$ ls multiple-frames/
0.jpg 1.jpg 2.jpg 3.jpg 4.jpg
Contributing
-
Clone this repository.
git clone https://github.com/Theia-Scientific/tsio && cd tsio
-
Create a virtual environment.
python3.11 -m venv .venv
-
Activate the virtual environment.
source .venv/bin/activate
or if direnv is installed, the virtual environment will automatically be activated.
-
Upgrade
pip.pip install --upgrade pip
-
Install all the dependencies.
pip install -e ".[dev]"
-
Create a local branch.
git checkout -b feature-awesome-new-feature
-
Modify the code.
-
Run the tests.
pytest --color=yes --cov=tsio --cov-report=term-missing
-
Commit changes to your local branch.
git add -A && git commit -m "Add new feature"
-
Push your local branch to GitHub to create a Pull Request (PR).
git push origin feature-awesome-new-feature
-
Create a Pull Request (PR) in GitHub.
-
Wait for CI to complete.
-
Add comment to PR that it is ready to review.
-
Wait for review from a maintainer.
-
Address any comments from the reviewer by modifying your local files and pushing to the remote branch/PR.
git push origin feature-awesome-new-feature
-
Once the PR is approved, then it will be "Squash and Merge". Congratulations on contributing to an open source project, and Thank you!
License
The tsio project is licensed under the GPL-3.0 license. See the
LICENSE.txt file for more information about licensing and copyright.
Acknowledgments
This material is based upon work supported by the U.S. Department of Energy, Office of Basic Science and Office of Nuclear Energy under Award Number DE-SC0021529 and DE-SC0021936, respectively.
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 tsio-1.0.0.tar.gz.
File metadata
- Download URL: tsio-1.0.0.tar.gz
- Upload date:
- Size: 695.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fefc3b8c525f20d705cbe4618e013f523677cb7bb12df5c983e47eb216e849a1
|
|
| MD5 |
050c079527a1cdd09cf70e1852670934
|
|
| BLAKE2b-256 |
3467fc12de6d4aced274bd40e7cc0bf36f51e48b997253e67e019aa2c95aaeb8
|
Provenance
The following attestation bundles were made for tsio-1.0.0.tar.gz:
Publisher:
publish.yml on Theia-Scientific/tsio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tsio-1.0.0.tar.gz -
Subject digest:
fefc3b8c525f20d705cbe4618e013f523677cb7bb12df5c983e47eb216e849a1 - Sigstore transparency entry: 2712298828
- Sigstore integration time:
-
Permalink:
Theia-Scientific/tsio@06301d19dee3882879e3a82e5dc51eda70fd9abe -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Theia-Scientific
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@06301d19dee3882879e3a82e5dc51eda70fd9abe -
Trigger Event:
push
-
Statement type:
File details
Details for the file tsio-1.0.0-py3-none-any.whl.
File metadata
- Download URL: tsio-1.0.0-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
416d50d6f26a8cd6285ae7c422c3ded9d05c1f79435a05fadfabea9af6cb69ea
|
|
| MD5 |
b3f6a1b606c9f2324d4e98439c9e0db8
|
|
| BLAKE2b-256 |
e912fae57acb116775e11b1e47bf11b38a939c58c9a8459e32b1b9cd7db9cd78
|
Provenance
The following attestation bundles were made for tsio-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on Theia-Scientific/tsio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tsio-1.0.0-py3-none-any.whl -
Subject digest:
416d50d6f26a8cd6285ae7c422c3ded9d05c1f79435a05fadfabea9af6cb69ea - Sigstore transparency entry: 2712299606
- Sigstore integration time:
-
Permalink:
Theia-Scientific/tsio@06301d19dee3882879e3a82e5dc51eda70fd9abe -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Theia-Scientific
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@06301d19dee3882879e3a82e5dc51eda70fd9abe -
Trigger Event:
push
-
Statement type: