Skip to content

Commit

Permalink
Merge pull request #2 from starcalibre/dib-support
Browse files Browse the repository at this point in the history
Add support for DIB files and large data sets
  • Loading branch information
jni committed Mar 23, 2015
2 parents cba2f68 + 9983738 commit b96f86c
Show file tree
Hide file tree
Showing 57 changed files with 45 additions and 8 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cellom2tif
==========

Python script to convert Cellomics .C01 files to TIFF.
Python script to convert Cellomics files to TIFF.

Read the BioFormats [report card for Cellomics
files](https://www.openmicroscopy.org/site/support/bio-formats5/formats/cellomics.html).
Expand Down Expand Up @@ -37,17 +37,18 @@ GPL* by the import of Python BioFormats. Consult your lawyer.
$ cellom2tif -h
usage: cellom2tif [-h] [-E FILENAME] [-m] [-v] root_path out_path
Convert a bunch of Cellomics .C01 files to TIFFs.
Convert a bunch of Cellomics files to TIFFs. Currently supports the .CO1 and
.DIB format.
positional arguments:
root_path The path containing .C01 files
root_path The path containing the Cellomics files
out_path The path to output the TIFFs.
optional arguments:
-h, --help show this help message and exit
-E FILENAME, --error-file FILENAME
Log problem filenames to the given filename.
-m, --ignore-masks Ignore files ending in "o1.C01".
-m, --ignore-masks Ignore files ending in "o1".
-v, --verbose Print out runtime information.
```

Expand Down
1 change: 1 addition & 0 deletions cellom2tif/cellom2tif.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def read_image(filelike):
else:
rdr = bf.ImageReader(filelike)
image = rdr.read(rescale=False)
rdr.close()
return image


Expand Down
43 changes: 39 additions & 4 deletions cellom2tif/filetypes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
import os


def has_extension(filename, ext):
"""
Determine whether a file has a particular extension.
Parameters
----------
filename : string
The filename of the query file.
ext : string
The extension being checked.
Returns
-------
file_has_ext : bool
True if the filename has the specified extension.
Examples
--------
>>> dib_file = 'AS_09125_050116110001_A01f00d0.DIB'
>>> has_extension(dib_file, 'dib')
True
"""
fn_ext = os.path.splitext(filename)[1][1:]
file_has_ext = fn_ext.lower() == ext.lower()
return file_has_ext


def is_cellomics_image(fn):
"""Determine whether a file is a Cellomics image.
Expand All @@ -11,7 +41,7 @@ def is_cellomics_image(fn):
is_cellom : bool
True if the filename points to a Cellomics image.
"""
is_cellom = fn.endswith('.C01') or fn.endswith('.c01')
is_cellom = has_extension(fn, 'C01') or has_extension(fn, 'DIB')
return is_cellom


Expand All @@ -27,8 +57,13 @@ def is_cellomics_mask(fn):
-------
is_mask : bool
True if the filename points to a Cellomics mask image.
Examples
--------
>>> mask_fn = 'MFGTMP_120628160001_C18f00o1.C01'
>>> is_cellomics_mask(mask_fn)
True
"""
is_mask = fn.endswith('o1.C01') or fn.endswith('o1.c01')
base_fn = os.path.splitext(fn)[0]
is_mask = base_fn.endswith('o1') or base_fn.endswith('o1')
return is_mask


Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f00d0.DIB
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f00d1.DIB
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f00d2.DIB
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f01d0.DIB
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f01d1.DIB
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f01d2.DIB
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f02d0.DIB
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f02d1.DIB
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f02d2.DIB
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f03d0.DIB
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f03d1.DIB
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f03d2.DIB
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f04d0.DIB
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f04d1.DIB
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f04d2.DIB
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f05d0.DIB
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f05d1.DIB
Binary file not shown.
Binary file added test-data/d3/AS_09125_050116110001_A01f05d2.DIB
Binary file not shown.

0 comments on commit b96f86c

Please sign in to comment.