Mercurial > repos > goeckslab > rename_tiff_channels
changeset 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 | |
files | macros.xml rename_tiff_channels.xml test-data/rename_channels.csv test-data/rename_test.ome.tiff test-data/test.xml |
diffstat | 5 files changed, 26 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/macros.xml Thu Jul 11 22:41:10 2024 +0000 +++ b/macros.xml Mon Jul 15 21:37:39 2024 +0000 @@ -16,6 +16,6 @@ </xml> <token name="@TOOL_VERSION@">0.0.2</token> - <token name="@VERSION_SUFFIX@">0</token> + <token name="@VERSION_SUFFIX@">1</token> <token name="@PROFILE@">19.01</token> </macros>
--- a/rename_tiff_channels.xml Thu Jul 11 22:41:10 2024 +0000 +++ b/rename_tiff_channels.xml Mon Jul 15 21:37:39 2024 +0000 @@ -59,7 +59,7 @@ channels_df = pd.read_csv(os.path.join(cwd, 'channels.csv')) original_ome_xml = tiffcomment(os.path.join(cwd, 'renamed_image.ome.tiff')) -working_ome = ome_types.from_xml(original_ome_xml, parser = 'lxml') +working_ome = ome_types.from_xml(original_ome_xml) for l_idx, level in enumerate(working_ome.images): @@ -73,7 +73,7 @@ print(f"Channel {c_idx} renamed to {new_name}") -updated_ome_xml = working_ome.to_xml() +updated_ome_xml = working_ome.to_xml().encode() tiffcomment(os.path.join(cwd, 'renamed_image.ome.tiff'), updated_ome_xml) print("Updated OME-TIFF metadata:") @@ -93,12 +93,13 @@ <param name="channel_csv" value="rename_channels.csv" /> <output name="renamed_image" ftype="ome.tiff"> <assert_contents> - <has_size value="899000" delta="50000" /> + <has_size value="900000" delta="50000" /> </assert_contents> </output> <assert_stdout> - <has_text text="Channel 0 renamed to DNA_6" /> + <has_text text="Channel 0 renamed to Hematoxylin" /> <has_text text="Updated OME-TIFF metadata" /> + <has_text text="µm" /> </assert_stdout> </test> </tests>
--- a/test-data/rename_channels.csv Thu Jul 11 22:41:10 2024 +0000 +++ b/test-data/rename_channels.csv Mon Jul 15 21:37:39 2024 +0000 @@ -1,3 +1,20 @@ -channel_number,cycle_number,marker_name,Filter,excitation_wavelength,emission_wavelength -0,6,DNA_6,DAPI,395,431 -0,6,DNA_7,DAPI,395,431 \ No newline at end of file +channel_number,marker_name +1,Hematoxylin +2,HLA_DRDPDQ +3,DCLAMP +4,CD3 +5,CD45 +6,CD8 +7,GRZB +8,CD20 +9,CD11b +10,CD66b +11,CD11c +12,CD163 +13,HLA-ClassI +14,EOMES +15,FOXP3 +16,Ki67 +17,panCK +18,PD-1 +19,PD-L1
--- a/test-data/test.xml Thu Jul 11 22:41:10 2024 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<OME xmlns="http://www.openmicroscopy.org/Schemas/OME/2016-06" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" UUID="urn:uuid:be7b96c1-399b-41a1-a9f8-ab50da05159b" xsi:schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2016-06 http://www.openmicroscopy.org/Schemas/OME/2016-06/ome.xsd"><Image ID="Image:0"><Pixels BigEndian="false" DimensionOrder="XYZCT" ID="Pixels:0" PhysicalSizeX="0.6499999761581421" PhysicalSizeXUnit="µm" PhysicalSizeY="0.6499999761581421" PhysicalSizeYUnit="µm" SizeC="32" SizeT="1" SizeX="13720" SizeY="9420" SizeZ="1" Type="uint16"><Channel ID="Channel:0:0" Name="DNA" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:1" Name="Control-488nm" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:2" Name="Control-555nm" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:3" Name="Control-647nm" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:4" Name="DNA (2)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:5" Name="ERK-1 (pT202; pY204)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:6" Name="ERK-1 (pT202; pY204) (2)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:7" Name="hRAD51" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:8" Name="DNA (3)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:9" Name="G1/S-specific cyclin-D1" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:10" Name="Vimentin" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:11" Name="Aortic smooth muscle actin" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:12" Name="DNA (4)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:13" Name="E-cadherin" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:14" Name="ER" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:15" Name="PR" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:16" Name="DNA (5)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:17" Name="Epidermal growth factor receptor" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:18" Name="Rb (pS807; pS811)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:19" Name="CD45" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:20" Name="DNA (6)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:21" Name="Antigen Ki67" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:22" Name="CK-19" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:23" Name="p21" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:24" Name="DNA (7)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:25" Name="CK-14" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:26" Name="Androgen Receptor" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:27" Name="Cleaved PARP-1" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:28" Name="DNA (8)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:29" Name="CK-17" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:30" Name="CK-7" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:31" Name="HER2" SamplesPerPixel="1"><LightPath /></Channel><TiffData IFD="0" PlaneCount="32" /><Plane TheC="0" TheT="0" TheZ="0" /><Plane TheC="1" TheT="0" TheZ="0" /><Plane TheC="2" TheT="0" TheZ="0" /><Plane TheC="3" TheT="0" TheZ="0" /><Plane TheC="4" TheT="0" TheZ="0" /><Plane TheC="5" TheT="0" TheZ="0" /><Plane TheC="6" TheT="0" TheZ="0" /><Plane TheC="7" TheT="0" TheZ="0" /><Plane TheC="8" TheT="0" TheZ="0" /><Plane TheC="9" TheT="0" TheZ="0" /><Plane TheC="10" TheT="0" TheZ="0" /><Plane TheC="11" TheT="0" TheZ="0" /><Plane TheC="12" TheT="0" TheZ="0" /><Plane TheC="13" TheT="0" TheZ="0" /><Plane TheC="14" TheT="0" TheZ="0" /><Plane TheC="15" TheT="0" TheZ="0" /><Plane TheC="16" TheT="0" TheZ="0" /><Plane TheC="17" TheT="0" TheZ="0" /><Plane TheC="18" TheT="0" TheZ="0" /><Plane TheC="19" TheT="0" TheZ="0" /><Plane TheC="20" TheT="0" TheZ="0" /><Plane TheC="21" TheT="0" TheZ="0" /><Plane TheC="22" TheT="0" TheZ="0" /><Plane TheC="23" TheT="0" TheZ="0" /><Plane TheC="24" TheT="0" TheZ="0" /><Plane TheC="25" TheT="0" TheZ="0" /><Plane TheC="26" TheT="0" TheZ="0" /><Plane TheC="27" TheT="0" TheZ="0" /><Plane TheC="28" TheT="0" TheZ="0" /><Plane TheC="29" TheT="0" TheZ="0" /><Plane TheC="30" TheT="0" TheZ="0" /><Plane TheC="31" TheT="0" TheZ="0" /></Pixels></Image></OME>