# HG changeset patch # User iuc # Date 1586874445 14400 # Node ID 17b1cd0f4812e6aede67ab0730c80b139cd4c478 # Parent 9340cbc7796c8236c6ba06d42af40f1304a5be8b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 7d7d50f41a9da71b0f45f8b710e52696689a8d85" diff -r 9340cbc7796c -r 17b1cd0f4812 idr_download_by_ids.py --- a/idr_download_by_ids.py Tue Mar 24 13:48:46 2020 -0400 +++ b/idr_download_by_ids.py Tue Apr 14 10:27:25 2020 -0400 @@ -2,7 +2,7 @@ import os import sys -from matplotlib import pyplot as plt +from libtiff import TIFF from omero.gateway import BlitzGateway # noqa from omero.constants.namespaces import NSBULKANNOTATIONS # noqa @@ -17,8 +17,8 @@ def find_channel_index(image, channel_name): channel_name = channel_name.lower() - for n, channel in enumerate(image.getChannels()): - if channel_name == channel.getLabel().lower(): + for n, channel in enumerate(image.getChannelLabels()): + if channel_name == channel.lower(): return n # Check map annotation for information (this is necessary for some images) for ann in image.listAnnotations(NSBULKANNOTATIONS): @@ -82,11 +82,21 @@ def download_plane_as_tiff(image, tile, z, c, t, fname): pixels = image.getPrimaryPixels() - selection = pixels.getTile(theZ=z, theT=t, theC=c, tile=tile) + try: + selection = pixels.getTile(theZ=z, theT=t, theC=c, tile=tile) + except Exception: + warning = '{0} (ID: {1})'.format(image.getName(), + image.getId()) + warn('Could not download the requested region', warning) + return if fname[-5:] != '.tiff': fname += '.tiff' - plt.imsave(fname, selection) + try: + tiff = TIFF.open(fname, mode='w') + tiff.write_image(selection) + finally: + tiff.close() def download_image_data( @@ -182,7 +192,7 @@ ) else: channel_index = find_channel_index(image, channel) - if channel_index == -1: + if channel_index == -1 or channel_index >= image.getSizeC(): raise ValueError( '"{0}" is not a known channel name for image {1}' .format(channel, image.getName()) diff -r 9340cbc7796c -r 17b1cd0f4812 idr_download_by_ids.xml --- a/idr_download_by_ids.xml Tue Mar 24 13:48:46 2020 -0400 +++ b/idr_download_by_ids.xml Tue Apr 14 10:27:25 2020 -0400 @@ -1,5 +1,5 @@ - + - download images from the Image Data Resource using image IDs @@ -17,7 +17,7 @@ python-omero - matplotlib + pylibtiff - + @@ -191,7 +191,7 @@ - + diff -r 9340cbc7796c -r 17b1cd0f4812 test-data/test1.tiff Binary file test-data/test1.tiff has changed