comparison rename_tiff_channels.xml @ 6:4763362914f4 draft default tip

planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 5c324d06ad54dca76aa2b4c8118df5654f49da66
author goeckslab
date Mon, 15 Jul 2024 21:37:39 +0000
parents 61fd94c7ce42
children
comparison
equal deleted inserted replaced
5:61fd94c7ce42 6:4763362914f4
57 cwd = os.getcwd() 57 cwd = os.getcwd()
58 58
59 channels_df = pd.read_csv(os.path.join(cwd, 'channels.csv')) 59 channels_df = pd.read_csv(os.path.join(cwd, 'channels.csv'))
60 60
61 original_ome_xml = tiffcomment(os.path.join(cwd, 'renamed_image.ome.tiff')) 61 original_ome_xml = tiffcomment(os.path.join(cwd, 'renamed_image.ome.tiff'))
62 working_ome = ome_types.from_xml(original_ome_xml, parser = 'lxml') 62 working_ome = ome_types.from_xml(original_ome_xml)
63 63
64 for l_idx, level in enumerate(working_ome.images): 64 for l_idx, level in enumerate(working_ome.images):
65 65
66 for c_idx, channel in enumerate(level.pixels.channels): 66 for c_idx, channel in enumerate(level.pixels.channels):
67 67
71 71
72 if l_idx == 0: 72 if l_idx == 0:
73 73
74 print(f"Channel {c_idx} renamed to {new_name}") 74 print(f"Channel {c_idx} renamed to {new_name}")
75 75
76 updated_ome_xml = working_ome.to_xml() 76 updated_ome_xml = working_ome.to_xml().encode()
77 tiffcomment(os.path.join(cwd, 'renamed_image.ome.tiff'), updated_ome_xml) 77 tiffcomment(os.path.join(cwd, 'renamed_image.ome.tiff'), updated_ome_xml)
78 78
79 print("Updated OME-TIFF metadata:") 79 print("Updated OME-TIFF metadata:")
80 print(tiffcomment(os.path.join(cwd, 'renamed_image.ome.tiff'))) 80 print(tiffcomment(os.path.join(cwd, 'renamed_image.ome.tiff')))
81 </configfile> 81 </configfile>
91 <test> 91 <test>
92 <param name="image" value="rename_test.ome.tiff" /> 92 <param name="image" value="rename_test.ome.tiff" />
93 <param name="channel_csv" value="rename_channels.csv" /> 93 <param name="channel_csv" value="rename_channels.csv" />
94 <output name="renamed_image" ftype="ome.tiff"> 94 <output name="renamed_image" ftype="ome.tiff">
95 <assert_contents> 95 <assert_contents>
96 <has_size value="899000" delta="50000" /> 96 <has_size value="900000" delta="50000" />
97 </assert_contents> 97 </assert_contents>
98 </output> 98 </output>
99 <assert_stdout> 99 <assert_stdout>
100 <has_text text="Channel 0 renamed to DNA_6" /> 100 <has_text text="Channel 0 renamed to Hematoxylin" />
101 <has_text text="Updated OME-TIFF metadata" /> 101 <has_text text="Updated OME-TIFF metadata" />
102 <has_text text="µm" />
102 </assert_stdout> 103 </assert_stdout>
103 </test> 104 </test>
104 </tests> 105 </tests>
105 <help><![CDATA[ 106 <help><![CDATA[
106 Given an OME.TIFF image and channel metadata CSV file, rename the image channels in the 107 Given an OME.TIFF image and channel metadata CSV file, rename the image channels in the