diff rename_tiff_channels.xml @ 5:61fd94c7ce42 draft

planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit bc438db690e41823909b32b693f297d942433a43
author goeckslab
date Thu, 11 Jul 2024 22:41:10 +0000
parents d2c59a1ac0c4
children 4763362914f4
line wrap: on
line diff
--- a/rename_tiff_channels.xml	Fri May 10 21:01:32 2024 +0000
+++ b/rename_tiff_channels.xml	Thu Jul 11 22:41:10 2024 +0000
@@ -33,11 +33,27 @@
 import os
 import sys 
 import argparse
+from itertools import cycle
 import pandas as pd
 import ome_types
-from ome_types.model import channel
+from ome_types.model import channel, Color
 from tifffile import tiffcomment
 
+# setting default colors to match avivator
+colors = [
+    (0,0,255,1.0),     # blue
+    (0,255,0,1.0),     # green
+    (255,0,255,1.0),   # magenta
+    (255,255,0,1.0),   # yellow
+    (255,127,0,1.0),   # orange
+    (0,255,255,1.0),   # cyan
+    (255,255,255,1.0), # white
+    (255,0,0,1.0)      # red
+]
+
+# convert to repeatable object of primitive int colors 
+color_cycle = cycle([Color(c).as_int32() for c in colors])
+
 cwd = os.getcwd()
 
 channels_df = pd.read_csv(os.path.join(cwd, 'channels.csv'))
@@ -51,6 +67,7 @@
 
         new_name = channels_df.loc[c_idx, 'marker_name']
         channel.name = new_name
+        channel.color = next(color_cycle)
 
         if l_idx == 0:
 
@@ -72,11 +89,11 @@
     </outputs>
     <tests>
         <test>
-            <param name="image" value="rename_test.tiff" />
+            <param name="image" value="rename_test.ome.tiff" />
             <param name="channel_csv" value="rename_channels.csv" />
             <output name="renamed_image" ftype="ome.tiff">
                 <assert_contents>
-                    <has_size value="44000" delta="1000" />
+                    <has_size value="899000" delta="50000" />
                 </assert_contents>
             </output>
             <assert_stdout>