Previous changeset 1:02abff468d60 (2022-11-10) Next changeset 3:c60b810d570d (2023-11-28) |
Commit message:
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mesmer commit 40737a3341bb2352f4f8560889bb53362fd624be |
modified:
Dockerfile macros.xml mesmer.xml |
added:
test-data/deepcell_test.tiff |
removed:
test-data/test.tiff |
b |
diff -r 02abff468d60 -r 187918c47051 Dockerfile --- a/Dockerfile Thu Nov 10 20:38:34 2022 +0000 +++ b/Dockerfile Wed Dec 28 19:26:02 2022 +0000 |
[ |
@@ -1,5 +1,7 @@ -ARG VERSION=0.3.1 +ARG VERSION=0.12.3 -FROM vanvalenlab/deepcell-applications:${VERSION} +FROM vanvalenlab/deepcell-tf:${VERSION} + +RUN pip install imagecodecs zarr ENTRYPOINT [] |
b |
diff -r 02abff468d60 -r 187918c47051 macros.xml --- a/macros.xml Thu Nov 10 20:38:34 2022 +0000 +++ b/macros.xml Wed Dec 28 19:26:02 2022 +0000 |
b |
@@ -2,7 +2,7 @@ <macros> <xml name="requirements"> <requirements> - <container type="docker">quay.io/goeckslab/mesmer:@TOOL_VERSION@</container> + <container type="docker">quay.io/goeckslab/deepcell:@TOOL_VERSION@</container> </requirements> </xml> <xml name="stdio"> @@ -25,16 +25,42 @@ description="Out of Memory" /> </stdio> </xml> - <xml name="version_cmd"> - <version_command>@CMD_BEGIN@ --help</version_command> + + <xml name="watershed_adv_options"> + <param name="maxima_smooth" type="integer" value="0" label="Maxima Smooth"/> + <param name="interior_threshold" type="float" value="0.2" label="Interior Threshold"/> + <param name="interior_smooth" type="integer" value="2" label="Interior Smooth"/> + <param name="small_objects_threshold" type="integer" value="15" label="Small Objects Threshold"/> + <param name="fill_holes_threshold" type="integer" value="15" label="Fill Holes Threshold"/> + <param name="radius" type="integer" value="1" label="Radius"/> </xml> + + <xml name="nuclear_options_macro"> + <section name="nuclear_options" title="Nuclear Options" expanded="true"> + <param name="pixel_expansion" type="integer" optional="true" label="Number of pixels to expand nucleus"/> + <param name="maxima_threshold" type="float" value="0.1" label="Maxima Threshold"/> + <section name="adv_options" title="Advanced Nuclear Options" expanded="false"> + <expand macro="watershed_adv_options"/> + </section> + </section> + </xml> + + <xml name="wc_options_macro"> + <section name="wc_options" title="Whole Cell Options" expanded="true"> + <param name="wc_channels" type="text" value="1" label="The numerical indices of the channel(s) for the membrane markers" help="No quotes, separated by comma. e.g. 0, 1."/> + <param name="maxima_threshold" type="float" value="0.075" label="Maxima Threshold"/> + <section name="adv_options" title="Advanced Whole Cell Options" expanded="false"> + <expand macro="watershed_adv_options"/> + </section> + </section> + </xml> + <xml name="citations"> <citations> <citation type="doi">10.1038/s41587-021-01094-0</citation> </citations> </xml> - <token name="@TOOL_VERSION@">0.3.1</token> - <token name="@VERSION_SUFFIX@">1</token> - <token name="@CMD_BEGIN@">python /usr/src/app/run_app.py mesmer</token> + <token name="@TOOL_VERSION@">0.12.3</token> + <token name="@VERSION_SUFFIX@">2</token> </macros> |
b |
diff -r 02abff468d60 -r 187918c47051 mesmer.xml --- a/mesmer.xml Thu Nov 10 20:38:34 2022 +0000 +++ b/mesmer.xml Wed Dec 28 19:26:02 2022 +0000 |
[ |
b'@@ -7,63 +7,189 @@\n \n <expand macro="requirements"/>\n <expand macro="stdio"/>\n- <expand macro="version_cmd"/>\n \n <command detect_errors="exit_code"><![CDATA[\n- ln -s \'$nuclear_image\' \'input.tif\' && \n- @CMD_BEGIN@ \n- --output-directory ./\n- --output-name \'mask.tif\'\n- --nuclear-image \'input.tif\'\n- --nuclear-channel $nuclear_channel\n- --compartment $compartment\n- --image-mpp $image_mpp\n- $squeeze\n+ python $script\n+ ]]></command>\n+ <configfiles>\n+ <configfile name="script">\n+import argparse\n+import os \n+import sys\n+\n+import numpy as np\n+import tifffile\n+import zarr\n+\n+from deepcell.applications import Mesmer\n+\n+level = 0\n+is_ome=False\n+#if $image.file_ext == "ome.tiff":\n+is_ome=True\n+#end if\n+\n+## Grab params\n+nuc_kwargs = {}\n+wc_kwargs = {}\n+\n+\n+with tifffile.TiffFile("$image", is_ome=is_ome) as tiff:\n+\n+ # Read single pyramid level\n+ level_array = zarr.open(tiff.aszarr(series = 0, level = level))\n+\n+ ## grab the nuclear and membrane channels based on their indices add the markers along the channel axis\n+ ## Tifffile should always read as (channel,X,Y)\n+ #if $compartment_select.compartment != \'whole-cell\':\n+ nuc_kwargs = {\n+ #if $compartment_select.nuclear_options.pixel_expansion != \'\':\n+ \'pixel_expansion\': $compartment_select.nuclear_options.pixel_expansion,\n+ #end if\n+ #for $key, $value in $dict.items($compartment_select.nuclear_options.adv_options)\n+ \'$key\': $value,\n+ #end for\n+ \'maxima_threshold\': $compartment_select.nuclear_options.maxima_threshold\n+ }\n+ #end if\n+\n+ nuclear_indices = [int(x) for x in $nuclear_channels.split(\',\')]\n+ nuclear_channels = level_array.oindex[nuclear_indices, :, :]\n+ nuclear_channels = np.sum(nuclear_channels, axis = 0)\n \n- #if $membrane_select.membrane_segment == "True":\n- --membrane-image \'$membrane_select.membrane_image\'\n- --membrane-channel \'$membrane_select.membrane_channel\'\n+ #if $compartment_select.compartment != \'nuclear\':\n+ wc_kwargs = {\n+ #for $key, $value in $dict.items($compartment_select.wc_options.adv_options)\n+ \'$key\': $value,\n+ #end for\n+ \'maxima_threshold\': $compartment_select.wc_options.maxima_threshold\n+ }\n+\n+ membrane_indices = [int(x) for x in $compartment_select.wc_options.wc_channels.split(\',\')]\n+ membrane_channels = level_array.oindex[membrane_indices, :, :]\n+ membrane_channels = np.sum(membrane_channels, axis = 0) \n+ #end if\n+\n+ ## stack the nuclear and membrane composite channels with nuclear in channel 0 and mem in channel 1\n+ ## mesmer expects dimensions to be (X,Y,Channel) so axis = -1\n+ #if $compartment_select.compartment == \'nuclear\':\n+ membrane_channels = np.zeros(nuclear_channels.shape)\n #end if\n- ]]></command>\n+ formatted_image = np.stack((nuclear_channels,membrane_channels), axis=-1)\n+\n+ ## add batch dimension. Will have to be squeezed out later\n+ formatted_image = np.expand_dims(formatted_image, 0)\n+\n+## Create the application\n+app = Mesmer()\n+\n+## Run segmentation\n+mask = app.predict(\n+ formatted_image, \n+ image_mpp = $image_mpp, \n+ compartment = "$compartment_select.compartment",\n+ pad_mode = \'constant\',\n+ postprocess_kwargs_whole_cell = wc_kwargs, \n+ postprocess_kwargs_nuclear = nuc_kwargs)\n \n+#if $squeeze:\n+mask = np.squeeze(mask)\n+#end if\n+\n+#if $compartment_select.compartment == \'both\':\n+## split the two-channel mask into separate outputs\n+ #if $squeeze:\n+tifffile.imsave( "WC_output_mask.tif", mask[:,:,0])\n+tifffile.imsave("NU_output_mask.tif", mask[:,:,1])\n+ #else:\n+tifffile.imsave( "WC_output_mask.tif", mask[:,:,:,0])\n+tifffile.imsave("NU_output_mask.tif", mask[:,:,:,1])\n+ #end if\n+#else:\n+## save single-channel mask outputs as a tiff\n+tifffile.imsave("mask.tif", mask)\n+#end if\n+ </configfile>\n+ </configfiles>\n <inputs>\n- <param name="nuclear_image" type="data" format="tiff, ome.tiff" label="Imag'..b'n prediction: ">\n+ <option selected="true" value="whole-cell">Whole cell</option>\n+ <option value="nuclear">Nuclear</option>\n+ <option value="both">Both</option>\n </param>\n- <when value="True">\n- <param name="membrane_image" type="data" format="tiff, ome.tiff" label="The path to an image containing the membrane marker(s)"/>\n- <param name="membrane_channel" type="integer" value="0" label="The numerical index of the channel(s) from membrane-image"/>\n+ <when value="nuclear">\n+ <expand macro="nuclear_options_macro"/>\n </when>\n- <when value="False" />\n+ <when value="whole-cell">\n+ <expand macro="wc_options_macro"/>\n+ </when>\n+ <when value="both">\n+ <expand macro="nuclear_options_macro"/>\n+ <expand macro="wc_options_macro"/>\n+ </when>\n </conditional>\n </inputs>\n+\n <outputs>\n- <data format="tiff" name="mask" from_work_dir="mask.tif" label="${tool.name} on ${on_string}: Mask"/>\n+ <data format="tiff" name="nu_mask" from_work_dir="NU_output_mask.tif" label="${tool.name} on ${on_string}: Nuclear Mask">\n+ <filter>compartment_select[\'compartment\'] == \'both\'</filter>\n+ </data>\n+ <data format="tiff" name="wc_mask" from_work_dir="WC_output_mask.tif" label="${tool.name} on ${on_string}: Whole Cell Mask">\n+ <filter>compartment_select[\'compartment\'] == \'both\'</filter>\n+ </data>\n+ <data format="tiff" name="mask" from_work_dir="mask.tif" label="${tool.name} on ${on_string}: Mask">\n+ <filter>compartment_select[\'compartment\'] != \'both\'</filter>\n+ </data>\n </outputs>\n <tests>\n- <test>\n- <param name="nuclear_image" value="test.tiff" />\n+ <test>\n+ <param name="image" value="deepcell_test.tiff" ftype="tiff"/>\n <param name="compartment" value="nuclear" />\n- <param name="membrane_segment" value="False" />\n <param name="image_mpp" value="0.65" />\n- <param name="squeeze" value="--squeeze" />\n+ <param name="squeeze" value="True" />\n <output name="mask" ftype="tiff">\n <assert_contents>\n- <has_size value="360000" delta="1000" />\n+ <has_size value="1049000" delta="1000" />\n </assert_contents>\n </output>\n </test>\n- </tests>\n+ <test>\n+ <param name="image" value="deepcell_test.tiff" ftype="tiff"/>\n+ <param name="compartment" value="whole-cell" />\n+ <param name="wc_channels" value="0, 1" />\n+ <param name="maxima_threshold" value="0.075" />\n+ <param name="image_mpp" value="0.65" />\n+ <param name="squeeze" value="True" />\n+ <output name="mask" ftype="tiff">\n+ <assert_contents>\n+ <has_size value="1049000" delta="1000" />\n+ </assert_contents>\n+ </output>\n+ </test>\n+ <test>\n+ <param name="image" value="deepcell_test.tiff" ftype="tiff"/>\n+ <param name="compartment" value="both" />\n+ <param name="image_mpp" value="0.65" />\n+ <param name="wc_channels" value="1" />\n+ <param name="nuclear_channels" value="0" />\n+ <param name="squeeze" value="True" />\n+ <output name="wc_mask" ftype="tiff">\n+ <assert_contents>\n+ <has_size value="1049000" delta="1000" />\n+ </assert_contents>\n+ </output>\n+ <output name="nu_mask" ftype="tiff">\n+ <assert_contents>\n+ <has_size value="1049000" delta="1000" />\n+ </assert_contents>\n+ </output>\n+ </test>\n+ </tests>\n <help><![CDATA[\n ------\n Mesmer\n' |
b |
diff -r 02abff468d60 -r 187918c47051 test-data/deepcell_test.tiff |
b |
Binary file test-data/deepcell_test.tiff has changed |
b |
diff -r 02abff468d60 -r 187918c47051 test-data/test.tiff |
b |
Binary file test-data/test.tiff has changed |