Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
constantinpape committed Apr 25, 2024
1 parent dc3ddf6 commit 12edc0e
Show file tree
Hide file tree
Showing 27 changed files with 19,278 additions and 10,540 deletions.
41 changes: 25 additions & 16 deletions micro_sam.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ <h2>Contents</h2>

<h2>Submodules</h2>
<ul>
<li><a href="micro_sam/bioimageio.html">bioimageio</a></li>
<li><a href="micro_sam/evaluation.html">evaluation</a></li>
<li><a href="micro_sam/inference.html">inference</a></li>
<li><a href="micro_sam/instance_segmentation.html">instance_segmentation</a></li>
Expand Down Expand Up @@ -176,7 +177,7 @@ <h1 id="installation">Installation</h1>
<ul>
<li><a href="#from-mamba">From mamba</a> is the recommended way if you want to use all functionality.</li>
<li><a href="#from-source">From source</a> for setting up a development environment to use the latest version and be able to change and contribute to our software.</li>
<li><a href="#from-installer">From installer</a> to install without having to use conda (supported platforms: Windows and Linux, only for CPU users). </li>
<li><a href="#from-installer">From installer</a> to install without having to use mamba (supported platforms: Windows and Linux, only for CPU users). </li>
</ul>

<h2 id="from-mamba">From mamba</h2>
Expand Down Expand Up @@ -828,23 +829,23 @@ <h1 id="for-developers">For Developers</h1>
<p>This software consists of four different python (sub-)modules:</p>

<ul>
<li>The top-level <code><a href="">micro_sam</a></code> module implements general purpose functionality for using Segment Anything for multi-dimension data.</li>
<li>The top-level <code><a href="">micro_sam</a></code> module implements general purpose functionality for using Segment Anything for multi-dimensional data.</li>
<li><code><a href="micro_sam/evaluation.html">micro_sam.evaluation</a></code> provides functionality to evaluate Segment Anything models on (microscopy) segmentation tasks.</li>
<li><code>micro_sam.traning</code> implements the training functionality to finetune Segment Anything on custom segmentation datasets.</li>
<li><code>micro_sam.traning</code> implements the training functionality to finetune Segment Anything for custom segmentation datasets.</li>
<li><code><a href="micro_sam/sam_annotator.html">micro_sam.sam_annotator</a></code> implements the interactive annotation tools.</li>
</ul>

<h2 id="annotation-tools-2">Annotation Tools</h2>

<p>The annotation tools are currently implemented as stand-alone napari applications. We are in the process of implementing them as napari plugins instead (see <a href="https://github.com/computational-cell-analytics/micro-sam/issues/167">https://github.com/computational-cell-analytics/micro-sam/issues/167</a> for details), and the descriptions here refer to the planned architecture for the plugins.</p>
<p>The annotation tools are implemented as napari plugins.</p>

<p>There are four annotation tools:</p>

<ul>
<li><code><a href="micro_sam/sam_annotator/annotator_2d.html">micro_sam.sam_annotator.annotator_2d</a></code>: for interactive segmentation of 2d images.</li>
<li><code><a href="micro_sam/sam_annotator/annotator_3d.html">micro_sam.sam_annotator.annotator_3d</a></code>: for interactive segmentation of volumetric images.</li>
<li><code><a href="micro_sam/sam_annotator/annotator_tracking.html">micro_sam.sam_annotator.annotator_tracking</a></code>: for interactive tracking in timeseries of 2d images.</li>
<li><code><a href="micro_sam/sam_annotator/image_series_annotator.html">micro_sam.sam_annotator.image_series_annotator</a></code>: for applying the 2d annotation tool to a series of images.</li>
<li><code><a href="micro_sam/sam_annotator/image_series_annotator.html">micro_sam.sam_annotator.image_series_annotator</a></code>: for applying the 2d annotation tool to a series of images. This is not implemented as a separate plugin, but as a function that runns annotator 2d for multiple images.</li>
</ul>

<p>An overview of the functionality of the different tools:</p>
Expand All @@ -866,7 +867,7 @@ <h2 id="annotation-tools-2">Annotation Tools</h2>
<td>Yes</td>
</tr>
<tr>
<td>For multiple objects at a time</td>
<td>Interactive segmentation for multiple objects at a time</td>
<td>Yes</td>
<td>No</td>
<td>No</td>
Expand All @@ -886,13 +887,13 @@ <h2 id="annotation-tools-2">Annotation Tools</h2>
<tr>
<td>Automatic segmentation</td>
<td>Yes</td>
<td>Yes (on <code>dev</code>)</td>
<td>Yes</td>
<td>No</td>
</tr>
</tbody>
</table>

<p>The functionality for the <code>image_series_annotator</code> is not listed because it is identical with the functionality of the <code>annotator_2d</code>.</p>
<p>The functionality for <code>image_series_annotator</code> is not listed because it is identical with the functionality of <code>annotator_2d</code>.</p>

<p>Each tool implements the follwing core logic:</p>

Expand All @@ -901,20 +902,28 @@ <h2 id="annotation-tools-2">Annotation Tools</h2>
<li>Interactive (and automatic) segmentation functionality is implemented by a UI based on <code>napari</code> and <code>magicgui</code> functionality.</li>
</ol>

<p>Each tool has two different entry points:</p>
<p>Each tool has three different entry points:</p>

<ul>
<li>From napari plugin menu, e.g. <code>plugin-&gt;micro_sam-&gt;annotator_2d</code> (This entry point is called <em>plugin</em> in the following).</li>
<li>From the command line, e.g. <code>micro_sam.annotator_2d -i /path/to/image</code> (This entry point is called <em>CLI</em> in the following).</li>
<li>From napari plugin menu, e.g. <code>plugin-&gt;micro_sam-&gt;Annotator 2d</code>. (Called <em>plugin</em> in the following).</li>
<li>From a python function, e.g. <code><a href="micro_sam/sam_annotator/annotator_2d.html">micro_sam.sam_annotator.annotator_2d</a>:annotator_2d</code>. (Called <em>function</em> in the following.)</li>
<li>From the command line, e.g. <code>micro_sam.annotator_2d</code>. (Called <em>CLI</em> in the following).</li>
</ul>

<p>The tools are implemented their own submodules, e.g. <code><a href="micro_sam/sam_annotator/annotator_2d.html">micro_sam.sam_annotator.annotator_2d</a></code> with shared functionality implemented in <code><a href="micro_sam/sam_annotator/util.html">micro_sam.sam_annotator.util</a></code>. The function <code>micro_sam.sam_annotator.annotator_2d.annotator_2d_plugin</code> implements the <em>plugin</em> entry point, using the <code>magicgui.magic_factory</code> decorator. <code><a href="micro_sam/sam_annotator/annotator_2d.html#annotator_2d">micro_sam.sam_annotator.annotator_2d.annotator_2d</a></code> implements the <em>CLI</em> entry point; it calls the <code>annotator_2d_plugin</code> function internally.
The image embeddings are computed by the <code>embedding widget</code> (@GenevieveBuckley: will need to be implemented in your PR), which takes the image data from an image layer.
In case of the <em>plugin</em> entry point this image layer is created by the user (by loading an image into napari), and the user can then select in the <code>embedding widget</code> which layer to use for embedding computation.
In case of <em>CLI</em> the image data is specified via the <code>-i</code> parameter, the layer is created for that image and the embeddings are computed for it automatically.
<p>Each tool is implemented in its own submodule, e.g. <code><a href="micro_sam/sam_annotator/annotator_2d.html">micro_sam.sam_annotator.annotator_2d</a></code>.
The napari plugin is implemented by a class, e.g. <code><a href="micro_sam/sam_annotator/annotator_2d.html">micro_sam.sam_annotator.annotator_2d</a>:Annotator2d</code>, inheriting from <code>micro_sam.sam_annotator._annotator._AnnotatorBase</code>. This class implements the core logic for the plugins.
The concrete annotation tools are instantiated by passing widgets from <code>micro_sam.sam_annotator._widgets</code> to it,
which implement the interactive segmentation in 2d, 3d etc.
These plugins are designed so that image embeddings can be computed for user-specified image layers in napari.</p>

<p>The <em>function</em> and <em>CLI</em> entry points are implemented by <code><a href="micro_sam/sam_annotator/annotator_2d.html">micro_sam.sam_annotator.annotator_2d</a>:annotator_2d</code> (and corresponding functions for the other annotation tools). They are called with image data, precompute the embeddings for that image and start a napari viewer with this image and the annotation plugin.</p>

<p><!--
TODO update the flow chart so that it matches the new design.
The same overall design holds true for the other plugins. The flow chart below shows a flow chart with a simplified overview of the design of the 2d annotation tool. Rounded squares represent functions or the corresponding widget and squares napari layers or other data, orange represents the <em>plugin</em> enty point, cyan <em>CLI</em>. Arrows that do not have a label correspond to a simple input/output relation.</p>
<p><img src="./images/2d-annotator-flow.png" alt="annotator 2d flow diagram" /></p>
<p><img src="./images/2d-annotator-flow.png" alt="annotator 2d flow diagram" />
--></p>

<p><!---
Source for the diagram is here:
Expand Down
2 changes: 1 addition & 1 deletion micro_sam/__version__.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h1 class="modulename">

<label class="view-source-button" for="mod-__version__-view-source"><span>View Source</span></label>

<div class="pdoc-code codehilite"><pre><span></span><span id="L-1"><a href="#L-1"><span class="linenos">1</span></a><span class="n">__version__</span> <span class="o">=</span> <span class="s2">&quot;0.4.1&quot;</span>
<div class="pdoc-code codehilite"><pre><span></span><span id="L-1"><a href="#L-1"><span class="linenos">1</span></a><span class="n">__version__</span> <span class="o">=</span> <span class="s2">&quot;0.5.0&quot;</span>
</span></pre></div>


Expand Down
29 changes: 16 additions & 13 deletions micro_sam/evaluation.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ <h2>Submodules</h2>
<li><a href="evaluation/instance_segmentation.html">instance_segmentation</a></li>
<li><a href="evaluation/livecell.html">livecell</a></li>
<li><a href="evaluation/model_comparison.html">model_comparison</a></li>
<li><a href="evaluation/multi_dimensional_segmentation.html">multi_dimensional_segmentation</a></li>
</ul>


Expand Down Expand Up @@ -67,19 +68,21 @@ <h1 class="modulename">
</span><span id="L-6"><a href="#L-6"><span class="linenos"> 6</span></a> <span class="n">run_instance_segmentation_grid_search</span><span class="p">,</span>
</span><span id="L-7"><a href="#L-7"><span class="linenos"> 7</span></a> <span class="n">run_instance_segmentation_grid_search_and_inference</span><span class="p">,</span>
</span><span id="L-8"><a href="#L-8"><span class="linenos"> 8</span></a><span class="p">)</span>
</span><span id="L-9"><a href="#L-9"><span class="linenos"> 9</span></a><span class="kn">from</span> <span class="nn">.evaluation</span> <span class="kn">import</span> <span class="n">run_evaluation</span>
</span><span id="L-10"><a href="#L-10"><span class="linenos">10</span></a><span class="kn">from</span> <span class="nn">.inference</span> <span class="kn">import</span> <span class="p">(</span>
</span><span id="L-11"><a href="#L-11"><span class="linenos">11</span></a> <span class="n">get_predictor</span><span class="p">,</span>
</span><span id="L-12"><a href="#L-12"><span class="linenos">12</span></a> <span class="n">run_inference_with_iterative_prompting</span><span class="p">,</span>
</span><span id="L-13"><a href="#L-13"><span class="linenos">13</span></a> <span class="n">run_inference_with_prompts</span><span class="p">,</span>
</span><span id="L-14"><a href="#L-14"><span class="linenos">14</span></a> <span class="n">precompute_all_embeddings</span><span class="p">,</span>
</span><span id="L-15"><a href="#L-15"><span class="linenos">15</span></a> <span class="n">precompute_all_prompts</span><span class="p">,</span>
</span><span id="L-16"><a href="#L-16"><span class="linenos">16</span></a><span class="p">)</span>
</span><span id="L-17"><a href="#L-17"><span class="linenos">17</span></a><span class="kn">from</span> <span class="nn">.experiments</span> <span class="kn">import</span> <span class="p">(</span>
</span><span id="L-18"><a href="#L-18"><span class="linenos">18</span></a> <span class="n">default_experiment_settings</span><span class="p">,</span>
</span><span id="L-19"><a href="#L-19"><span class="linenos">19</span></a> <span class="n">full_experiment_settings</span><span class="p">,</span>
</span><span id="L-20"><a href="#L-20"><span class="linenos">20</span></a> <span class="n">get_experiment_setting_name</span><span class="p">,</span>
</span><span id="L-21"><a href="#L-21"><span class="linenos">21</span></a><span class="p">)</span>
</span><span id="L-9"><a href="#L-9"><span class="linenos"> 9</span></a><span class="kn">from</span> <span class="nn">.evaluation</span> <span class="kn">import</span> <span class="p">(</span>
</span><span id="L-10"><a href="#L-10"><span class="linenos">10</span></a> <span class="n">run_evaluation</span><span class="p">,</span>
</span><span id="L-11"><a href="#L-11"><span class="linenos">11</span></a> <span class="n">run_evaluation_for_iterative_prompting</span><span class="p">,</span>
</span><span id="L-12"><a href="#L-12"><span class="linenos">12</span></a><span class="p">)</span>
</span><span id="L-13"><a href="#L-13"><span class="linenos">13</span></a><span class="kn">from</span> <span class="nn">.inference</span> <span class="kn">import</span> <span class="p">(</span>
</span><span id="L-14"><a href="#L-14"><span class="linenos">14</span></a> <span class="n">run_inference_with_iterative_prompting</span><span class="p">,</span>
</span><span id="L-15"><a href="#L-15"><span class="linenos">15</span></a> <span class="n">run_inference_with_prompts</span><span class="p">,</span>
</span><span id="L-16"><a href="#L-16"><span class="linenos">16</span></a> <span class="n">precompute_all_embeddings</span><span class="p">,</span>
</span><span id="L-17"><a href="#L-17"><span class="linenos">17</span></a> <span class="n">precompute_all_prompts</span><span class="p">,</span>
</span><span id="L-18"><a href="#L-18"><span class="linenos">18</span></a><span class="p">)</span>
</span><span id="L-19"><a href="#L-19"><span class="linenos">19</span></a><span class="kn">from</span> <span class="nn">.experiments</span> <span class="kn">import</span> <span class="p">(</span>
</span><span id="L-20"><a href="#L-20"><span class="linenos">20</span></a> <span class="n">default_experiment_settings</span><span class="p">,</span>
</span><span id="L-21"><a href="#L-21"><span class="linenos">21</span></a> <span class="n">full_experiment_settings</span><span class="p">,</span>
</span><span id="L-22"><a href="#L-22"><span class="linenos">22</span></a> <span class="n">get_experiment_setting_name</span><span class="p">,</span>
</span><span id="L-23"><a href="#L-23"><span class="linenos">23</span></a><span class="p">)</span>
</span></pre></div>


Expand Down
Loading

0 comments on commit 12edc0e

Please sign in to comment.