changeset 3:be9a815e2240 draft

"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/projective_transformation/ commit ee372547082b693ef1bbe10b5b7ea8660b9779df"
author imgteam
date Thu, 20 Jan 2022 17:14:55 +0000
parents 1ffdb07020ee
children 37b079c98c38
files projective_transformation.py projective_transformation.xml test-data/fixed.png test-data/fixed_rgb.png test-data/moving.png test-data/moving_rgb.png test-data/moving_rgb_warped.png test-data/moving_warped.png test-data/multi_f.tif test-data/multi_m.tif test-data/multi_m_warped.tif test-data/sample1.png test-data/sample2.png test-data/tmat.tsv test-data/warp_matrix.tsv test-data/yam.png
diffstat 16 files changed, 37 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/projective_transformation.py	Fri Jan 14 03:07:08 2022 +0000
+++ b/projective_transformation.py	Thu Jan 20 17:14:55 2022 +0000
@@ -7,7 +7,6 @@
 """
 
 import argparse
-import imghdr
 import warnings
 
 import numpy as np
@@ -50,7 +49,6 @@
 def transform(moving_fn, fixed_fn, warp_mat, output_fn):
 
     moving = skimage.io.imread(moving_fn)
-    extension = imghdr.what(moving_fn)
     nDims = len(moving.shape)
     assert nDims in [2, 3, 4, 5, 6], 'this tool only supports up to 6 dimensions'
 
@@ -96,9 +94,9 @@
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         if isMulCh:
-            tifffile.imwrite(output_fn + '.tif', warped_moving, imagej=True, metadata={'mode': 'composite'})
+            tifffile.imwrite(output_fn, warped_moving, imagej=True, metadata={'mode': 'composite'})
         else:
-            skimage.io.imsave(output_fn + '.' + extension, warped_moving)
+            skimage.io.imsave(output_fn, warped_moving)
 
 
 if __name__ == "__main__":
--- a/projective_transformation.xml	Fri Jan 14 03:07:08 2022 +0000
+++ b/projective_transformation.xml	Thu Jan 20 17:14:55 2022 +0000
@@ -1,5 +1,5 @@
-<tool id="ip_projective_transformation" name="Projective Transformation" version="0.1.0" profile="20.05"> 
-    <description>2D Projective Transformation</description>
+<tool id="ip_projective_transformation" name="Projective Transformation" version="0.1.1" profile="20.05"> 
+    <description>of 2D images</description>
     <requirements>
         <requirement type="package" version="0.18.1">scikit-image</requirement>
         <requirement type="package" version="1.2.4">pandas</requirement>
@@ -9,31 +9,46 @@
     </requirements>
     <command detect_errors="aggressive">
     <![CDATA[
-         python '$__tool_directory__/projective_transformation.py'
-         '$fixed_image'
-         '$moving_image'
-         '$warp_matrix'
-         ./out
+        ln -s '$moving' ./in.${moving.ext} && 
+        python '$__tool_directory__/projective_transformation.py'
+        '$fixed'
+        ./in.${moving.ext}
+        '$tmat'
+        ./out.${moving.ext}
+        && mv ./out.${moving.ext} ./result_image
     ]]>
     </command>
     <inputs>
-        <param name="moving_image" type="data" format="tiff,png,jpg" label="Moving image (to be transformed)" />
-        <param name="fixed_image" type="data" format="tiff,png,jpg" label="Fixed image (the reference)" />
-        <param name="warp_matrix" type="data" format="tabular" label="Transformation matrix" />
+        <param name="moving" type="data" format="tiff,png" label="Moving image (to be transformed)" />
+        <param name="fixed" type="data" format="tiff,png" label="Fixed image (the reference)" />
+        <param name="tmat" type="data" format="tabular" label="Transformation matrix" />
     </inputs>
     <outputs>
-        <data format_source="moving_image" name="warped_image" from_work_dir="out" />
+        <data name="warped" format_source="moving" metadata_source="moving" from_work_dir="result_image" />
     </outputs>
     <tests>
-      <test>
-        <param name="fixed_image" value="sample1.png"/>
-        <param name="moving_image" value="sample2.png"/>
-        <param name="warp_matrix" value="warp_matrix.tsv"/>
-        <output name="warped_image" value="yam.png" ftype="png" compare="sim_size"/>
+        <test>
+            <param name="fixed" value="fixed.png"/>
+            <param name="moving" value="moving.png"/>
+            <param name="tmat" value="tmat.tsv"/>
+            <output name="warped" value="moving_warped.png" ftype="png" compare="sim_size" delta_frac="0.1" />
+        </test>
+        <test>
+            <param name="fixed" value="fixed_rgb.png"/>
+            <param name="moving" value="moving_rgb.png"/>
+            <param name="tmat" value="tmat.tsv"/>
+            <output name="warped" value="moving_rgb_warped.png" ftype="png" compare="sim_size" delta_frac="0.1" />
+        </test>
+        <test>
+            <param name="fixed" value="multi_f.tif"/>
+            <param name="moving" value="multi_m.tif"/>
+            <param name="tmat" value="tmat.tsv"/>
+            <output name="warped" value="multi_m_warped.tif" ftype="tiff" compare="sim_size" delta_frac="0.1" />
       </test>
     </tests>
     <help>
-    **What it does**
+
+**What it does**
 
     This tool performs a projective transformation of the moving image so that it fits the fixed image. 
     Multi-channel and RGB images are supported.
Binary file test-data/fixed.png has changed
Binary file test-data/fixed_rgb.png has changed
Binary file test-data/moving.png has changed
Binary file test-data/moving_rgb.png has changed
Binary file test-data/moving_rgb_warped.png has changed
Binary file test-data/moving_warped.png has changed
Binary file test-data/multi_f.tif has changed
Binary file test-data/multi_m.tif has changed
Binary file test-data/multi_m_warped.tif has changed
Binary file test-data/sample1.png has changed
Binary file test-data/sample2.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/tmat.tsv	Thu Jan 20 17:14:55 2022 +0000
@@ -0,0 +1,3 @@
+0.9406756518941536	-0.2954926628589712	45.11224440565029
+0.3009254584199789	0.949530052611427	-32.079361599470666
+0.0	0.0	1.0
--- a/test-data/warp_matrix.tsv	Fri Jan 14 03:07:08 2022 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-1	0	10
-0	1	20
-0	0	1
Binary file test-data/yam.png has changed