Skip to content

Commit

Permalink
update version, add tests for ome.tiff and pyramid
Browse files Browse the repository at this point in the history
  • Loading branch information
alliecreason committed Sep 8, 2022
1 parent 6d6a6fd commit 694ef74
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 12 deletions.
11 changes: 11 additions & 0 deletions tools/bfconvert/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM ubuntu:20.04

RUN apt-get update && \
ln -snf /usr/share/zoneinfo/$CONTAINER_TIMEZONE /etc/localtime && echo $CONTAINER_TIMEZONE > /etc/timezone

RUN apt-get update && \
apt-get install -y curl git openjdk-8-jdk unzip wget

RUN wget https://downloads.openmicroscopy.org/bio-formats/6.7.0/artifacts/bftools.zip && \
unzip bftools.zip && \
cp bftools/* /usr/local/bin/
63 changes: 51 additions & 12 deletions tools/bfconvert/bfconvert.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,45 @@
<tool id="ip_convertimage" name="Convert image" version="0.4">
<tool id="ip_convertimage" name="Convert image" version="6.7.0.5">
<description>Convert image</description>
<requirements>
<requirement type="package" version="5.7.1">bftools</requirement>
<requirement type="package" version="6.7.0">bftools</requirement>
<container type="docker">quay.io/goeckslab/bftools:6.7.0</container>
</requirements>
<command>
<![CDATA[
bfconvert
#if $series_options['extract'] == 'True'
-series $series
-series $series_options.series
#end if
#if $timepoint_options['extract'] == 'True'
-timepoint $timepoint
-timepoint $timepoint_options.timepoint
#end if
#if $channel_options['extract'] == 'True'
-channel $channel
-channel $channel_options.channel
#end if
#if $z_options['extract'] == 'True'
-z $z
-z $z_options.z
#end if
#if $range_options['extract'] == 'True'
-range $range_lower $range_upper
-range $range_options.range_lower $range_options.range_upper
#end if
#if $crop_options['extract'] == 'True'
-crop $crop_x $crop_y $crop_width $crop_height
-crop "$crop_options.crop_x,$crop_options.crop_y,$crop_options.crop_width,$crop_options.crop_height"
#end if
#if $tile_options['extract'] == 'True'
-tilex $tile_x -tiley $tile_y
-tilex $tile_options.tile_x -tiley $tile_options.tile_y
#end if
'$input_file' ./res.$out_format &&
mv ./res.$out_format ./result_image
#if $pyramid_options['generate'] == 'True'
-pyramid-resolutions $pyramid_options.pyramid_resolutions
-pyramid-scale $pyramid_options.pyramid_scale
#end if
$bigtiff
$noflat
#if $compression != 'False'
-compression $compression
#end if
'$input_file' './res.$out_format' &&
mv './res.$out_format' './result_image' &&
ls -lh
]]>
</command>
<inputs>
Expand Down Expand Up @@ -118,14 +129,34 @@
<param name="tile_y" type="integer" value="512 " label="Tile height" />
</when>
</conditional>
<conditional name="pyramid_options">
<param label="Pyramid image" name="generate" type="select">
<option selected="True" value="True">Generate Pyramid</option>

This comment has been minimized.

Copy link
@kostrykin

kostrykin Aug 12, 2023

Member

@alliecreason Any specific reason why you decided to make Pyramid image active by default, instead of No Pyramid? When converting an image to PNG that way, by default, the resulting image cannot be viewed inside Galaxy (at least when converting from TIFF).

This comment has been minimized.

Copy link
@alliecreason

alliecreason Aug 12, 2023

Author Contributor

Within the bioformats community that developed bfconvert, converting an image to ome-tif is one of the more common uses for this tool, and having a pyramid built is considered best practice. For really large images, the pyramid makes viewing substantially easier for a user.

Agree having the pyramid when converting to a png is not recommended.

This comment has been minimized.

Copy link
@kostrykin

kostrykin Aug 12, 2023

Member

@alliecreason Thanks for the insights. Do you agree, then, that a more convenient solution would be to add an option Default or Automatic for pyramid_options, which would be translated to either Generate Pyramid or No Pyramid based on the format of the input and the output?

If you agree, I would make the necessary changes.

This comment has been minimized.

Copy link
@alliecreason

alliecreason Aug 12, 2023

Author Contributor

That seems fine as long as pyramid is linked to the supported formats: https://docs.openmicroscopy.org/bio-formats/6.7.0/supported-formats.html. I could also see other options being based on specific formats, such as noflat and bigtiff.

This comment has been minimized.

Copy link
@kostrykin

kostrykin Aug 12, 2023

Member

@alliecreason Thanks for the link. As far as I see, PNG doesn't support pyramids at all? Thus, instead of providing an additional option like Default or Automatic for pyramid_options, it would be better to force pyramid_options to No Pyramid if out_format is set to PNG (or another format which does not support pyramids), wouldn't it?

This comment has been minimized.

Copy link
@kostrykin

kostrykin Aug 12, 2023

Member

@alliecreason I have drafted a PR, please let me know what you think: #69

<option value="False">No Pyramid</option>
</param>
<when value="True">
<param name="pyramid_resolutions" type="integer" value="4" label="Pyramid Resolutions"/>
<param name="pyramid_scale" type="integer" value="2" label="Pyramid Scale" />
</when>
</conditional>
<param name="bigtiff" label="Big TIFF" type="boolean" checked="false" truevalue="-bigtiff" falsevalue=""/>
<param name="noflat" label="No Flatten" type="boolean" checked="true" truevalue="-noflat" falsevalue=""/>
<param label="Compression" name="compression" type="select">
<option selected="True" value="False">No Compression</option>
<option value="LZW">LZW</option>
<option value="JPEG-2000">JPEG-2000</option>
<option value="JPEG-2000 Lossy">JPEG-2000 Lossy</option>
<option value="JPEG">JPEG</option>
<option value="zlib">zlib</option>
</param>
</inputs>
<outputs>
<data format="tiff" name="output" from_work_dir="result_image">
<change_format>
<when input="out_format" value="tiff" format="tiff" />
<when input="out_format" value="png" format="png" />
<when input="out_format" value="jpg" format="jpg" />
<when input="out_format" value="ome.tiff" format="tiff" />
<when input="out_format" value="ome.tiff" format="ome.tiff" />
<when input="out_format" value="jp2" format="jpg" />
<when input="out_format" value="eps" format="eps" />
<when input="out_format" value="avi" format="avi" />
Expand All @@ -138,6 +169,14 @@
<param name="out_format" value="tiff" />
<output name="output" value="res.tiff" ftype="tiff" compare="sim_size"/>
</test>
<test>
<param name="input_file" value="input.png" />
<param name="out_format" value="ome.tiff" />
<param name="pyramid_options.generate" value="True"/>
<param name="pyramid_options.pyramid_resolutions" value="4"/>
<param name="pyramid_options.pyramid_scale" value="2"/>
<output name="output" value="res.ome.tiff" ftype="ome.tiff" compare="sim_size"/>
</test>
</tests>
<help>
**What it does**
Expand Down
Binary file added tools/bfconvert/test-data/res.ome.tiff
Binary file not shown.

0 comments on commit 694ef74

Please sign in to comment.