changeset 4:00175f4a2bbb draft default tip

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/coordinates_of_roi/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
author imgteam
date Mon, 13 Nov 2023 22:10:52 +0000
parents 02a686fc1654
children
files coordinates_of_roi.py coordinates_of_roi.xml
diffstat 2 files changed, 31 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/coordinates_of_roi.py	Mon Mar 25 11:15:39 2019 -0400
+++ b/coordinates_of_roi.py	Mon Nov 13 22:10:52 2023 +0000
@@ -1,10 +1,11 @@
 import argparse
+
 import pandas as pd
-import skimage.io
 import skimage.color
-import warnings
+import skimage.io
 
-def get_pixel_values(im, pixel_table, white_obj, threshold, offset=[0,0]):
+
+def get_pixel_values(im, pixel_table, white_obj, threshold, offset=[0, 0]):
     data = skimage.io.imread(im)
     if len(data.shape) == 3 and data.shape[-1] > 1:
         data = skimage.color.rgb2grey(data)
@@ -14,27 +15,26 @@
     img_width = data.shape[1]
     for j in range(img_width):
         for i in range(img_height):
-            if white_obj == False: 
-                if data[i,j] <= threshold:
+            if not white_obj:
+                if data[i, j] <= threshold:
                     x.append(i + offset[0])
                     y.append(j + offset[1])
-            elif data[i,j] >= threshold:
-                    x.append(i + offset[0])
-                    y.append(j + offset[1])
-                    
+            elif data[i, j] >= threshold:
+                x.append(i + offset[0])
+                y.append(j + offset[1])
+
     df = pd.DataFrame()
     df['x'] = x
     df['y'] = y
-    df.to_csv(pixel_table, sep="\t", index = False)
-                     
-if __name__=="__main__":
-    parser = argparse.ArgumentParser(description = "Create a csv table with Coordinates of the ROI")
-    parser.add_argument("im", help = "Paste path to out.png (output created by transformation)")
-    parser.add_argument("pixel_table", help = "Paste path to file in which list with all pixles > threshold should be saved")
-    parser.add_argument("--white_obj", dest = "white_obj", default=False, help = "If set objects in image are white otherwise black", action = "store_true")
-    parser.add_argument("--threshold", dest = "threshold", default = 0.5, help = "Enter desired threshold value", type = float)
-    
-    args = parser.parse_args()  
-    # with warnings.catch_warnings():
-	#     warnings.simplefilter("ignore") 
-    get_pixel_values(args.im, args.pixel_table, args.white_obj, args.threshold)     
+    df.to_csv(pixel_table, sep="\t", index=False)
+
+
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser(description="Create a csv table with Coordinates of the ROI")
+    parser.add_argument("im", help="Paste path to out.png (output created by transformation)")
+    parser.add_argument("pixel_table", help="Paste path to file in which list with all pixles > threshold should be saved")
+    parser.add_argument("--white_obj", dest="white_obj", default=False, help="If set objects in image are white otherwise black", action="store_true")
+    parser.add_argument("--threshold", dest="threshold", default=0.5, help="Enter desired threshold value", type=float)
+
+    args = parser.parse_args()
+    get_pixel_values(args.im, args.pixel_table, args.white_obj, args.threshold)
--- a/coordinates_of_roi.xml	Mon Mar 25 11:15:39 2019 -0400
+++ b/coordinates_of_roi.xml	Mon Nov 13 22:10:52 2023 +0000
@@ -1,14 +1,21 @@
-<tool id="ip_coordinates_of_roi" name="Coordinates of ROI" version="0.0.4">
+<tool id="ip_coordinates_of_roi" name="Convert binary image to points (point coordinates)" version="0.0.4-2">
     <description></description>
+    <edam_operations>
+        <edam_operation>operation_3443</edam_operation>
+    </edam_operations>
+    <xrefs>
+        <xref type="bio.tools">galaxy_image_analysis</xref>
+    </xrefs>
     <requirements>
         <requirement type="package" version="0.14.2">scikit-image</requirement>
         <requirement type="package" version="0.23.4">pandas</requirement>
+        <requirement type="package" version="0.15.1">tifffile</requirement>
     </requirements>
     <command detect_errors="aggressive">
         <![CDATA[
             python '$__tool_directory__/coordinates_of_roi.py'
             '$im'
-            '$pixel_table'
+            '$pixel_table' 
             $white_obj
             --threshold $threshold
         ]]>