Skip to content

Commit

Permalink
deploy: aaa8a08
Browse files Browse the repository at this point in the history
  • Loading branch information
Karl5766 committed Oct 7, 2024
1 parent a682738 commit 816d539
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions API/ome_zarr_io.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,20 @@
<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>
<dd><p>Loads either a zarr folder or zarr zip file into a dask array.</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>
<p class="rubric">Example</p>
<p>Loading an ome zarr array of shape (2, 200, 1000, 1000) using different slices:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">arr_original</span> <span class="o">=</span> <span class="n">load_dask_array_from_path</span><span class="p">(</span><span class="s1">&#39;file.ome.zarr&#39;</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span> <span class="c1"># shape=(2, 200, 1000, 1000)</span>
<span class="n">arr1</span> <span class="o">=</span> <span class="n">load_dask_array_from_path</span><span class="p">(</span><span class="s1">&#39;file.ome.zarr?slices=[0]&#39;</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span> <span class="c1"># shape=(200, 1000, 1000)</span>
<span class="n">arr2</span> <span class="o">=</span> <span class="n">load_dask_array_from_path</span><span class="p">(</span><span class="s1">&#39;file.ome.zarr?slices=[:, :100]&#39;</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span> <span class="c1"># shape=(2, 100, 1000, 1000)</span>
<span class="n">arr3</span> <span class="o">=</span> <span class="n">load_dask_array_from_path</span><span class="p">(</span><span class="s1">&#39;file.ome.zarr?slices=[0:1, 0, -1:, ::2]&#39;</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span> <span class="c1"># shape=(1, 1, 500)</span>
</pre></div>
</div>
<p>Essentially, Python multi-index slicing can be done and the effect is similar to torch or numpy indexing using
slices.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
Expand Down
Loading

0 comments on commit 816d539

Please sign in to comment.