Commit c7d5ca9e authored by Christoph Sommer's avatar Christoph Sommer

Initial commit

parents
# Images #
############
*.tif
*.tiff
*.pyc
*.gif
*.pdf
*.png
*.lsm
*.czi
*.jpg
*.jpeg
*.ims
*.h5
*.hdf5
*.ilp
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
*.sql
*.sqlite
*.csv
*.txt
*.xlsx
*.xls
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
This diff is collapsed.
include README.md
include requirements.txt
include LICENSE
include demo/*.tif
include bf_template_match/*.py
include bf_template_match_run.py
# convert_ometiff
Convert multi-file OME-Tiff files produced at Open-SPIM microscope to ImageJ hyper-stacks
## Installation
---
1. Recommended: download and install Python 3.6 using the Anaconda python distribution
from https://www.anaconda.com/download/. Anaconda already comes with
most of the required packages.
2. Download convert_ometiff and/or extract the convert_ometiff package to path/to/dir
3. Open (Anaconda) prompt and type
```
cd path/to/dir
```
4. Install additional requirements
```
pip install -r requirements.txt
```
5. Install the bf_template_match package
```
python setup.py install
```
6. Quick test
```
convert_ometiff --help
```
If all went fine, the command line help is displayedco
# -*- coding: utf-8 -*-
"""convert_ometiff.__main__: executed when convert_ometiff directory is called as script."""
from .convert_ometiff import main
main()
\ No newline at end of file
import os
import re
import sys
import glob
import numpy
import argparse
import tifffile
import warnings
warnings.filterwarnings("ignore")
__author__ = "christoph.sommer@ist.ac.at"
__licence__ = "GPLv3"
__version__ = "0.1.0"
description = \
"""
Convert multi-file OME-Tiff files produced at Open-SPIM microscope to ImageJ hyper-stacks
"""
pat = r'spim_dataset_CH_(?P<channel>.+)_TL(?P<frame>.+)_Angle0.ome.tiff'
def get_args():
parser = argparse.ArgumentParser(
description=description)
parser.add_argument('input_folders', type=str, nargs='+', help="List of input folders containing OME-Tiff files")
return parser.parse_args()
def convert(in_dir):
assert os.path.exists(in_dir), "Folder does not exist '{}'".format(in_dir)
ome_fns = glob.glob(os.path.join(in_dir, "*.ome.tiff"))
assert len(ome_fns) > 0, "No ome.tiff files found in {}'".format(in_dir)
# read first for spatial dims from frist file
tmp = tifffile.imread(ome_fns[0], is_ome=False)
dtype = tmp.dtype
z, y, x = tmp.shape
channel_set = set()
frame_set = set()
fn_lkp = {}
for fn in ome_fns:
fn_base = os.path.basename(fn)
match = re.search(pat, fn_base)
groupdict = match.groupdict()
channel = groupdict["channel"]
frame = groupdict["frame"]
fn_lkp[(channel, frame)] = fn
channel_set.add(channel)
frame_set.add(frame)
out_hyper = numpy.zeros((len(frame_set), z, len(channel_set), y, x), dtype=dtype)
print("Output shape TZCYX", out_hyper.shape)
for c, channel in enumerate(sorted(channel_set)):
for f, frame in enumerate(sorted(frame_set, key=lambda t: int(t))):
print("Reading", fn_lkp[(channel, frame)], c, f)
tmp = tifffile.imread(fn_lkp[(channel, frame)], is_ome=False)
out_hyper[f, :, c, :, :] = tmp
out_fn = "Resaved.tif"
print("Resaving to", out_fn)
tifffile.imsave(os.path.join(in_dir, out_fn), out_hyper, imagej=True)
def main():
args = get_args()
for in_dir in args.input_folders:
convert(in_dir)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Convenience wrapper for running bf_template_match directly from source tree."""
from convert_ometiff.convert_ometiff import main
if __name__ == '__main__':
main()
\ No newline at end of file
# -*- coding: utf-8 -*-
"""setup.py: setuptools control."""
import re
from setuptools import setup
version = re.search(
'^__version__\s*=\s*"(.*)"',
open('convert_ometiff/convert_ometiff.py').read(),
re.M
).group(1)
with open("README.md", "rb") as f:
long_descr = f.read().decode("utf-8")
description = \
"""
Convert multi-file OME-Tiff files produced at Open-SPIM microscope to ImageJ hyper-stacks
"""
setup(
name = "convert_ometiff",
packages = ["convert_ometiff"],
entry_points = {
"console_scripts": ['convert_ometiff = convert_ometiff.convert_ometiff:main']
},
version = version,
description = description,
long_description = long_descr,
author = "Christoph Sommer",
author_email = "christoph.sommer@gmail.com",
)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment