Skip to content

Commit

Permalink
deploy: 30db694
Browse files Browse the repository at this point in the history
  • Loading branch information
Karl5766 committed Oct 3, 2024
1 parent 35c56b1 commit a682738
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 43 deletions.
2 changes: 1 addition & 1 deletion API/napari_zarr.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<section id="cvpl-tools-napari-zarr-py">
<span id="napari-zarr"></span><h1>cvpl_tools/napari/zarr.py<a class="headerlink" href="#cvpl-tools-napari-zarr-py" title="Permalink to this heading"></a></h1>
<p>View source at <a class="reference external" href="https://github.com/khanlab/cvpl_tools/blob/main/src/cvpl_tools/napari/zarr.py">zarr.py</a>.</p>
<p>For OME ZARR images, <code class="code docutils literal notranslate"><span class="pre">add_ome_zarr_array_from_path</span></code> can be used generally. If an image has an
<p>For ome zarr images, <code class="code docutils literal notranslate"><span class="pre">add_ome_zarr_array_from_path</span></code> can be used generally. If an image has an
associated label OME_ZARR file(s) in the “[image_ome_zarr]/labels/label_name” path, then the
image and label(s) can be opened together with a single <code class="code docutils literal notranslate"><span class="pre">add_ome_zarr_group_from_path</span></code> call.</p>
<p class="rubric">APIs</p>
Expand Down
37 changes: 33 additions & 4 deletions API/ome_zarr_io.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<li class="toctree-l1"><a class="reference internal" href="napari_zarr.html">cvpl_tools.ome_zarr.napari.zarr_viewer.py</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">cvpl_tools.ome_zarr.io.py</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#cvpl_tools.ome_zarr.io.load_zarr_group_from_path"><code class="docutils literal notranslate"><span class="pre">load_zarr_group_from_path()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#cvpl_tools.ome_zarr.io.load_dask_array_from_path"><code class="docutils literal notranslate"><span class="pre">load_dask_array_from_path()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#cvpl_tools.ome_zarr.io.write_ome_zarr_image"><code class="docutils literal notranslate"><span class="pre">write_ome_zarr_image()</span></code></a></li>
</ul>
</li>
Expand Down Expand Up @@ -92,10 +93,11 @@
<section id="cvpl-tools-ome-zarr-io-py">
<span id="ome-zarr-io"></span><h1>cvpl_tools/ome_zarr/io.py<a class="headerlink" href="#cvpl-tools-ome-zarr-io-py" title="Permalink to this heading"></a></h1>
<p>View source at <a class="reference external" href="https://github.com/khanlab/cvpl_tools/blob/main/src/cvpl_tools/ome_zarr/io.py">io.py</a>.</p>
<p>Read and Write: For reading OME ZARR image, use <code class="code docutils literal notranslate"><span class="pre">load_zarr_group_from_path</span></code> to open a zarr group in
read mode and then use <code class="code docutils literal notranslate"><span class="pre">dask.array.from_zarr</span></code> to create a dask array from the group. For writing OME
ZARR image, we assume you have a dask array and would like to write it as a .zip or a directory. In
such cases, <code class="code docutils literal notranslate"><span class="pre">write_ome_zarr_image</span></code> directly writes the dask array onto disk.</p>
<p>Read and Write: For reading ome zarr image, use <code class="code docutils literal notranslate"><span class="pre">load_dask_array_from_path</span></code> to directly read the OME
ZARR file as a dask array. Alternatively, use <code class="code docutils literal notranslate"><span class="pre">load_zarr_group_from_path</span></code> to open a zarr group in
read mode and then use <code class="code docutils literal notranslate"><span class="pre">dask.array.from_zarr</span></code> to create a dask array from that group.</p>
<p>For writing ome zarr image, we assume you have a dask array and would like to write it as a .zip or a
directory. In such cases, <code class="code docutils literal notranslate"><span class="pre">write_ome_zarr_image</span></code> directly writes the dask array onto disk.</p>
<p class="rubric">APIs</p>
<dl class="py function">
<dt class="sig sig-object py" id="cvpl_tools.ome_zarr.io.load_zarr_group_from_path">
Expand All @@ -118,6 +120,33 @@
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="cvpl_tools.ome_zarr.io.load_dask_array_from_path">
<span class="sig-prename descclassname"><span class="pre">cvpl_tools.ome_zarr.io.</span></span><span class="sig-name descname"><span class="pre">load_dask_array_from_path</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mode</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_zip</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">level</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Array</span></span></span><a class="headerlink" href="#cvpl_tools.ome_zarr.io.load_dask_array_from_path" title="Permalink to this definition"></a></dt>
<dd><p>Loads either a zarr folder or zarr zip file into a zarr group.</p>
<p>Compared to load_zarr_group_from_path, this function allows specifying which slice and channel to read using
a query string syntax (idea thanks to Davis Bennett in the thread
<a class="reference external" href="https://forum.image.sc/t/loading-only-one-channel-from-an-ome-zarr/97798">https://forum.image.sc/t/loading-only-one-channel-from-an-ome-zarr/97798</a>)</p>
<p class="rubric">Examples</p>
<p>load_dask_array_from_path(‘C://path/to/image.ome.zarr?slices=[1]’) # use channel 1
load_dask_array_from_path(‘/path/to/image.ome.zarr?slices=[:, :100]’) # all channels, 0-99 on the second axis</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>path</strong> – path to the zarr folder or zip to be opened</p></li>
<li><p><strong>mode</strong> – file open mode e.g. ‘r’, only pass this if the file is a zip file</p></li>
<li><p><strong>use_zip</strong> – if True, treat path as a zip; if False, treat path as a folder; if None, use path to determine
file type</p></li>
<li><p><strong>level</strong> – If None (default), load the entire ome zarr; if an int is provided, load the corresponding level
in the ome zarr array</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>the opened zarr group</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="cvpl_tools.ome_zarr.io.write_ome_zarr_image">
<span class="sig-prename descclassname"><span class="pre">cvpl_tools.ome_zarr.io.</span></span><span class="sig-name descname"><span class="pre">write_ome_zarr_image</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ome_zarr_path</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tmp_path</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">da_arr</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Array</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lbl_arr</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Array</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lbl_name</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">make_zip</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">MAX_LAYER</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">logging</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">storage_options</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">dict</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lbl_storage_options</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">dict</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cvpl_tools.ome_zarr.io.write_ome_zarr_image" title="Permalink to this definition"></a></dt>
Expand Down
Loading

0 comments on commit a682738

Please sign in to comment.