--- a +++ b/docs/index.html @@ -0,0 +1,2863 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Welcome to PathFlowAI’s documentation! — PathFlowAI 0.1 documentation</title> + + + + + + + + + <script type="text/javascript" src="_static/js/modernizr.min.js"></script> + + + <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> + <script type="text/javascript" src="_static/jquery.js"></script> + <script type="text/javascript" src="_static/underscore.js"></script> + <script type="text/javascript" src="_static/doctools.js"></script> + <script type="text/javascript" src="_static/language_data.js"></script> + <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script> + + <script type="text/javascript" src="_static/js/theme.js"></script> + + + + + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="index" title="Index" href="genindex.html" /> + <link rel="search" title="Search" href="search.html" /> +</head> + +<body class="wy-body-for-nav"> + + + <div class="wy-grid-for-nav"> + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + + + + <a href="#" class="icon icon-home"> PathFlowAI + + + + </a> + + + + + + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + + + + <!-- Local TOC --> + <div class="local-toc"><ul> +<li><a class="reference internal" href="#">Welcome to PathFlowAI’s documentation!</a><ul> +<li><a class="reference internal" href="#pathflowai-preprocess">pathflowai-preprocess</a><ul> +<li><a class="reference internal" href="#pathflowai-preprocess-alter-masks">alter_masks</a></li> +<li><a class="reference internal" href="#pathflowai-preprocess-collapse-annotations">collapse_annotations</a></li> +<li><a class="reference internal" href="#pathflowai-preprocess-preprocess-pipeline">preprocess_pipeline</a></li> +<li><a class="reference internal" href="#pathflowai-preprocess-remove-basename-from-db">remove_basename_from_db</a></li> +</ul> +</li> +<li><a class="reference internal" href="#pathflowai-visualize">pathflowai-visualize</a><ul> +<li><a class="reference internal" href="#pathflowai-visualize-extract-patch">extract_patch</a></li> +<li><a class="reference internal" href="#pathflowai-visualize-overlay-new-annotations">overlay_new_annotations</a></li> +<li><a class="reference internal" href="#pathflowai-visualize-plot-embeddings">plot_embeddings</a></li> +<li><a class="reference internal" href="#pathflowai-visualize-plot-image">plot_image</a></li> +<li><a class="reference internal" href="#pathflowai-visualize-plot-image-umap-embeddings">plot_image_umap_embeddings</a></li> +<li><a class="reference internal" href="#pathflowai-visualize-plot-predictions">plot_predictions</a></li> +<li><a class="reference internal" href="#pathflowai-visualize-shapley-plot">shapley_plot</a></li> +</ul> +</li> +<li><a class="reference internal" href="#pathflowai-monitor">pathflowai-monitor</a><ul> +<li><a class="reference internal" href="#pathflowai-monitor-monitor-usage">monitor_usage</a></li> +</ul> +</li> +<li><a class="reference internal" href="#datasets-py">datasets.py</a></li> +<li><a class="reference internal" href="#losses-py">losses.py</a><ul> +</ul> +</li> +<li><a class="reference internal" href="#sampler-py">sampler.py</a></li> +<li><a class="reference internal" href="#schedulers-py">schedulers.py</a><ul> +</ul> +</li> +<li><a class="reference internal" href="#visualize-py">visualize.py</a><ul> +</ul> +</li> +<li><a class="reference internal" href="#utils-py">utils.py</a></li> +</ul> +</li> +<li><a class="reference internal" href="#indices-and-tables">Indices and tables</a></li> +</ul> +</div> + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" aria-label="top navigation"> + + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="#">PathFlowAI</a> + + </nav> + + + <div class="wy-nav-content"> + + <div class="rst-content"> + + + + + + + + + + + + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + + <ul class="wy-breadcrumbs"> + + <li><a href="#">Docs</a> »</li> + + <li>Welcome to PathFlowAI’s documentation!</li> + + + <li class="wy-breadcrumbs-aside"> + + + <a href="_sources/index.rst.txt" rel="nofollow"> View page source</a> + + + </li> + + </ul> + + + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="section" id="welcome-to-pathflowai-s-documentation"> +<h1>Welcome to PathFlowAI’s documentation!<a class="headerlink" href="#welcome-to-pathflowai-s-documentation" title="Permalink to this headline">¶</a></h1> +<div class="toctree-wrapper compound"> +</div> +<a class="reference internal image-reference" href="_images/1.jpeg"><img alt="Download" class="align-center" src="_images/1.jpeg" style="width: 480.0px; height: 360.0px;" /></a> +<a class="reference internal image-reference" href="_images/2.jpeg"><img alt="Download" class="align-center" src="_images/2.jpeg" style="width: 480.0px; height: 360.0px;" /></a> +<a class="reference internal image-reference" href="_images/3.jpeg"><img alt="Download" class="align-center" src="_images/3.jpeg" style="width: 480.0px; height: 360.0px;" /></a> +<a class="reference internal image-reference" href="_images/4.jpeg"><img alt="Download" class="align-center" src="_images/4.jpeg" style="width: 480.0px; height: 360.0px;" /></a> +<div class="section" id="pathflowai-preprocess"> +<h2>pathflowai-preprocess<a class="headerlink" href="#pathflowai-preprocess" title="Permalink to this headline">¶</a></h2> +<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-preprocess <span class="o">[</span>OPTIONS<span class="o">]</span> COMMAND <span class="o">[</span>ARGS<span class="o">]</span>... +</pre></div> +</div> +<p class="rubric">Options</p> +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-version"> +<code class="sig-name descname">--version</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-version" title="Permalink to this definition">¶</a></dt> +<dd><p>Show the version and exit.</p> +</dd></dl> + +<div class="section" id="pathflowai-preprocess-alter-masks"> +<h3>alter_masks<a class="headerlink" href="#pathflowai-preprocess-alter-masks" title="Permalink to this headline">¶</a></h3> +<p>Map list of values to other values in mask.</p> +<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-preprocess alter_masks <span class="o">[</span>OPTIONS<span class="o">]</span> +</pre></div> +</div> +<p class="rubric">Options</p> +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-alter-masks-i"> +<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--mask_dir</code><code class="sig-prename descclassname"> <mask_dir></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-alter-masks-i" title="Permalink to this definition">¶</a></dt> +<dd><p>Input directory for masks. [default: ./inputs/]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-alter-masks-o"> +<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--output_dir</code><code class="sig-prename descclassname"> <output_dir></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-alter-masks-o" title="Permalink to this definition">¶</a></dt> +<dd><p>Output directory for new masks. [default: ./outputs/]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-alter-masks-fr"> +<code class="sig-name descname">-fr</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--from_annotations</code><code class="sig-prename descclassname"> <from_annotations></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-alter-masks-fr" title="Permalink to this definition">¶</a></dt> +<dd><p>Annotations to switch from. [default: ]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-alter-masks-to"> +<code class="sig-name descname">-to</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--to_annotations</code><code class="sig-prename descclassname"> <to_annotations></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-alter-masks-to" title="Permalink to this definition">¶</a></dt> +<dd><p>Annotations to switch to. [default: ]</p> +</dd></dl> + +</div> +<div class="section" id="pathflowai-preprocess-collapse-annotations"> +<h3>collapse_annotations<a class="headerlink" href="#pathflowai-preprocess-collapse-annotations" title="Permalink to this headline">¶</a></h3> +<p>Adds annotation classes areas to other annotation classes in SQL DB when getting rid of some annotation classes.</p> +<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-preprocess collapse_annotations <span class="o">[</span>OPTIONS<span class="o">]</span> +</pre></div> +</div> +<p class="rubric">Options</p> +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-collapse-annotations-i"> +<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--input_patch_db</code><code class="sig-prename descclassname"> <input_patch_db></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-collapse-annotations-i" title="Permalink to this definition">¶</a></dt> +<dd><p>Input db. [default: patch_info_input.db]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-collapse-annotations-o"> +<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--output_patch_db</code><code class="sig-prename descclassname"> <output_patch_db></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-collapse-annotations-o" title="Permalink to this definition">¶</a></dt> +<dd><p>Output db. [default: patch_info_output.db]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-collapse-annotations-fr"> +<code class="sig-name descname">-fr</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--from_annotations</code><code class="sig-prename descclassname"> <from_annotations></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-collapse-annotations-fr" title="Permalink to this definition">¶</a></dt> +<dd><p>Annotations to switch from. [default: ]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-collapse-annotations-to"> +<code class="sig-name descname">-to</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--to_annotations</code><code class="sig-prename descclassname"> <to_annotations></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-collapse-annotations-to" title="Permalink to this definition">¶</a></dt> +<dd><p>Annotations to switch to. [default: ]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-collapse-annotations-ps"> +<code class="sig-name descname">-ps</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--patch_size</code><code class="sig-prename descclassname"> <patch_size></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-collapse-annotations-ps" title="Permalink to this definition">¶</a></dt> +<dd><p>Patch size. [default: 224]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-collapse-annotations-rb"> +<code class="sig-name descname">-rb</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--remove_background_annotation</code><code class="sig-prename descclassname"> <remove_background_annotation></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-collapse-annotations-rb" title="Permalink to this definition">¶</a></dt> +<dd><p>If selected, removes 100% background patches based on this annotation. [default: ]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-collapse-annotations-ma"> +<code class="sig-name descname">-ma</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--max_background_area</code><code class="sig-prename descclassname"> <max_background_area></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-collapse-annotations-ma" title="Permalink to this definition">¶</a></dt> +<dd><p>Max background area before exclusion. [default: 0.05]</p> +</dd></dl> + +</div> +<div class="section" id="pathflowai-preprocess-preprocess-pipeline"> +<h3>preprocess_pipeline<a class="headerlink" href="#pathflowai-preprocess-preprocess-pipeline" title="Permalink to this headline">¶</a></h3> +<p>Preprocessing pipeline that accomplishes 3 things. 1: storage into ZARR format, 2: optional mask adjustment, 3: storage of patch-level information into SQL DB</p> +<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-preprocess preprocess_pipeline <span class="o">[</span>OPTIONS<span class="o">]</span> +</pre></div> +</div> +<p class="rubric">Options</p> +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-npy"> +<code class="sig-name descname">-npy</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--img2npy</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-npy" title="Permalink to this definition">¶</a></dt> +<dd><p>Image to numpy for faster read. [default: False]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-b"> +<code class="sig-name descname">-b</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--basename</code><code class="sig-prename descclassname"> <basename></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-b" title="Permalink to this definition">¶</a></dt> +<dd><p>Basename of patches. [default: A01]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-i"> +<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--input_dir</code><code class="sig-prename descclassname"> <input_dir></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-i" title="Permalink to this definition">¶</a></dt> +<dd><p>Input directory for patches. [default: ./inputs/]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-a"> +<code class="sig-name descname">-a</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--annotations</code><code class="sig-prename descclassname"> <annotations></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-a" title="Permalink to this definition">¶</a></dt> +<dd><p>Annotations in image in order. [default: ]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-pr"> +<code class="sig-name descname">-pr</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--preprocess</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-pr" title="Permalink to this definition">¶</a></dt> +<dd><p>Run preprocessing pipeline. [default: False]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-pa"> +<code class="sig-name descname">-pa</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--patches</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-pa" title="Permalink to this definition">¶</a></dt> +<dd><p>Add patches to SQL. [default: False]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-t"> +<code class="sig-name descname">-t</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--threshold</code><code class="sig-prename descclassname"> <threshold></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-t" title="Permalink to this definition">¶</a></dt> +<dd><p>Threshold to remove non-purple slides. [default: 0.05]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-ps"> +<code class="sig-name descname">-ps</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--patch_size</code><code class="sig-prename descclassname"> <patch_size></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-ps" title="Permalink to this definition">¶</a></dt> +<dd><p>Patch size. [default: 224]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-it"> +<code class="sig-name descname">-it</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--intensity_threshold</code><code class="sig-prename descclassname"> <intensity_threshold></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-it" title="Permalink to this definition">¶</a></dt> +<dd><p>Intensity threshold to rate a pixel as non-white. [default: 100.0]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-g"> +<code class="sig-name descname">-g</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--generate_finetune_segmentation</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-g" title="Permalink to this definition">¶</a></dt> +<dd><p>Generate patches for one segmentation mask class for targeted finetuning. [default: False]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-tc"> +<code class="sig-name descname">-tc</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--target_segmentation_class</code><code class="sig-prename descclassname"> <target_segmentation_class></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-tc" title="Permalink to this definition">¶</a></dt> +<dd><p>Segmentation Class to finetune on, output patches to another db. [default: 0]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-tt"> +<code class="sig-name descname">-tt</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--target_threshold</code><code class="sig-prename descclassname"> <target_threshold></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-tt" title="Permalink to this definition">¶</a></dt> +<dd><p>Threshold to include target for segmentation if saving one class. [default: 0.0]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-odb"> +<code class="sig-name descname">-odb</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--out_db</code><code class="sig-prename descclassname"> <out_db></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-odb" title="Permalink to this definition">¶</a></dt> +<dd><p>Output patch database. [default: ./patch_info.db]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-am"> +<code class="sig-name descname">-am</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--adjust_mask</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-am" title="Permalink to this definition">¶</a></dt> +<dd><p>Remove additional background regions from annotation mask. [default: False]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-nn"> +<code class="sig-name descname">-nn</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--n_neighbors</code><code class="sig-prename descclassname"> <n_neighbors></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-nn" title="Permalink to this definition">¶</a></dt> +<dd><p>If adjusting mask, number of neighbors connectivity to remove. [default: 5]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-bp"> +<code class="sig-name descname">-bp</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--basic_preprocess</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-bp" title="Permalink to this definition">¶</a></dt> +<dd><p>Basic preprocessing pipeline, annotation areas are not saved. Used for benchmarking tool against comparable pipelines [default: False]</p> +</dd></dl> + +</div> +<div class="section" id="pathflowai-preprocess-remove-basename-from-db"> +<h3>remove_basename_from_db<a class="headerlink" href="#pathflowai-preprocess-remove-basename-from-db" title="Permalink to this headline">¶</a></h3> +<p>Removes basename/ID from SQL DB.</p> +<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-preprocess remove_basename_from_db <span class="o">[</span>OPTIONS<span class="o">]</span> +</pre></div> +</div> +<p class="rubric">Options</p> +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-remove-basename-from-db-i"> +<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--input_patch_db</code><code class="sig-prename descclassname"> <input_patch_db></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-remove-basename-from-db-i" title="Permalink to this definition">¶</a></dt> +<dd><p>Input db. [default: patch_info_input.db]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-remove-basename-from-db-o"> +<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--output_patch_db</code><code class="sig-prename descclassname"> <output_patch_db></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-remove-basename-from-db-o" title="Permalink to this definition">¶</a></dt> +<dd><p>Output db. [default: patch_info_output.db]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-remove-basename-from-db-b"> +<code class="sig-name descname">-b</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--basename</code><code class="sig-prename descclassname"> <basename></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-remove-basename-from-db-b" title="Permalink to this definition">¶</a></dt> +<dd><p>Basename. [default: A01]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-preprocess-remove-basename-from-db-ps"> +<code class="sig-name descname">-ps</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--patch_size</code><code class="sig-prename descclassname"> <patch_size></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-remove-basename-from-db-ps" title="Permalink to this definition">¶</a></dt> +<dd><p>Patch size. [default: 224]</p> +</dd></dl> + +</div> +</div> +<div class="section" id="pathflowai-visualize"> +<h2>pathflowai-visualize<a class="headerlink" href="#pathflowai-visualize" title="Permalink to this headline">¶</a></h2> +<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-visualize <span class="o">[</span>OPTIONS<span class="o">]</span> COMMAND <span class="o">[</span>ARGS<span class="o">]</span>... +</pre></div> +</div> +<p class="rubric">Options</p> +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-version"> +<code class="sig-name descname">--version</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-version" title="Permalink to this definition">¶</a></dt> +<dd><p>Show the version and exit.</p> +</dd></dl> + +<div class="section" id="pathflowai-visualize-extract-patch"> +<h3>extract_patch<a class="headerlink" href="#pathflowai-visualize-extract-patch" title="Permalink to this headline">¶</a></h3> +<p>Extract image of patch of any size/location and output to image file</p> +<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-visualize extract_patch <span class="o">[</span>OPTIONS<span class="o">]</span> +</pre></div> +</div> +<p class="rubric">Options</p> +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-extract-patch-i"> +<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--input_dir</code><code class="sig-prename descclassname"> <input_dir></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-i" title="Permalink to this definition">¶</a></dt> +<dd><p>Input directory for patches. [default: ./inputs/]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-extract-patch-b"> +<code class="sig-name descname">-b</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--basename</code><code class="sig-prename descclassname"> <basename></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-b" title="Permalink to this definition">¶</a></dt> +<dd><p>Basename of patches. [default: A01]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-extract-patch-p"> +<code class="sig-name descname">-p</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--patch_info_file</code><code class="sig-prename descclassname"> <patch_info_file></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-p" title="Permalink to this definition">¶</a></dt> +<dd><p>Datbase containing all patches [default: patch_info.db]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-extract-patch-ps"> +<code class="sig-name descname">-ps</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--patch_size</code><code class="sig-prename descclassname"> <patch_size></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-ps" title="Permalink to this definition">¶</a></dt> +<dd><p>Patch size. [default: 224]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-extract-patch-x"> +<code class="sig-name descname">-x</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--x</code><code class="sig-prename descclassname"> <x></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-x" title="Permalink to this definition">¶</a></dt> +<dd><p>X Coordinate of patch. [default: 0]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-extract-patch-y"> +<code class="sig-name descname">-y</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--y</code><code class="sig-prename descclassname"> <y></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-y" title="Permalink to this definition">¶</a></dt> +<dd><p>Y coordinate of patch. [default: 0]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-extract-patch-o"> +<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--outputfname</code><code class="sig-prename descclassname"> <outputfname></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-o" title="Permalink to this definition">¶</a></dt> +<dd><p>Output extracted image. [default: ./output_image.png]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-extract-patch-s"> +<code class="sig-name descname">-s</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--segmentation</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-s" title="Permalink to this definition">¶</a></dt> +<dd><p>Plot segmentations. [default: False]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-extract-patch-sc"> +<code class="sig-name descname">-sc</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--n_segmentation_classes</code><code class="sig-prename descclassname"> <n_segmentation_classes></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-sc" title="Permalink to this definition">¶</a></dt> +<dd><p>Number segmentation classes [default: 4]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-extract-patch-c"> +<code class="sig-name descname">-c</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--custom_segmentation</code><code class="sig-prename descclassname"> <custom_segmentation></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-c" title="Permalink to this definition">¶</a></dt> +<dd><p>Add custom segmentation map from prediction, in npy [default: ]</p> +</dd></dl> + +</div> +<div class="section" id="pathflowai-visualize-overlay-new-annotations"> +<h3>overlay_new_annotations<a class="headerlink" href="#pathflowai-visualize-overlay-new-annotations" title="Permalink to this headline">¶</a></h3> +<p>Custom annotations, in format [Point: x, y, Point: x, y … ] one line like this per polygon, overlap these polygons on top of WSI.</p> +<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-visualize overlay_new_annotations <span class="o">[</span>OPTIONS<span class="o">]</span> +</pre></div> +</div> +<p class="rubric">Options</p> +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-overlay-new-annotations-i"> +<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--img_file</code><code class="sig-prename descclassname"> <img_file></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-overlay-new-annotations-i" title="Permalink to this definition">¶</a></dt> +<dd><p>Input image. [default: image.txt]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-overlay-new-annotations-a"> +<code class="sig-name descname">-a</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--annotation_txt</code><code class="sig-prename descclassname"> <annotation_txt></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-overlay-new-annotations-a" title="Permalink to this definition">¶</a></dt> +<dd><p>Column of annotations [default: annotation.txt]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-overlay-new-annotations-ocf"> +<code class="sig-name descname">-ocf</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--original_compression_factor</code><code class="sig-prename descclassname"> <original_compression_factor></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-overlay-new-annotations-ocf" title="Permalink to this definition">¶</a></dt> +<dd><p>How much compress image. [default: 1.0]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-overlay-new-annotations-cf"> +<code class="sig-name descname">-cf</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--compression_factor</code><code class="sig-prename descclassname"> <compression_factor></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-overlay-new-annotations-cf" title="Permalink to this definition">¶</a></dt> +<dd><p>How much compress image. [default: 3.0]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-overlay-new-annotations-o"> +<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--outputfilename</code><code class="sig-prename descclassname"> <outputfilename></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-overlay-new-annotations-o" title="Permalink to this definition">¶</a></dt> +<dd><p>Output extracted image. [default: ./output_image.png]</p> +</dd></dl> + +</div> +<div class="section" id="pathflowai-visualize-plot-embeddings"> +<h3>plot_embeddings<a class="headerlink" href="#pathflowai-visualize-plot-embeddings" title="Permalink to this headline">¶</a></h3> +<p>Perform UMAP embeddings of patches and plot using plotly.</p> +<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-visualize plot_embeddings <span class="o">[</span>OPTIONS<span class="o">]</span> +</pre></div> +</div> +<p class="rubric">Options</p> +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-embeddings-i"> +<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--embeddings_file</code><code class="sig-prename descclassname"> <embeddings_file></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-embeddings-i" title="Permalink to this definition">¶</a></dt> +<dd><p>Embeddings. [default: predictions/embeddings.pkl]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-embeddings-o"> +<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--plotly_output_file</code><code class="sig-prename descclassname"> <plotly_output_file></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-embeddings-o" title="Permalink to this definition">¶</a></dt> +<dd><p>Plotly output file. [default: predictions/embeddings.html]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-embeddings-a"> +<code class="sig-name descname">-a</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--annotations</code><code class="sig-prename descclassname"> <annotations></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-embeddings-a" title="Permalink to this definition">¶</a></dt> +<dd><p>Multiple annotations to color image. [default: ]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-embeddings-rb"> +<code class="sig-name descname">-rb</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--remove_background_annotation</code><code class="sig-prename descclassname"> <remove_background_annotation></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-embeddings-rb" title="Permalink to this definition">¶</a></dt> +<dd><p>If selected, removes 100% background patches based on this annotation. [default: ]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-embeddings-ma"> +<code class="sig-name descname">-ma</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--max_background_area</code><code class="sig-prename descclassname"> <max_background_area></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-embeddings-ma" title="Permalink to this definition">¶</a></dt> +<dd><p>Max background area before exclusion. [default: 0.05]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-embeddings-b"> +<code class="sig-name descname">-b</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--basename</code><code class="sig-prename descclassname"> <basename></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-embeddings-b" title="Permalink to this definition">¶</a></dt> +<dd><p>Basename of patches. [default: ]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-embeddings-nn"> +<code class="sig-name descname">-nn</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--n_neighbors</code><code class="sig-prename descclassname"> <n_neighbors></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-embeddings-nn" title="Permalink to this definition">¶</a></dt> +<dd><p>Number nearest neighbors. [default: 8]</p> +</dd></dl> + +</div> +<div class="section" id="pathflowai-visualize-plot-image"> +<h3>plot_image<a class="headerlink" href="#pathflowai-visualize-plot-image" title="Permalink to this headline">¶</a></h3> +<p>Plots the whole slide image supplied.</p> +<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-visualize plot_image <span class="o">[</span>OPTIONS<span class="o">]</span> +</pre></div> +</div> +<p class="rubric">Options</p> +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-image-i"> +<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--image_file</code><code class="sig-prename descclassname"> <image_file></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-i" title="Permalink to this definition">¶</a></dt> +<dd><p>Input image file. [default: ./inputs/a.svs]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-image-cf"> +<code class="sig-name descname">-cf</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--compression_factor</code><code class="sig-prename descclassname"> <compression_factor></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-cf" title="Permalink to this definition">¶</a></dt> +<dd><p>How much compress image. [default: 3.0]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-image-o"> +<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--outputfname</code><code class="sig-prename descclassname"> <outputfname></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-o" title="Permalink to this definition">¶</a></dt> +<dd><p>Output extracted image. [default: ./output_image.png]</p> +</dd></dl> + +</div> +<div class="section" id="pathflowai-visualize-plot-image-umap-embeddings"> +<h3>plot_image_umap_embeddings<a class="headerlink" href="#pathflowai-visualize-plot-image-umap-embeddings" title="Permalink to this headline">¶</a></h3> +<p>Plots a UMAP embedding with each point as its corresponding patch image.</p> +<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-visualize plot_image_umap_embeddings <span class="o">[</span>OPTIONS<span class="o">]</span> +</pre></div> +</div> +<p class="rubric">Options</p> +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-i"> +<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--input_dir</code><code class="sig-prename descclassname"> <input_dir></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-i" title="Permalink to this definition">¶</a></dt> +<dd><p>Input directory for patches. [default: ./inputs/]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-e"> +<code class="sig-name descname">-e</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--embeddings_file</code><code class="sig-prename descclassname"> <embeddings_file></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-e" title="Permalink to this definition">¶</a></dt> +<dd><p>Embeddings. [default: predictions/embeddings.pkl]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-b"> +<code class="sig-name descname">-b</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--basename</code><code class="sig-prename descclassname"> <basename></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-b" title="Permalink to this definition">¶</a></dt> +<dd><p>Basename of patches. [default: ]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-o"> +<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--outputfilename</code><code class="sig-prename descclassname"> <outputfilename></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-o" title="Permalink to this definition">¶</a></dt> +<dd><p>Embedding visualization. [default: predictions/shap_plots.png]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-mpl"> +<code class="sig-name descname">-mpl</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--mpl_scatter</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-mpl" title="Permalink to this definition">¶</a></dt> +<dd><p>Plot segmentations. [default: False]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-rb"> +<code class="sig-name descname">-rb</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--remove_background_annotation</code><code class="sig-prename descclassname"> <remove_background_annotation></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-rb" title="Permalink to this definition">¶</a></dt> +<dd><p>If selected, removes 100% background patches based on this annotation. [default: ]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-ma"> +<code class="sig-name descname">-ma</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--max_background_area</code><code class="sig-prename descclassname"> <max_background_area></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-ma" title="Permalink to this definition">¶</a></dt> +<dd><p>Max background area before exclusion. [default: 0.05]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-z"> +<code class="sig-name descname">-z</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--zoom</code><code class="sig-prename descclassname"> <zoom></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-z" title="Permalink to this definition">¶</a></dt> +<dd><p>Size of images. [default: 0.05]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-nn"> +<code class="sig-name descname">-nn</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--n_neighbors</code><code class="sig-prename descclassname"> <n_neighbors></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-nn" title="Permalink to this definition">¶</a></dt> +<dd><p>Number nearest neighbors. [default: 8]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-sc"> +<code class="sig-name descname">-sc</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--sort_col</code><code class="sig-prename descclassname"> <sort_col></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-sc" title="Permalink to this definition">¶</a></dt> +<dd><p>Sort samples on this column. [default: ]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-sm"> +<code class="sig-name descname">-sm</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--sort_mode</code><code class="sig-prename descclassname"> <sort_mode></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-sm" title="Permalink to this definition">¶</a></dt> +<dd><p>Sort ascending or descending. [default: asc]</p> +<dl class="field-list simple"> +<dt class="field-odd">Options</dt> +<dd class="field-odd"><p>asc|desc</p> +</dd> +</dl> +</dd></dl> + +</div> +<div class="section" id="pathflowai-visualize-plot-predictions"> +<h3>plot_predictions<a class="headerlink" href="#pathflowai-visualize-plot-predictions" title="Permalink to this headline">¶</a></h3> +<p>Overlays classification, regression and segmentation patch level predictions on top of whole slide image.</p> +<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-visualize plot_predictions <span class="o">[</span>OPTIONS<span class="o">]</span> +</pre></div> +</div> +<p class="rubric">Options</p> +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-predictions-i"> +<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--input_dir</code><code class="sig-prename descclassname"> <input_dir></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-i" title="Permalink to this definition">¶</a></dt> +<dd><p>Input directory for patches. [default: ./inputs/]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-predictions-b"> +<code class="sig-name descname">-b</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--basename</code><code class="sig-prename descclassname"> <basename></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-b" title="Permalink to this definition">¶</a></dt> +<dd><p>Basename of patches. [default: A01]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-predictions-p"> +<code class="sig-name descname">-p</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--patch_info_file</code><code class="sig-prename descclassname"> <patch_info_file></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-p" title="Permalink to this definition">¶</a></dt> +<dd><p>Datbase containing all patches [default: patch_info.db]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-predictions-ps"> +<code class="sig-name descname">-ps</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--patch_size</code><code class="sig-prename descclassname"> <patch_size></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-ps" title="Permalink to this definition">¶</a></dt> +<dd><p>Patch size. [default: 224]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-predictions-o"> +<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--outputfname</code><code class="sig-prename descclassname"> <outputfname></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-o" title="Permalink to this definition">¶</a></dt> +<dd><p>Output extracted image. [default: ./output_image.png]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-predictions-an"> +<code class="sig-name descname">-an</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--annotations</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-an" title="Permalink to this definition">¶</a></dt> +<dd><p>Plot annotations instead of predictions. [default: False]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-predictions-cf"> +<code class="sig-name descname">-cf</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--compression_factor</code><code class="sig-prename descclassname"> <compression_factor></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-cf" title="Permalink to this definition">¶</a></dt> +<dd><p>How much compress image. [default: 3.0]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-predictions-al"> +<code class="sig-name descname">-al</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--alpha</code><code class="sig-prename descclassname"> <alpha></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-al" title="Permalink to this definition">¶</a></dt> +<dd><p>How much to give annotations/predictions versus original image. [default: 0.8]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-predictions-s"> +<code class="sig-name descname">-s</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--segmentation</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-s" title="Permalink to this definition">¶</a></dt> +<dd><p>Plot segmentations. [default: False]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-predictions-sc"> +<code class="sig-name descname">-sc</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--n_segmentation_classes</code><code class="sig-prename descclassname"> <n_segmentation_classes></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-sc" title="Permalink to this definition">¶</a></dt> +<dd><p>Number segmentation classes [default: 4]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-predictions-c"> +<code class="sig-name descname">-c</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--custom_segmentation</code><code class="sig-prename descclassname"> <custom_segmentation></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-c" title="Permalink to this definition">¶</a></dt> +<dd><p>Add custom segmentation map from prediction, npy format. [default: ]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-predictions-ac"> +<code class="sig-name descname">-ac</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--annotation_col</code><code class="sig-prename descclassname"> <annotation_col></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-ac" title="Permalink to this definition">¶</a></dt> +<dd><p>Column of annotations [default: annotation]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-predictions-sf"> +<code class="sig-name descname">-sf</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--scaling_factor</code><code class="sig-prename descclassname"> <scaling_factor></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-sf" title="Permalink to this definition">¶</a></dt> +<dd><p>Multiply all prediction scores by this amount. [default: 1.0]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-plot-predictions-tif"> +<code class="sig-name descname">-tif</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--tif_file</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-tif" title="Permalink to this definition">¶</a></dt> +<dd><p>Write to tiff file. [default: False]</p> +</dd></dl> + +</div> +<div class="section" id="pathflowai-visualize-shapley-plot"> +<h3>shapley_plot<a class="headerlink" href="#pathflowai-visualize-shapley-plot" title="Permalink to this headline">¶</a></h3> +<p>Run SHAPley attribution method on patches after classification task to see where model made prediction based on.</p> +<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-visualize shapley_plot <span class="o">[</span>OPTIONS<span class="o">]</span> +</pre></div> +</div> +<p class="rubric">Options</p> +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-shapley-plot-m"> +<code class="sig-name descname">-m</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--model_pkl</code><code class="sig-prename descclassname"> <model_pkl></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-shapley-plot-m" title="Permalink to this definition">¶</a></dt> +<dd><p>Plotly output file. [default: ]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-shapley-plot-bs"> +<code class="sig-name descname">-bs</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--batch_size</code><code class="sig-prename descclassname"> <batch_size></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-shapley-plot-bs" title="Permalink to this definition">¶</a></dt> +<dd><p>Batch size. [default: 32]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-shapley-plot-o"> +<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--outputfilename</code><code class="sig-prename descclassname"> <outputfilename></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-shapley-plot-o" title="Permalink to this definition">¶</a></dt> +<dd><p>SHAPley visualization. [default: predictions/shap_plots.png]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-shapley-plot-mth"> +<code class="sig-name descname">-mth</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--method</code><code class="sig-prename descclassname"> <method></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-shapley-plot-mth" title="Permalink to this definition">¶</a></dt> +<dd><p>Method of explaining. [default: deep]</p> +<dl class="field-list simple"> +<dt class="field-odd">Options</dt> +<dd class="field-odd"><p>deep|gradient</p> +</dd> +</dl> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-shapley-plot-l"> +<code class="sig-name descname">-l</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--local_smoothing</code><code class="sig-prename descclassname"> <local_smoothing></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-shapley-plot-l" title="Permalink to this definition">¶</a></dt> +<dd><p>Local smoothing of SHAP scores. [default: 0.0]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-shapley-plot-ns"> +<code class="sig-name descname">-ns</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--n_samples</code><code class="sig-prename descclassname"> <n_samples></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-shapley-plot-ns" title="Permalink to this definition">¶</a></dt> +<dd><p>Number shapley samples for shapley regression (gradient explainer). [default: 32]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-visualize-shapley-plot-p"> +<code class="sig-name descname">-p</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--pred_out</code><code class="sig-prename descclassname"> <pred_out></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-shapley-plot-p" title="Permalink to this definition">¶</a></dt> +<dd><p>If not none, output prediction as shap label. [default: none]</p> +<dl class="field-list simple"> +<dt class="field-odd">Options</dt> +<dd class="field-odd"><p>none|sigmoid|softmax</p> +</dd> +</dl> +</dd></dl> + +</div> +</div> +<div class="section" id="pathflowai-monitor"> +<h2>pathflowai-monitor<a class="headerlink" href="#pathflowai-monitor" title="Permalink to this headline">¶</a></h2> +<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-monitor <span class="o">[</span>OPTIONS<span class="o">]</span> COMMAND <span class="o">[</span>ARGS<span class="o">]</span>... +</pre></div> +</div> +<p class="rubric">Options</p> +<dl class="option"> +<dt id="cmdoption-pathflowai-monitor-version"> +<code class="sig-name descname">--version</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-monitor-version" title="Permalink to this definition">¶</a></dt> +<dd><p>Show the version and exit.</p> +</dd></dl> + +<div class="section" id="pathflowai-monitor-monitor-usage"> +<h3>monitor_usage<a class="headerlink" href="#pathflowai-monitor-monitor-usage" title="Permalink to this headline">¶</a></h3> +<p>Monitor Usage over Time Interval.</p> +<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-monitor monitor_usage <span class="o">[</span>OPTIONS<span class="o">]</span> +</pre></div> +</div> +<p class="rubric">Options</p> +<dl class="option"> +<dt id="cmdoption-pathflowai-monitor-monitor-usage-csv"> +<code class="sig-name descname">-csv</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--records_output_csv</code><code class="sig-prename descclassname"> <records_output_csv></code><a class="headerlink" href="#cmdoption-pathflowai-monitor-monitor-usage-csv" title="Permalink to this definition">¶</a></dt> +<dd><p>Where to store records. [default: records.csv]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-monitor-monitor-usage-tt"> +<code class="sig-name descname">-tt</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--total_time</code><code class="sig-prename descclassname"> <total_time></code><a class="headerlink" href="#cmdoption-pathflowai-monitor-monitor-usage-tt" title="Permalink to this definition">¶</a></dt> +<dd><p>Total time to monitor for in minutes. [default: 1.0]</p> +</dd></dl> + +<dl class="option"> +<dt id="cmdoption-pathflowai-monitor-monitor-usage-dt"> +<code class="sig-name descname">-dt</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--delay_time</code><code class="sig-prename descclassname"> <delay_time></code><a class="headerlink" href="#cmdoption-pathflowai-monitor-monitor-usage-dt" title="Permalink to this definition">¶</a></dt> +<dd><p>Time between samples, in seconds. [default: 1.0]</p> +</dd></dl> + +</div> +</div> +<span class="target" id="module-pathflowai.datasets"></span><div class="section" id="datasets-py"> +<h2>datasets.py<a class="headerlink" href="#datasets-py" title="Permalink to this headline">¶</a></h2> +<p>Houses the DynamicImageDataset class, also functions to help with image color channel normalization, transformers, etc..</p> +<dl class="class"> +<dt id="pathflowai.datasets.DynamicImageDataset"> +<em class="property">class </em><code class="sig-prename descclassname">pathflowai.datasets.</code><code class="sig-name descname">DynamicImageDataset</code><span class="sig-paren">(</span><em class="sig-param">dataset_df</em>, <em class="sig-param">set</em>, <em class="sig-param">patch_info_file</em>, <em class="sig-param">transformers</em>, <em class="sig-param">input_dir</em>, <em class="sig-param">target_names</em>, <em class="sig-param">pos_annotation_class</em>, <em class="sig-param">other_annotations=[]</em>, <em class="sig-param">segmentation=False</em>, <em class="sig-param">patch_size=224</em>, <em class="sig-param">fix_names=True</em>, <em class="sig-param">target_segmentation_class=-1</em>, <em class="sig-param">target_threshold=0.0</em>, <em class="sig-param">oversampling_factor=1.0</em>, <em class="sig-param">n_segmentation_classes=4</em>, <em class="sig-param">gdl=False</em>, <em class="sig-param">mt_bce=False</em>, <em class="sig-param">classify_annotations=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#DynamicImageDataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.DynamicImageDataset" title="Permalink to this definition">¶</a></dt> +<dd><p>Generate image dataset that accesses images and annotations via dask.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>dataset_df:dataframe</strong></dt><dd><p>Dataframe with WSI, which set it is in (train/test/val) and corresponding WSI labels if applicable.</p> +</dd> +<dt><strong>set:str</strong></dt><dd><p>Whether train, test, val or pass (normalization) set.</p> +</dd> +<dt><strong>patch_info_file:str</strong></dt><dd><p>SQL db with positional and annotation information on each slide.</p> +</dd> +<dt><strong>transformers:dict</strong></dt><dd><p>Contains transformers to apply on images.</p> +</dd> +<dt><strong>input_dir:str</strong></dt><dd><p>Directory where images comes from.</p> +</dd> +<dt><strong>target_names:list/str</strong></dt><dd><p>Names of initial targets, which may be modified.</p> +</dd> +<dt><strong>pos_annotation_class:str</strong></dt><dd><p>If selected and predicting on WSI, this class is labeled as a positive from the WSI, while the other classes are not.</p> +</dd> +<dt><strong>other_annotations:list</strong></dt><dd><p>Other annotations to consider from patch info db.</p> +</dd> +<dt><strong>segmentation:bool</strong></dt><dd><p>Conducting segmentation task?</p> +</dd> +<dt><strong>patch_size:int</strong></dt><dd><p>Patch size.</p> +</dd> +<dt><strong>fix_names:bool</strong></dt><dd><p>Whether to change the names of dataset_df.</p> +</dd> +<dt><strong>target_segmentation_class:list</strong></dt><dd><p>Now can be used for classification as well, matched with two below options, samples images only from this class. Can specify this and below two options multiple times.</p> +</dd> +<dt><strong>target_threshold:list</strong></dt><dd><p>Sampled only if above this threshold of occurence in the patches.</p> +</dd> +<dt><strong>oversampling_factor:list</strong></dt><dd><p>Over sample them at this amount.</p> +</dd> +<dt><strong>n_segmentation_classes:int</strong></dt><dd><p>Number classes to segment.</p> +</dd> +<dt><strong>gdl:bool</strong></dt><dd><p>Using generalized dice loss?</p> +</dd> +<dt><strong>mt_bce:bool</strong></dt><dd><p>For multi-target prediction tasks.</p> +</dd> +<dt><strong>classify_annotations:bool</strong></dt><dd><p>For classifying annotations.</p> +</dd> +</dl> +</dd> +</dl> +<p class="rubric">Methods</p> +<table class="longtable docutils align-default"> +<colgroup> +<col style="width: 10%" /> +<col style="width: 90%" /> +</colgroup> +<tbody> +<tr class="row-odd"><td><p><a class="reference internal" href="#pathflowai.datasets.DynamicImageDataset.binarize_annotations" title="pathflowai.datasets.DynamicImageDataset.binarize_annotations"><code class="xref py py-obj docutils literal notranslate"><span class="pre">binarize_annotations</span></code></a>(self[, binarizer, …])</p></td> +<td><p>Label binarize some annotations or threshold them if classifying slide annotations.</p></td> +</tr> +<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.datasets.DynamicImageDataset.concat" title="pathflowai.datasets.DynamicImageDataset.concat"><code class="xref py py-obj docutils literal notranslate"><span class="pre">concat</span></code></a>(self, other_dataset)</p></td> +<td><p>Concatenate this dataset with others.</p></td> +</tr> +<tr class="row-odd"><td><p><a class="reference internal" href="#pathflowai.datasets.DynamicImageDataset.get_class_weights" title="pathflowai.datasets.DynamicImageDataset.get_class_weights"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_class_weights</span></code></a>(self[, i])</p></td> +<td><p>Weight loss function with weights inversely proportional to the class appearence.</p></td> +</tr> +<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.datasets.DynamicImageDataset.retain_ID" title="pathflowai.datasets.DynamicImageDataset.retain_ID"><code class="xref py py-obj docutils literal notranslate"><span class="pre">retain_ID</span></code></a>(self, ID)</p></td> +<td><p>Reduce the sample set to just images from one ID.</p></td> +</tr> +<tr class="row-odd"><td><p><a class="reference internal" href="#pathflowai.datasets.DynamicImageDataset.split_by_ID" title="pathflowai.datasets.DynamicImageDataset.split_by_ID"><code class="xref py py-obj docutils literal notranslate"><span class="pre">split_by_ID</span></code></a>(self)</p></td> +<td><p>Generator similar to groupby, but splits up by ID, generates (ID,data) using retain_ID.</p></td> +</tr> +<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.datasets.DynamicImageDataset.subsample" title="pathflowai.datasets.DynamicImageDataset.subsample"><code class="xref py py-obj docutils literal notranslate"><span class="pre">subsample</span></code></a>(self, p)</p></td> +<td><p>Sample subset of dataset.</p></td> +</tr> +</tbody> +</table> +<dl class="method"> +<dt id="pathflowai.datasets.DynamicImageDataset.binarize_annotations"> +<code class="sig-name descname">binarize_annotations</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">binarizer=None</em>, <em class="sig-param">num_targets=1</em>, <em class="sig-param">binary_threshold=0.0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#DynamicImageDataset.binarize_annotations"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.DynamicImageDataset.binarize_annotations" title="Permalink to this definition">¶</a></dt> +<dd><p>Label binarize some annotations or threshold them if classifying slide annotations.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>binarizer:LabelBinarizer</strong></dt><dd><p>Binarizes the labels of a column(s)</p> +</dd> +<dt><strong>num_targets:int</strong></dt><dd><p>Number of desired targets to preidict on.</p> +</dd> +<dt><strong>binary_threshold:float</strong></dt><dd><p>Amount of annotation in patch before positive annotation.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>binarizer</dt><dd></dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="method"> +<dt id="pathflowai.datasets.DynamicImageDataset.concat"> +<code class="sig-name descname">concat</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">other_dataset</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#DynamicImageDataset.concat"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.DynamicImageDataset.concat" title="Permalink to this definition">¶</a></dt> +<dd><p>Concatenate this dataset with others. Updates its own internal attributes.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>other_dataset:DynamicImageDataset</strong></dt><dd><p>Other image dataset.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="method"> +<dt id="pathflowai.datasets.DynamicImageDataset.get_class_weights"> +<code class="sig-name descname">get_class_weights</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">i=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#DynamicImageDataset.get_class_weights"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.DynamicImageDataset.get_class_weights" title="Permalink to this definition">¶</a></dt> +<dd><p>Weight loss function with weights inversely proportional to the class appearence.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>i:int</strong></dt><dd><p>If multi-target, class used for weighting.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>self</dt><dd><p>Dataset.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="method"> +<dt id="pathflowai.datasets.DynamicImageDataset.retain_ID"> +<code class="sig-name descname">retain_ID</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">ID</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#DynamicImageDataset.retain_ID"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.DynamicImageDataset.retain_ID" title="Permalink to this definition">¶</a></dt> +<dd><p>Reduce the sample set to just images from one ID.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>ID:str</strong></dt><dd><p>Basename/ID to predict on.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>self</dt><dd></dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="method"> +<dt id="pathflowai.datasets.DynamicImageDataset.split_by_ID"> +<code class="sig-name descname">split_by_ID</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#DynamicImageDataset.split_by_ID"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.DynamicImageDataset.split_by_ID" title="Permalink to this definition">¶</a></dt> +<dd><p>Generator similar to groupby, but splits up by ID, generates (ID,data) using retain_ID.</p> +<dl class="field-list simple"> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><dl class="simple"> +<dt>generator</dt><dd><p>ID, DynamicDataset</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="method"> +<dt id="pathflowai.datasets.DynamicImageDataset.subsample"> +<code class="sig-name descname">subsample</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">p</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#DynamicImageDataset.subsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.DynamicImageDataset.subsample" title="Permalink to this definition">¶</a></dt> +<dd><p>Sample subset of dataset.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>p:float</strong></dt><dd><p>Fraction to subsample.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.datasets.RandomRotate90"> +<code class="sig-prename descclassname">pathflowai.datasets.</code><code class="sig-name descname">RandomRotate90</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#RandomRotate90"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.RandomRotate90" title="Permalink to this definition">¶</a></dt> +<dd><p>Transformer for random 90 degree rotation image.</p> +<dl class="field-list simple"> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><dl class="simple"> +<dt>function</dt><dd><p>Transformer function for operation.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.datasets.create_transforms"> +<code class="sig-prename descclassname">pathflowai.datasets.</code><code class="sig-name descname">create_transforms</code><span class="sig-paren">(</span><em class="sig-param">mean</em>, <em class="sig-param">std</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#create_transforms"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.create_transforms" title="Permalink to this definition">¶</a></dt> +<dd><p>Create transformers.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>mean:list</strong></dt><dd><p>See get_data_transforms.</p> +</dd> +<dt><strong>std:list</strong></dt><dd><p>See get_data_transforms.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>dict</dt><dd><p>Transformers.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.datasets.get_data_transforms"> +<code class="sig-prename descclassname">pathflowai.datasets.</code><code class="sig-name descname">get_data_transforms</code><span class="sig-paren">(</span><em class="sig-param">patch_size=None</em>, <em class="sig-param">mean=[]</em>, <em class="sig-param">std=[]</em>, <em class="sig-param">resize=False</em>, <em class="sig-param">transform_platform='torch'</em>, <em class="sig-param">elastic=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#get_data_transforms"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.get_data_transforms" title="Permalink to this definition">¶</a></dt> +<dd><p>Get data transformers for training test and validation sets.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>patch_size:int</strong></dt><dd><p>Original patch size being transformed.</p> +</dd> +<dt><strong>mean:list of float</strong></dt><dd><p>Mean RGB</p> +</dd> +<dt><strong>std:list of float</strong></dt><dd><p>Std RGB</p> +</dd> +<dt><strong>resize:int</strong></dt><dd><p>Which patch size to resize to.</p> +</dd> +<dt><strong>transform_platform:str</strong></dt><dd><p>Use pytorch or albumentation transforms.</p> +</dd> +<dt><strong>elastic:bool</strong></dt><dd><p>Whether to add elastic deformations from albumentations.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>dict</dt><dd><p>Transformers.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.datasets.get_normalizer"> +<code class="sig-prename descclassname">pathflowai.datasets.</code><code class="sig-name descname">get_normalizer</code><span class="sig-paren">(</span><em class="sig-param">normalization_file</em>, <em class="sig-param">dataset_opts</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#get_normalizer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.get_normalizer" title="Permalink to this definition">¶</a></dt> +<dd><p>Find mean and standard deviation of images in batches.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>normalization_file:str</strong></dt><dd><p>File to store normalization information.</p> +</dd> +<dt><strong>dataset_opts:type</strong></dt><dd><p>Dictionary storing information to create DynamicDataset class.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>dict</dt><dd><p>Stores RGB mean, stdev.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.datasets.segmentation_transform"> +<code class="sig-prename descclassname">pathflowai.datasets.</code><code class="sig-name descname">segmentation_transform</code><span class="sig-paren">(</span><em class="sig-param">img</em>, <em class="sig-param">mask</em>, <em class="sig-param">transformer</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#segmentation_transform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.segmentation_transform" title="Permalink to this definition">¶</a></dt> +<dd><p>Run albumentations and return an image and its segmentation mask.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>img:array</strong></dt><dd><p>Image as array</p> +</dd> +<dt><strong>mask:array</strong></dt><dd><p>Categorical pixel by pixel.</p> +</dd> +<dt><strong>transformer :</strong></dt><dd><p>Transformation object.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>tuple arrays</dt><dd><p>Image and mask array.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +</div> +<span class="target" id="module-pathflowai.losses"></span><div class="section" id="losses-py"> +<h2>losses.py<a class="headerlink" href="#losses-py" title="Permalink to this headline">¶</a></h2> +<p>Some additional loss functions that can be called using the pipeline, some of which still to be implemented.</p> +<dl class="class"> +<dt id="pathflowai.losses.FocalLoss"> +<em class="property">class </em><code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">FocalLoss</code><span class="sig-paren">(</span><em class="sig-param">num_class</em>, <em class="sig-param">alpha=None</em>, <em class="sig-param">gamma=2</em>, <em class="sig-param">balance_index=-1</em>, <em class="sig-param">smooth=None</em>, <em class="sig-param">size_average=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/losses.html#FocalLoss"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.FocalLoss" title="Permalink to this definition">¶</a></dt> +<dd><p># <a class="reference external" href="https://raw.githubusercontent.com/Hsuxu/Loss_ToolBox-PyTorch/master/FocalLoss/FocalLoss.py">https://raw.githubusercontent.com/Hsuxu/Loss_ToolBox-PyTorch/master/FocalLoss/FocalLoss.py</a> +This is a implementation of Focal Loss with smooth label cross entropy supported which is proposed in +‘Focal Loss for Dense Object Detection. (<a class="reference external" href="https://arxiv.org/abs/1708.02002">https://arxiv.org/abs/1708.02002</a>)’</p> +<blockquote> +<div><p>Focal_Loss= -1*alpha*(1-pt)*log(pt)</p> +</div></blockquote> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>num_class</strong> – </p></li> +<li><p><strong>alpha</strong> – (tensor) 3D or 4D the scalar factor for this criterion</p></li> +<li><p><strong>gamma</strong> – (float,double) gamma > 0 reduces the relative loss for well-classified examples (p>0.5) putting more +focus on hard misclassified example</p></li> +<li><p><strong>smooth</strong> – (float,double) smooth value when cross entropy</p></li> +<li><p><strong>balance_index</strong> – (int) balance class index, should be specific when alpha is float</p></li> +<li><p><strong>size_average</strong> – (bool, optional) By default, the losses are averaged over each loss element in the batch.</p></li> +</ul> +</dd> +</dl> +<p class="rubric">Methods</p> +<table class="longtable docutils align-default"> +<colgroup> +<col style="width: 10%" /> +<col style="width: 90%" /> +</colgroup> +<tbody> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">__call__</span></code>(self, \*input, \*\*kwargs)</p></td> +<td><p>Call self as a function.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">add_module</span></code>(self, name, module)</p></td> +<td><p>Adds a child module to the current module.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">apply</span></code>(self, fn)</p></td> +<td><p>Applies <code class="docutils literal notranslate"><span class="pre">fn</span></code> recursively to every submodule (as returned by <code class="docutils literal notranslate"><span class="pre">.children()</span></code>) as well as self.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">buffers</span></code>(self[, recurse])</p></td> +<td><p>Returns an iterator over module buffers.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">children</span></code>(self)</p></td> +<td><p>Returns an iterator over immediate children modules.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">cpu</span></code>(self)</p></td> +<td><p>Moves all model parameters and buffers to the CPU.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">cuda</span></code>(self[, device])</p></td> +<td><p>Moves all model parameters and buffers to the GPU.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">double</span></code>(self)</p></td> +<td><p>Casts all floating point parameters and buffers to <code class="docutils literal notranslate"><span class="pre">double</span></code> datatype.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">eval</span></code>(self)</p></td> +<td><p>Sets the module in evaluation mode.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">extra_repr</span></code>(self)</p></td> +<td><p>Set the extra representation of the module</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">float</span></code>(self)</p></td> +<td><p>Casts all floating point parameters and buffers to float datatype.</p></td> +</tr> +<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.losses.FocalLoss.forward" title="pathflowai.losses.FocalLoss.forward"><code class="xref py py-obj docutils literal notranslate"><span class="pre">forward</span></code></a>(self, logit, target)</p></td> +<td><p>Defines the computation performed at every call.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">half</span></code>(self)</p></td> +<td><p>Casts all floating point parameters and buffers to <code class="docutils literal notranslate"><span class="pre">half</span></code> datatype.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">load_state_dict</span></code>(self, state_dict[, strict])</p></td> +<td><p>Copies parameters and buffers from <code class="xref py py-attr docutils literal notranslate"><span class="pre">state_dict</span></code> into this module and its descendants.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">modules</span></code>(self)</p></td> +<td><p>Returns an iterator over all modules in the network.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">named_buffers</span></code>(self[, prefix, recurse])</p></td> +<td><p>Returns an iterator over module buffers, yielding both the name of the buffer as well as the buffer itself.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">named_children</span></code>(self)</p></td> +<td><p>Returns an iterator over immediate children modules, yielding both the name of the module as well as the module itself.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">named_modules</span></code>(self[, memo, prefix])</p></td> +<td><p>Returns an iterator over all modules in the network, yielding both the name of the module as well as the module itself.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">named_parameters</span></code>(self[, prefix, recurse])</p></td> +<td><p>Returns an iterator over module parameters, yielding both the name of the parameter as well as the parameter itself.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">parameters</span></code>(self[, recurse])</p></td> +<td><p>Returns an iterator over module parameters.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_backward_hook</span></code>(self, hook)</p></td> +<td><p>Registers a backward hook on the module.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_buffer</span></code>(self, name, tensor)</p></td> +<td><p>Adds a persistent buffer to the module.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_forward_hook</span></code>(self, hook)</p></td> +<td><p>Registers a forward hook on the module.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_forward_pre_hook</span></code>(self, hook)</p></td> +<td><p>Registers a forward pre-hook on the module.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_parameter</span></code>(self, name, param)</p></td> +<td><p>Adds a parameter to the module.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">state_dict</span></code>(self[, destination, prefix, …])</p></td> +<td><p>Returns a dictionary containing a whole state of the module.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">to</span></code>(self, \*args, \*\*kwargs)</p></td> +<td><p>Moves and/or casts the parameters and buffers.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">train</span></code>(self[, mode])</p></td> +<td><p>Sets the module in training mode.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">type</span></code>(self, dst_type)</p></td> +<td><p>Casts all parameters and buffers to <code class="xref py py-attr docutils literal notranslate"><span class="pre">dst_type</span></code>.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">zero_grad</span></code>(self)</p></td> +<td><p>Sets gradients of all model parameters to zero.</p></td> +</tr> +</tbody> +</table> +<table class="docutils align-default"> +<colgroup> +<col style="width: 62%" /> +<col style="width: 38%" /> +</colgroup> +<tbody> +<tr class="row-odd"><td><p><strong>share_memory</strong></p></td> +<td></td> +</tr> +</tbody> +</table> +<dl class="method"> +<dt id="pathflowai.losses.FocalLoss.forward"> +<code class="sig-name descname">forward</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">logit</em>, <em class="sig-param">target</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/losses.html#FocalLoss.forward"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.FocalLoss.forward" title="Permalink to this definition">¶</a></dt> +<dd><p>Defines the computation performed at every call.</p> +<p>Should be overridden by all subclasses.</p> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<p>Although the recipe for forward pass needs to be defined within +this function, one should call the <code class="xref py py-class docutils literal notranslate"><span class="pre">Module</span></code> instance afterwards +instead of this since the former takes care of running the +registered hooks while the latter silently ignores them.</p> +</div> +</dd></dl> + +</dd></dl> + +<dl class="class"> +<dt id="pathflowai.losses.GeneralizedDice"> +<em class="property">class </em><code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">GeneralizedDice</code><span class="sig-paren">(</span><em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/losses.html#GeneralizedDice"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.GeneralizedDice" title="Permalink to this definition">¶</a></dt> +<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/losses.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/losses.py</a></p> +<p class="rubric">Methods</p> +<table class="longtable docutils align-default"> +<colgroup> +<col style="width: 10%" /> +<col style="width: 90%" /> +</colgroup> +<tbody> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">__call__</span></code>(self, probs, target, _)</p></td> +<td><p>Call self as a function.</p></td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="class"> +<dt id="pathflowai.losses.GeneralizedDiceLoss"> +<em class="property">class </em><code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">GeneralizedDiceLoss</code><span class="sig-paren">(</span><em class="sig-param">weight=None</em>, <em class="sig-param">channelwise=False</em>, <em class="sig-param">eps=1e-06</em>, <em class="sig-param">add_softmax=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/losses.html#GeneralizedDiceLoss"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.GeneralizedDiceLoss" title="Permalink to this definition">¶</a></dt> +<dd><p><a class="reference external" href="https://raw.githubusercontent.com/inferno-pytorch/inferno/0561e8a95cde6bfc5e10a3609841b7b0ca5b03ca/inferno/extensions/criteria/set_similarity_measures.py">https://raw.githubusercontent.com/inferno-pytorch/inferno/0561e8a95cde6bfc5e10a3609841b7b0ca5b03ca/inferno/extensions/criteria/set_similarity_measures.py</a> +Computes the scalar Generalized Dice Loss defined in <a class="reference external" href="https://arxiv.org/abs/1707.03237">https://arxiv.org/abs/1707.03237</a></p> +<p>This version works for multiple classes and expects predictions for every class (e.g. softmax output) and +one-hot targets for every class.</p> +<p class="rubric">Methods</p> +<table class="longtable docutils align-default"> +<colgroup> +<col style="width: 10%" /> +<col style="width: 90%" /> +</colgroup> +<tbody> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">__call__</span></code>(self, \*input, \*\*kwargs)</p></td> +<td><p>Call self as a function.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">add_module</span></code>(self, name, module)</p></td> +<td><p>Adds a child module to the current module.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">apply</span></code>(self, fn)</p></td> +<td><p>Applies <code class="docutils literal notranslate"><span class="pre">fn</span></code> recursively to every submodule (as returned by <code class="docutils literal notranslate"><span class="pre">.children()</span></code>) as well as self.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">buffers</span></code>(self[, recurse])</p></td> +<td><p>Returns an iterator over module buffers.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">children</span></code>(self)</p></td> +<td><p>Returns an iterator over immediate children modules.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">cpu</span></code>(self)</p></td> +<td><p>Moves all model parameters and buffers to the CPU.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">cuda</span></code>(self[, device])</p></td> +<td><p>Moves all model parameters and buffers to the GPU.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">double</span></code>(self)</p></td> +<td><p>Casts all floating point parameters and buffers to <code class="docutils literal notranslate"><span class="pre">double</span></code> datatype.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">eval</span></code>(self)</p></td> +<td><p>Sets the module in evaluation mode.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">extra_repr</span></code>(self)</p></td> +<td><p>Set the extra representation of the module</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">float</span></code>(self)</p></td> +<td><p>Casts all floating point parameters and buffers to float datatype.</p></td> +</tr> +<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.losses.GeneralizedDiceLoss.forward" title="pathflowai.losses.GeneralizedDiceLoss.forward"><code class="xref py py-obj docutils literal notranslate"><span class="pre">forward</span></code></a>(self, input, target)</p></td> +<td><p>input: torch.FloatTensor or torch.cuda.FloatTensor target: torch.FloatTensor or torch.cuda.FloatTensor</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">half</span></code>(self)</p></td> +<td><p>Casts all floating point parameters and buffers to <code class="docutils literal notranslate"><span class="pre">half</span></code> datatype.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">load_state_dict</span></code>(self, state_dict[, strict])</p></td> +<td><p>Copies parameters and buffers from <code class="xref py py-attr docutils literal notranslate"><span class="pre">state_dict</span></code> into this module and its descendants.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">modules</span></code>(self)</p></td> +<td><p>Returns an iterator over all modules in the network.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">named_buffers</span></code>(self[, prefix, recurse])</p></td> +<td><p>Returns an iterator over module buffers, yielding both the name of the buffer as well as the buffer itself.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">named_children</span></code>(self)</p></td> +<td><p>Returns an iterator over immediate children modules, yielding both the name of the module as well as the module itself.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">named_modules</span></code>(self[, memo, prefix])</p></td> +<td><p>Returns an iterator over all modules in the network, yielding both the name of the module as well as the module itself.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">named_parameters</span></code>(self[, prefix, recurse])</p></td> +<td><p>Returns an iterator over module parameters, yielding both the name of the parameter as well as the parameter itself.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">parameters</span></code>(self[, recurse])</p></td> +<td><p>Returns an iterator over module parameters.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_backward_hook</span></code>(self, hook)</p></td> +<td><p>Registers a backward hook on the module.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_buffer</span></code>(self, name, tensor)</p></td> +<td><p>Adds a persistent buffer to the module.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_forward_hook</span></code>(self, hook)</p></td> +<td><p>Registers a forward hook on the module.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_forward_pre_hook</span></code>(self, hook)</p></td> +<td><p>Registers a forward pre-hook on the module.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_parameter</span></code>(self, name, param)</p></td> +<td><p>Adds a parameter to the module.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">state_dict</span></code>(self[, destination, prefix, …])</p></td> +<td><p>Returns a dictionary containing a whole state of the module.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">to</span></code>(self, \*args, \*\*kwargs)</p></td> +<td><p>Moves and/or casts the parameters and buffers.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">train</span></code>(self[, mode])</p></td> +<td><p>Sets the module in training mode.</p></td> +</tr> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">type</span></code>(self, dst_type)</p></td> +<td><p>Casts all parameters and buffers to <code class="xref py py-attr docutils literal notranslate"><span class="pre">dst_type</span></code>.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">zero_grad</span></code>(self)</p></td> +<td><p>Sets gradients of all model parameters to zero.</p></td> +</tr> +</tbody> +</table> +<table class="docutils align-default"> +<colgroup> +<col style="width: 62%" /> +<col style="width: 38%" /> +</colgroup> +<tbody> +<tr class="row-odd"><td><p><strong>share_memory</strong></p></td> +<td></td> +</tr> +</tbody> +</table> +<dl class="method"> +<dt id="pathflowai.losses.GeneralizedDiceLoss.forward"> +<code class="sig-name descname">forward</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">input</em>, <em class="sig-param">target</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/losses.html#GeneralizedDiceLoss.forward"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.GeneralizedDiceLoss.forward" title="Permalink to this definition">¶</a></dt> +<dd><p>input: torch.FloatTensor or torch.cuda.FloatTensor +target: torch.FloatTensor or torch.cuda.FloatTensor</p> +<dl class="simple"> +<dt>Expected shape of the inputs:</dt><dd><ul class="simple"> +<li><p>if not channelwise: (batch_size, nb_classes, …)</p></li> +<li><p>if channelwise: (batch_size, nb_channels, nb_classes, …)</p></li> +</ul> +</dd> +</dl> +</dd></dl> + +</dd></dl> + +<dl class="exception"> +<dt id="pathflowai.losses.ShapeError"> +<em class="property">exception </em><code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">ShapeError</code><a class="reference internal" href="_modules/pathflowai/losses.html#ShapeError"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.ShapeError" title="Permalink to this definition">¶</a></dt> +<dd></dd></dl> + +<dl class="class"> +<dt id="pathflowai.losses.SurfaceLoss"> +<em class="property">class </em><code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">SurfaceLoss</code><span class="sig-paren">(</span><em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/losses.html#SurfaceLoss"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.SurfaceLoss" title="Permalink to this definition">¶</a></dt> +<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/losses.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/losses.py</a></p> +<p class="rubric">Methods</p> +<table class="longtable docutils align-default"> +<colgroup> +<col style="width: 10%" /> +<col style="width: 90%" /> +</colgroup> +<tbody> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">__call__</span></code>(self, probs, dist_maps, _)</p></td> +<td><p>Call self as a function.</p></td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.losses.assert_"> +<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">assert_</code><span class="sig-paren">(</span><em class="sig-param">condition</em>, <em class="sig-param">message=''</em>, <em class="sig-param">exception_type=<class 'AssertionError'></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/losses.html#assert_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.assert_" title="Permalink to this definition">¶</a></dt> +<dd><p><a class="reference external" href="https://raw.githubusercontent.com/inferno-pytorch/inferno/0561e8a95cde6bfc5e10a3609841b7b0ca5b03ca/inferno/utils/exceptions.py">https://raw.githubusercontent.com/inferno-pytorch/inferno/0561e8a95cde6bfc5e10a3609841b7b0ca5b03ca/inferno/utils/exceptions.py</a> +Like assert, but with arbitrary exception types.</p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.losses.class2one_hot"> +<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">class2one_hot</code><span class="sig-paren">(</span><em class="sig-param">seg:torch.Tensor</em>, <em class="sig-param">C:int</em><span class="sig-paren">)</span> → torch.Tensor<a class="reference internal" href="_modules/pathflowai/losses.html#class2one_hot"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.class2one_hot" title="Permalink to this definition">¶</a></dt> +<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py</a></p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.losses.eq"> +<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">eq</code><span class="sig-paren">(</span><em class="sig-param">a:torch.Tensor</em>, <em class="sig-param">b</em><span class="sig-paren">)</span> → bool<a class="reference internal" href="_modules/pathflowai/losses.html#eq"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.eq" title="Permalink to this definition">¶</a></dt> +<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py</a></p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.losses.flatten_samples"> +<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">flatten_samples</code><span class="sig-paren">(</span><em class="sig-param">input_</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/losses.html#flatten_samples"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.flatten_samples" title="Permalink to this definition">¶</a></dt> +<dd><p><a class="reference external" href="https://raw.githubusercontent.com/inferno-pytorch/inferno/0561e8a95cde6bfc5e10a3609841b7b0ca5b03ca/inferno/utils/torch_utils.py">https://raw.githubusercontent.com/inferno-pytorch/inferno/0561e8a95cde6bfc5e10a3609841b7b0ca5b03ca/inferno/utils/torch_utils.py</a> +Flattens a tensor or a variable such that the channel axis is first and the sample axis +is second. The shapes are transformed as follows:</p> +<blockquote> +<div><p>(N, C, H, W) –> (C, N * H * W) +(N, C, D, H, W) –> (C, N * D * H * W) +(N, C) –> (C, N)</p> +</div></blockquote> +<p>The input must be atleast 2d.</p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.losses.one_hot"> +<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">one_hot</code><span class="sig-paren">(</span><em class="sig-param">t:torch.Tensor</em>, <em class="sig-param">axis=1</em><span class="sig-paren">)</span> → bool<a class="reference internal" href="_modules/pathflowai/losses.html#one_hot"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.one_hot" title="Permalink to this definition">¶</a></dt> +<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py</a></p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.losses.one_hot2dist"> +<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">one_hot2dist</code><span class="sig-paren">(</span><em class="sig-param">seg:numpy.ndarray</em><span class="sig-paren">)</span> → numpy.ndarray<a class="reference internal" href="_modules/pathflowai/losses.html#one_hot2dist"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.one_hot2dist" title="Permalink to this definition">¶</a></dt> +<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py</a></p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.losses.simplex"> +<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">simplex</code><span class="sig-paren">(</span><em class="sig-param">t:torch.Tensor</em>, <em class="sig-param">axis=1</em><span class="sig-paren">)</span> → bool<a class="reference internal" href="_modules/pathflowai/losses.html#simplex"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.simplex" title="Permalink to this definition">¶</a></dt> +<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py</a></p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.losses.sset"> +<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">sset</code><span class="sig-paren">(</span><em class="sig-param">a:torch.Tensor</em>, <em class="sig-param">sub:Iterable</em><span class="sig-paren">)</span> → bool<a class="reference internal" href="_modules/pathflowai/losses.html#sset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.sset" title="Permalink to this definition">¶</a></dt> +<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py</a></p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.losses.uniq"> +<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">uniq</code><span class="sig-paren">(</span><em class="sig-param">a:torch.Tensor</em><span class="sig-paren">)</span> → Set<a class="reference internal" href="_modules/pathflowai/losses.html#uniq"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.uniq" title="Permalink to this definition">¶</a></dt> +<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py</a></p> +</dd></dl> + +</div> +<span class="target" id="module-pathflowai.sampler"></span><div class="section" id="sampler-py"> +<h2>sampler.py<a class="headerlink" href="#sampler-py" title="Permalink to this headline">¶</a></h2> +<p>Balanced sampling based on one of the columns of the patch information.</p> +<dl class="class"> +<dt id="pathflowai.sampler.ImbalancedDatasetSampler"> +<em class="property">class </em><code class="sig-prename descclassname">pathflowai.sampler.</code><code class="sig-name descname">ImbalancedDatasetSampler</code><span class="sig-paren">(</span><em class="sig-param">dataset</em>, <em class="sig-param">indices=None</em>, <em class="sig-param">num_samples=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/sampler.html#ImbalancedDatasetSampler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.sampler.ImbalancedDatasetSampler" title="Permalink to this definition">¶</a></dt> +<dd><p>Samples elements randomly from a given list of indices for imbalanced dataset +<a class="reference external" href="https://raw.githubusercontent.com/ufoym/imbalanced-dataset-sampler/master/sampler.py">https://raw.githubusercontent.com/ufoym/imbalanced-dataset-sampler/master/sampler.py</a> +Arguments:</p> +<blockquote> +<div><p>indices (list, optional): a list of indices +num_samples (int, optional): number of samples to draw</p> +</div></blockquote> +</dd></dl> + +</div> +<span class="target" id="module-pathflowai.schedulers"></span><div class="section" id="schedulers-py"> +<h2>schedulers.py<a class="headerlink" href="#schedulers-py" title="Permalink to this headline">¶</a></h2> +<p>Modulates the learning rate during the training process.</p> +<dl class="class"> +<dt id="pathflowai.schedulers.CosineAnnealingWithRestartsLR"> +<em class="property">class </em><code class="sig-prename descclassname">pathflowai.schedulers.</code><code class="sig-name descname">CosineAnnealingWithRestartsLR</code><span class="sig-paren">(</span><em class="sig-param">optimizer</em>, <em class="sig-param">T_max</em>, <em class="sig-param">eta_min=0</em>, <em class="sig-param">last_epoch=-1</em>, <em class="sig-param">T_mult=1.0</em>, <em class="sig-param">alpha_decay=1.0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/schedulers.html#CosineAnnealingWithRestartsLR"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.schedulers.CosineAnnealingWithRestartsLR" title="Permalink to this definition">¶</a></dt> +<dd><p>Set the learning rate of each parameter group using a cosine annealing +schedule, where <span class="math notranslate nohighlight">\(\eta_{max}\)</span> is set to the initial lr and +<span class="math notranslate nohighlight">\(T_{cur}\)</span> is the number of epochs since the last restart in SGDR:</p> +<blockquote> +<div><div class="math notranslate nohighlight"> +\[\eta_t = \eta_{min} + \frac{1}{2}(\eta_{max} - \eta_{min})(1 + +\cos(\frac{T_{cur}}{T_{max}}\pi))\]</div> +<p>When last_epoch=-1, sets initial lr as lr. +It has been proposed in</p> +</div></blockquote> +<p><a class="reference external" href="https://arxiv.org/abs/1608.03983">SGDR: Stochastic Gradient Descent with Warm Restarts</a>. This implements +the cosine annealing part of SGDR, the restarts and number of iterations multiplier.</p> +<blockquote> +<div><dl class="simple"> +<dt>Args:</dt><dd><p>optimizer (Optimizer): Wrapped optimizer. +T_max (int): Maximum number of iterations. +T_mult (float): Multiply T_max by this number after each restart. Default: 1. +eta_min (float): Minimum learning rate. Default: 0. +last_epoch (int): The index of last epoch. Default: -1.</p> +</dd> +</dl> +</div></blockquote> +<dl class="field-list simple"> +<dt class="field-odd">Attributes</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>step_n</strong></dt><dd></dd> +</dl> +</dd> +</dl> +<p class="rubric">Methods</p> +<table class="longtable docutils align-default"> +<colgroup> +<col style="width: 10%" /> +<col style="width: 90%" /> +</colgroup> +<tbody> +<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">load_state_dict</span></code>(self, state_dict)</p></td> +<td><p>Loads the schedulers state.</p></td> +</tr> +<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">state_dict</span></code>(self)</p></td> +<td><p>Returns the state of the scheduler as a <code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>.</p></td> +</tr> +</tbody> +</table> +<table class="docutils align-default"> +<colgroup> +<col style="width: 52%" /> +<col style="width: 48%" /> +</colgroup> +<tbody> +<tr class="row-odd"><td><p><strong>cosine</strong></p></td> +<td></td> +</tr> +<tr class="row-even"><td><p><strong>get_lr</strong></p></td> +<td></td> +</tr> +<tr class="row-odd"><td><p><strong>restart</strong></p></td> +<td></td> +</tr> +<tr class="row-even"><td><p><strong>step</strong></p></td> +<td></td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="class"> +<dt id="pathflowai.schedulers.Scheduler"> +<em class="property">class </em><code class="sig-prename descclassname">pathflowai.schedulers.</code><code class="sig-name descname">Scheduler</code><span class="sig-paren">(</span><em class="sig-param">optimizer=None</em>, <em class="sig-param">opts={'T_max': 10</em>, <em class="sig-param">'T_mult': 2</em>, <em class="sig-param">'eta_min': 5e-08</em>, <em class="sig-param">'lr_scheduler_decay': 0.5</em>, <em class="sig-param">'scheduler': 'null'}</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/schedulers.html#Scheduler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.schedulers.Scheduler" title="Permalink to this definition">¶</a></dt> +<dd><p>Scheduler class that modulates learning rate of torch optimizers over epochs.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>optimizer</strong><span class="classifier">type</span></dt><dd><p>torch.Optimizer object</p> +</dd> +<dt><strong>opts</strong><span class="classifier">type</span></dt><dd><p>Options of setting the learning rate scheduler, see default.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Attributes</dt> +<dd class="field-even"><dl class="simple"> +<dt><strong>schedulers</strong><span class="classifier">type</span></dt><dd><p>Different types of schedulers to choose from.</p> +</dd> +<dt><strong>scheduler_step_fn</strong><span class="classifier">type</span></dt><dd><p>How scheduler updates learning rate.</p> +</dd> +<dt><strong>initial_lr</strong><span class="classifier">type</span></dt><dd><p>Initial set learning rate.</p> +</dd> +<dt><strong>scheduler_choice</strong><span class="classifier">type</span></dt><dd><p>What scheduler type was chosen.</p> +</dd> +<dt><strong>scheduler</strong><span class="classifier">type</span></dt><dd><p>Scheduler object chosen that will more directly update optimizer LR.</p> +</dd> +</dl> +</dd> +</dl> +<p class="rubric">Methods</p> +<table class="longtable docutils align-default"> +<colgroup> +<col style="width: 10%" /> +<col style="width: 90%" /> +</colgroup> +<tbody> +<tr class="row-odd"><td><p><a class="reference internal" href="#pathflowai.schedulers.Scheduler.get_lr" title="pathflowai.schedulers.Scheduler.get_lr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_lr</span></code></a>(self)</p></td> +<td><p>Return current learning rate.</p></td> +</tr> +<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.schedulers.Scheduler.step" title="pathflowai.schedulers.Scheduler.step"><code class="xref py py-obj docutils literal notranslate"><span class="pre">step</span></code></a>(self)</p></td> +<td><p>Update optimizer learning rate</p></td> +</tr> +</tbody> +</table> +<dl class="method"> +<dt id="pathflowai.schedulers.Scheduler.get_lr"> +<code class="sig-name descname">get_lr</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/schedulers.html#Scheduler.get_lr"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.schedulers.Scheduler.get_lr" title="Permalink to this definition">¶</a></dt> +<dd><p>Return current learning rate.</p> +<dl class="field-list simple"> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><dl class="simple"> +<dt>float</dt><dd><p>Current learning rate.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="method"> +<dt id="pathflowai.schedulers.Scheduler.step"> +<code class="sig-name descname">step</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/schedulers.html#Scheduler.step"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.schedulers.Scheduler.step" title="Permalink to this definition">¶</a></dt> +<dd><p>Update optimizer learning rate</p> +</dd></dl> + +</dd></dl> + +</div> +<span class="target" id="module-pathflowai.visualize"></span><div class="section" id="visualize-py"> +<h2>visualize.py<a class="headerlink" href="#visualize-py" title="Permalink to this headline">¶</a></h2> +<p>Plots SHAP outputs, UMAP embeddings, and overlays predictions on top of WSI.</p> +<dl class="class"> +<dt id="pathflowai.visualize.PlotlyPlot"> +<em class="property">class </em><code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">PlotlyPlot</code><a class="reference internal" href="_modules/pathflowai/visualize.html#PlotlyPlot"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.PlotlyPlot" title="Permalink to this definition">¶</a></dt> +<dd><p>Creates plotly html plots.</p> +<p class="rubric">Methods</p> +<table class="longtable docutils align-default"> +<colgroup> +<col style="width: 10%" /> +<col style="width: 90%" /> +</colgroup> +<tbody> +<tr class="row-odd"><td><p><a class="reference internal" href="#pathflowai.visualize.PlotlyPlot.add_plot" title="pathflowai.visualize.PlotlyPlot.add_plot"><code class="xref py py-obj docutils literal notranslate"><span class="pre">add_plot</span></code></a>(self, t_data_df[, G, color_col, …])</p></td> +<td><p>Adds plotting data to be plotted.</p></td> +</tr> +<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.visualize.PlotlyPlot.plot" title="pathflowai.visualize.PlotlyPlot.plot"><code class="xref py py-obj docutils literal notranslate"><span class="pre">plot</span></code></a>(self, output_fname[, axes_off])</p></td> +<td><p>Plot embedding of patches to html file.</p></td> +</tr> +</tbody> +</table> +<dl class="method"> +<dt id="pathflowai.visualize.PlotlyPlot.add_plot"> +<code class="sig-name descname">add_plot</code><span class="sig-paren">(</span><em class="sig-param">self, t_data_df, G=None, color_col='color', name_col='name', xyz_cols=['x', 'y', 'z'], size=2, opacity=1.0, custom_colors=[]</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#PlotlyPlot.add_plot"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.PlotlyPlot.add_plot" title="Permalink to this definition">¶</a></dt> +<dd><p>Adds plotting data to be plotted.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>t_data_df:dataframe</strong></dt><dd><p>3-D transformed dataframe.</p> +</dd> +<dt><strong>G:nx.Graph</strong></dt><dd><p>Networkx graph.</p> +</dd> +<dt><strong>color_col:str</strong></dt><dd><p>Column to use to color points.</p> +</dd> +<dt><strong>name_col:str</strong></dt><dd><p>Column to use to name points.</p> +</dd> +<dt><strong>xyz_cols:list</strong></dt><dd><p>3 columns that denote x,y,z coords.</p> +</dd> +<dt><strong>size:int</strong></dt><dd><p>Marker size.</p> +</dd> +<dt><strong>opacity:float</strong></dt><dd><p>Marker opacity.</p> +</dd> +<dt><strong>custom_colors:list</strong></dt><dd><p>Custom colors to supply.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="method"> +<dt id="pathflowai.visualize.PlotlyPlot.plot"> +<code class="sig-name descname">plot</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">output_fname</em>, <em class="sig-param">axes_off=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#PlotlyPlot.plot"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.PlotlyPlot.plot" title="Permalink to this definition">¶</a></dt> +<dd><p>Plot embedding of patches to html file.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>output_fname:str</strong></dt><dd><p>Output html file.</p> +</dd> +<dt><strong>axes_off:bool</strong></dt><dd><p>Remove axes.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +</dd></dl> + +<dl class="class"> +<dt id="pathflowai.visualize.PredictionPlotter"> +<em class="property">class </em><code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">PredictionPlotter</code><span class="sig-paren">(</span><em class="sig-param">dask_arr_dict</em>, <em class="sig-param">patch_info_db</em>, <em class="sig-param">compression_factor=3</em>, <em class="sig-param">alpha=0.5</em>, <em class="sig-param">patch_size=224</em>, <em class="sig-param">no_db=False</em>, <em class="sig-param">plot_annotation=False</em>, <em class="sig-param">segmentation=False</em>, <em class="sig-param">n_segmentation_classes=4</em>, <em class="sig-param">input_dir=''</em>, <em class="sig-param">annotation_col='annotation'</em>, <em class="sig-param">scaling_factor=1.0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#PredictionPlotter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.PredictionPlotter" title="Permalink to this definition">¶</a></dt> +<dd><p>Plots predictions over entire image.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>dask_arr_dict:dict</strong></dt><dd><p>Stores all dask arrays corresponding to all of the images.</p> +</dd> +<dt><strong>patch_info_db:str</strong></dt><dd><p>Patch level information, eg. prediction.</p> +</dd> +<dt><strong>compression_factor:float</strong></dt><dd><p>How much to compress image by.</p> +</dd> +<dt><strong>alpha:float</strong></dt><dd><p>Low value assigns higher weight to prediction over original image.</p> +</dd> +<dt><strong>patch_size:int</strong></dt><dd><p>Patch size.</p> +</dd> +<dt><strong>no_db:bool</strong></dt><dd><p>Don’t use patch information.</p> +</dd> +<dt><strong>plot_annotation:bool</strong></dt><dd><p>Plot annotations from patch information.</p> +</dd> +<dt><strong>segmentation:bool</strong></dt><dd><p>Plot segmentation mask.</p> +</dd> +<dt><strong>n_segmentation_classes:int</strong></dt><dd><p>Number segmentation classes.</p> +</dd> +<dt><strong>input_dir:str</strong></dt><dd><p>Input directory.</p> +</dd> +<dt><strong>annotation_col:str</strong></dt><dd><p>Annotation column to plot.</p> +</dd> +<dt><strong>scaling_factor:float</strong></dt><dd><p>Multiplies the prediction scores to make them appear darker on the images when predicting.</p> +</dd> +</dl> +</dd> +</dl> +<p class="rubric">Methods</p> +<table class="longtable docutils align-default"> +<colgroup> +<col style="width: 10%" /> +<col style="width: 90%" /> +</colgroup> +<tbody> +<tr class="row-odd"><td><p><a class="reference internal" href="#pathflowai.visualize.PredictionPlotter.add_custom_segmentation" title="pathflowai.visualize.PredictionPlotter.add_custom_segmentation"><code class="xref py py-obj docutils literal notranslate"><span class="pre">add_custom_segmentation</span></code></a>(self, basename, npy)</p></td> +<td><p>Replace segmentation mask with new custom segmentation.</p></td> +</tr> +<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.visualize.PredictionPlotter.generate_image" title="pathflowai.visualize.PredictionPlotter.generate_image"><code class="xref py py-obj docutils literal notranslate"><span class="pre">generate_image</span></code></a>(self, ID)</p></td> +<td><p>Generate the image array for the whole slide image with predictions overlaid.</p></td> +</tr> +<tr class="row-odd"><td><p><a class="reference internal" href="#pathflowai.visualize.PredictionPlotter.output_image" title="pathflowai.visualize.PredictionPlotter.output_image"><code class="xref py py-obj docutils literal notranslate"><span class="pre">output_image</span></code></a>(self, img, filename[, tif])</p></td> +<td><p>Output calculated image to file.</p></td> +</tr> +<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.visualize.PredictionPlotter.return_patch" title="pathflowai.visualize.PredictionPlotter.return_patch"><code class="xref py py-obj docutils literal notranslate"><span class="pre">return_patch</span></code></a>(self, ID, x, y, patch_size)</p></td> +<td><p>Return one single patch instead of entire image.</p></td> +</tr> +</tbody> +</table> +<dl class="method"> +<dt id="pathflowai.visualize.PredictionPlotter.add_custom_segmentation"> +<code class="sig-name descname">add_custom_segmentation</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">basename</em>, <em class="sig-param">npy</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#PredictionPlotter.add_custom_segmentation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.PredictionPlotter.add_custom_segmentation" title="Permalink to this definition">¶</a></dt> +<dd><p>Replace segmentation mask with new custom segmentation.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>basename:str</strong></dt><dd><p>Patient ID</p> +</dd> +<dt><strong>npy:str</strong></dt><dd><p>Numpy mask.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="method"> +<dt id="pathflowai.visualize.PredictionPlotter.generate_image"> +<code class="sig-name descname">generate_image</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">ID</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#PredictionPlotter.generate_image"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.PredictionPlotter.generate_image" title="Permalink to this definition">¶</a></dt> +<dd><p>Generate the image array for the whole slide image with predictions overlaid.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>ID:str</strong></dt><dd><p>patient ID.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>array</dt><dd><p>Resulting overlaid whole slide image.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="method"> +<dt id="pathflowai.visualize.PredictionPlotter.output_image"> +<code class="sig-name descname">output_image</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">img</em>, <em class="sig-param">filename</em>, <em class="sig-param">tif=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#PredictionPlotter.output_image"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.PredictionPlotter.output_image" title="Permalink to this definition">¶</a></dt> +<dd><p>Output calculated image to file.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>img:array</strong></dt><dd><p>Image.</p> +</dd> +<dt><strong>filename:str</strong></dt><dd><p>Output file name.</p> +</dd> +<dt><strong>tif:bool</strong></dt><dd><p>Store in TIF format?</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="method"> +<dt id="pathflowai.visualize.PredictionPlotter.return_patch"> +<code class="sig-name descname">return_patch</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">ID</em>, <em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">patch_size</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#PredictionPlotter.return_patch"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.PredictionPlotter.return_patch" title="Permalink to this definition">¶</a></dt> +<dd><p>Return one single patch instead of entire image.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>ID:str</strong></dt><dd><p>Patient ID</p> +</dd> +<dt><strong>x:int</strong></dt><dd><p>X coordinate.</p> +</dd> +<dt><strong>y:int</strong></dt><dd><p>Y coordinate.</p> +</dd> +<dt><strong>patch_size:int</strong></dt><dd><p>Patch size.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>array</dt><dd><p>Image.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.visualize.annotation2rgb"> +<code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">annotation2rgb</code><span class="sig-paren">(</span><em class="sig-param">i</em>, <em class="sig-param">palette</em>, <em class="sig-param">arr</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#annotation2rgb"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.annotation2rgb" title="Permalink to this definition">¶</a></dt> +<dd><p>Go from annotation of patch to color.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>i:int</strong></dt><dd><p>Annotation index.</p> +</dd> +<dt><strong>palette:palette</strong></dt><dd><p>Index to color mapping.</p> +</dd> +<dt><strong>arr:array</strong></dt><dd><p>Image array.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>array</dt><dd><p>Resulting image.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.visualize.blend"> +<code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">blend</code><span class="sig-paren">(</span><em class="sig-param">arr1</em>, <em class="sig-param">arr2</em>, <em class="sig-param">alpha=0.5</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#blend"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.blend" title="Permalink to this definition">¶</a></dt> +<dd><p>Blend 2 arrays together, mixing with alpha.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>arr1:array</strong></dt><dd><p>Image 1.</p> +</dd> +<dt><strong>arr2:array</strong></dt><dd><p>Image 2.</p> +</dd> +<dt><strong>alpha:float</strong></dt><dd><p>Higher alpha makes image more like image 1.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>array</dt><dd><p>Resulting image.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.visualize.plot_image_"> +<code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">plot_image_</code><span class="sig-paren">(</span><em class="sig-param">image_file</em>, <em class="sig-param">compression_factor=2.0</em>, <em class="sig-param">test_image_name='test.png'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#plot_image_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.plot_image_" title="Permalink to this definition">¶</a></dt> +<dd><p>Plots entire SVS/other image.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>image_file:str</strong></dt><dd><p>Image file.</p> +</dd> +<dt><strong>compression_factor:float</strong></dt><dd><p>Amount to shrink each dimension of image.</p> +</dd> +<dt><strong>test_image_name:str</strong></dt><dd><p>Output image file.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.visualize.plot_shap"> +<code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">plot_shap</code><span class="sig-paren">(</span><em class="sig-param">model</em>, <em class="sig-param">dataset_opts</em>, <em class="sig-param">transform_opts</em>, <em class="sig-param">batch_size</em>, <em class="sig-param">outputfilename</em>, <em class="sig-param">n_outputs=1</em>, <em class="sig-param">method='deep'</em>, <em class="sig-param">local_smoothing=0.0</em>, <em class="sig-param">n_samples=20</em>, <em class="sig-param">pred_out=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#plot_shap"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.plot_shap" title="Permalink to this definition">¶</a></dt> +<dd><p>Plot shapley attributions overlaid on images for classification tasks.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>model:nn.Module</strong></dt><dd><p>Pytorch model.</p> +</dd> +<dt><strong>dataset_opts:dict</strong></dt><dd><p>Options used to configure dataset</p> +</dd> +<dt><strong>transform_opts:dict</strong></dt><dd><p>Options used to configure transformers.</p> +</dd> +<dt><strong>batch_size:int</strong></dt><dd><p>Batch size for training.</p> +</dd> +<dt><strong>outputfilename:str</strong></dt><dd><p>Output filename.</p> +</dd> +<dt><strong>n_outputs:int</strong></dt><dd><p>Number of top outputs.</p> +</dd> +<dt><strong>method:str</strong></dt><dd><p>Gradient or deep explainer.</p> +</dd> +<dt><strong>local_smoothing:float</strong></dt><dd><p>How much to smooth shapley map.</p> +</dd> +<dt><strong>n_samples:int</strong></dt><dd><p>Number shapley samples to draw.</p> +</dd> +<dt><strong>pred_out:bool</strong></dt><dd><p>Label images with binary prediction score?</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.visualize.plot_umap_images"> +<code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">plot_umap_images</code><span class="sig-paren">(</span><em class="sig-param">dask_arr_dict</em>, <em class="sig-param">embeddings_file</em>, <em class="sig-param">ID=None</em>, <em class="sig-param">cval=1.0</em>, <em class="sig-param">image_res=300.0</em>, <em class="sig-param">outputfname='output_embedding.png'</em>, <em class="sig-param">mpl_scatter=True</em>, <em class="sig-param">remove_background_annotation=''</em>, <em class="sig-param">max_background_area=0.01</em>, <em class="sig-param">zoom=0.05</em>, <em class="sig-param">n_neighbors=10</em>, <em class="sig-param">sort_col=''</em>, <em class="sig-param">sort_mode='asc'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#plot_umap_images"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.plot_umap_images" title="Permalink to this definition">¶</a></dt> +<dd><p>Make UMAP embedding plot, overlaid with images.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>dask_arr_dict:dict</strong></dt><dd><p>Stored dask arrays for each WSI.</p> +</dd> +<dt><strong>embeddings_file:str</strong></dt><dd><p>Embeddings pickle file stored from running using after trainign the model.</p> +</dd> +<dt><strong>ID:str</strong></dt><dd><p>Patient ID.</p> +</dd> +<dt><strong>cval:float</strong></dt><dd><p>Deprecated</p> +</dd> +<dt><strong>image_res:float</strong></dt><dd><p>Image resolution.</p> +</dd> +<dt><strong>outputfname:str</strong></dt><dd><p>Output image file.</p> +</dd> +<dt><strong>mpl_scatter:bool</strong></dt><dd><p>Recommended: Use matplotlib for scatter plot.</p> +</dd> +<dt><strong>remove_background_annotation:str</strong></dt><dd><p>Remove the background annotations. Enter for annotation to remove.</p> +</dd> +<dt><strong>max_background_area:float</strong></dt><dd><p>Maximum backgrund area in each tile for inclusion.</p> +</dd> +<dt><strong>zoom:float</strong></dt><dd><p>How much to zoom in on each patch, less than 1 is zoom out.</p> +</dd> +<dt><strong>n_neighbors:int</strong></dt><dd><p>Number of neighbors for UMAP embedding.</p> +</dd> +<dt><strong>sort_col:str</strong></dt><dd><p>Patch info column to sort on.</p> +</dd> +<dt><strong>sort_mode:str</strong></dt><dd><p>Sort ascending or descending.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>type</dt><dd><p>Description of returned object.</p> +</dd> +<dt>Inspired by: <a class="reference external" href="https://gist.github.com/lukemetz/be6123c7ee3b366e333a">https://gist.github.com/lukemetz/be6123c7ee3b366e333a</a></dt><dd></dd> +<dt>WIP!! Needs testing.</dt><dd></dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.visualize.prob2rbg"> +<code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">prob2rbg</code><span class="sig-paren">(</span><em class="sig-param">prob</em>, <em class="sig-param">palette</em>, <em class="sig-param">arr</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#prob2rbg"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.prob2rbg" title="Permalink to this definition">¶</a></dt> +<dd><p>Convert probability score to rgb image.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>prob:float</strong></dt><dd><p>Between 0 and 1 score.</p> +</dd> +<dt><strong>palette:palette</strong></dt><dd><p>Pallet converts between prob and color.</p> +</dd> +<dt><strong>arr:array</strong></dt><dd><p>Original array.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>array</dt><dd><p>New image colored by prediction score.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.visualize.seg2rgb"> +<code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">seg2rgb</code><span class="sig-paren">(</span><em class="sig-param">seg</em>, <em class="sig-param">palette</em>, <em class="sig-param">n_segmentation_classes</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#seg2rgb"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.seg2rgb" title="Permalink to this definition">¶</a></dt> +<dd><p>Color each pixel by segmentation class.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>seg:array</strong></dt><dd><p>Segmentation mask.</p> +</dd> +<dt><strong>palette:palette</strong></dt><dd><p>Color to RGB map.</p> +</dd> +<dt><strong>n_segmentation_classes:int</strong></dt><dd><p>Total number segmentation classes.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>array</dt><dd><p>Returned segmentation image.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.visualize.to_pil"> +<code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">to_pil</code><span class="sig-paren">(</span><em class="sig-param">arr</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#to_pil"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.to_pil" title="Permalink to this definition">¶</a></dt> +<dd><p>Numpy array to pil.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>arr:array</strong></dt><dd><p>Numpy array.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>Image</dt><dd><p>PIL Image.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +</div> +<span class="target" id="module-pathflowai.utils"></span><div class="section" id="utils-py"> +<h2>utils.py<a class="headerlink" href="#utils-py" title="Permalink to this headline">¶</a></h2> +<p>General utilities that still need to be broken up into preprocessing, machine learning input preparation, and output submodules.</p> +<dl class="function"> +<dt id="pathflowai.utils.add_purple_mask"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">add_purple_mask</code><span class="sig-paren">(</span><em class="sig-param">arr</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#add_purple_mask"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.add_purple_mask" title="Permalink to this definition">¶</a></dt> +<dd><p>Optional add intensity mask to the dask array.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>arr:dask.array</strong></dt><dd><p>Image data.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>array</dt><dd><p>Image data with intensity added as forth channel.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.adjust_mask"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">adjust_mask</code><span class="sig-paren">(</span><em class="sig-param">mask_file</em>, <em class="sig-param">dask_img_array_file</em>, <em class="sig-param">out_npy</em>, <em class="sig-param">n_neighbors</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#adjust_mask"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.adjust_mask" title="Permalink to this definition">¶</a></dt> +<dd><p>Fixes segmentation masks to reduce coarse annotations over empty regions.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>mask_file:str</strong></dt><dd><p>NPY segmentation mask.</p> +</dd> +<dt><strong>dask_img_array_file:str</strong></dt><dd><p>Dask image file.</p> +</dd> +<dt><strong>out_npy:str</strong></dt><dd><p>Output numpy file.</p> +</dd> +<dt><strong>n_neighbors:int</strong></dt><dd><p>Number nearest neighbors for dilation and erosion of mask from background to not background.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>str</dt><dd><p>Output numpy file.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.boxes2interior"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">boxes2interior</code><span class="sig-paren">(</span><em class="sig-param">img_size</em>, <em class="sig-param">polygons</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#boxes2interior"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.boxes2interior" title="Permalink to this definition">¶</a></dt> +<dd><p>Deprecated.</p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.create_purple_mask"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">create_purple_mask</code><span class="sig-paren">(</span><em class="sig-param">arr</em>, <em class="sig-param">img_size=None</em>, <em class="sig-param">sparse=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#create_purple_mask"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.create_purple_mask" title="Permalink to this definition">¶</a></dt> +<dd><p>Create a gray scale intensity mask. This will be changed soon to support other thresholding QC methods.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>arr:dask.array</strong></dt><dd><p>Dask array containing image information.</p> +</dd> +<dt><strong>img_size:int</strong></dt><dd><p>Deprecated.</p> +</dd> +<dt><strong>sparse:bool</strong></dt><dd><p>Deprecated</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>dask.array</dt><dd><p>Intensity, grayscale array over image.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.create_sparse_annotation_arrays"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">create_sparse_annotation_arrays</code><span class="sig-paren">(</span><em class="sig-param">xml_file</em>, <em class="sig-param">img_size</em>, <em class="sig-param">annotations=[]</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#create_sparse_annotation_arrays"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.create_sparse_annotation_arrays" title="Permalink to this definition">¶</a></dt> +<dd><p>Convert annotation xml to shapely objects and store in dictionary.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>xml_file:str</strong></dt><dd><p>XML file containing annotations.</p> +</dd> +<dt><strong>img_size:int</strong></dt><dd><p>Deprecated.</p> +</dd> +<dt><strong>annotations:list</strong></dt><dd><p>Annotations to look for in xml export.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>dict</dt><dd><p>Dictionary with annotation-shapely object pairs.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.create_train_val_test"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">create_train_val_test</code><span class="sig-paren">(</span><em class="sig-param">train_val_test_pkl</em>, <em class="sig-param">input_info_db</em>, <em class="sig-param">patch_size</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#create_train_val_test"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.create_train_val_test" title="Permalink to this definition">¶</a></dt> +<dd><p>Create dataframe that splits slides into training validation and test.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>train_val_test_pkl:str</strong></dt><dd><p>Pickle for training validation and test slides.</p> +</dd> +<dt><strong>input_info_db:str</strong></dt><dd><p>Patch information SQL database.</p> +</dd> +<dt><strong>patch_size:int</strong></dt><dd><p>Patch size looking to access.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>dataframe</dt><dd><p>Train test validation splits.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.df2sql"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">df2sql</code><span class="sig-paren">(</span><em class="sig-param">df</em>, <em class="sig-param">sql_file</em>, <em class="sig-param">patch_size</em>, <em class="sig-param">mode='replace'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#df2sql"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.df2sql" title="Permalink to this definition">¶</a></dt> +<dd><p>Write dataframe containing patch level information to SQL db.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>df:dataframe</strong></dt><dd><p>Dataframe containing patch information.</p> +</dd> +<dt><strong>sql_file:str</strong></dt><dd><p>SQL database.</p> +</dd> +<dt><strong>patch_size:int</strong></dt><dd><p>Size of patches.</p> +</dd> +<dt><strong>mode:str</strong></dt><dd><p>Replace or append.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.dir2images"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">dir2images</code><span class="sig-paren">(</span><em class="sig-param">image_dir</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#dir2images"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.dir2images" title="Permalink to this definition">¶</a></dt> +<dd><p>Deprecated</p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.extract_patch_information"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">extract_patch_information</code><span class="sig-paren">(</span><em class="sig-param">basename</em>, <em class="sig-param">input_dir='./'</em>, <em class="sig-param">annotations=[]</em>, <em class="sig-param">threshold=0.5</em>, <em class="sig-param">patch_size=224</em>, <em class="sig-param">generate_finetune_segmentation=False</em>, <em class="sig-param">target_class=0</em>, <em class="sig-param">intensity_threshold=100.0</em>, <em class="sig-param">target_threshold=0.0</em>, <em class="sig-param">adj_mask=''</em>, <em class="sig-param">basic_preprocess=False</em>, <em class="sig-param">tries=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#extract_patch_information"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.extract_patch_information" title="Permalink to this definition">¶</a></dt> +<dd><p>Final step of preprocessing pipeline. Break up image into patches, include if not background and of a certain intensity, find area of each annotation type in patch, spatial information, image ID and dump data to SQL table.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>basename:str</strong></dt><dd><p>Patient ID.</p> +</dd> +<dt><strong>input_dir:str</strong></dt><dd><p>Input directory.</p> +</dd> +<dt><strong>annotations:list</strong></dt><dd><p>List of annotations to record, these can be different tissue types, must correspond with XML labels.</p> +</dd> +<dt><strong>threshold:float</strong></dt><dd><p>Value between 0 and 1 that indicates the minimum amount of patch that musn’t be background for inclusion.</p> +</dd> +<dt><strong>patch_size:int</strong></dt><dd><p>Patch size of patches; this will become one of the tables.</p> +</dd> +<dt><strong>generate_finetune_segmentation:bool</strong></dt><dd><p>Deprecated.</p> +</dd> +<dt><strong>target_class:int</strong></dt><dd><p>Number of segmentation classes desired, from 0th class to target_class-1 will be annotated in SQL.</p> +</dd> +<dt><strong>intensity_threshold:float</strong></dt><dd><p>Value between 0 and 255 that represents minimum intensity to not include as background. Will be modified with new transforms.</p> +</dd> +<dt><strong>target_threshold:float</strong></dt><dd><p>Deprecated.</p> +</dd> +<dt><strong>adj_mask:str</strong></dt><dd><p>Adjusted mask if performed binary opening operations in previous preprocessing step.</p> +</dd> +<dt><strong>basic_preprocess:bool</strong></dt><dd><p>Do not store patch level information.</p> +</dd> +<dt><strong>tries:int</strong></dt><dd><p>Number of tries in case there is a Dask timeout, run again.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>dataframe</dt><dd><p>Patch information.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.fix_name"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">fix_name</code><span class="sig-paren">(</span><em class="sig-param">basename</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#fix_name"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.fix_name" title="Permalink to this definition">¶</a></dt> +<dd><p>Fixes illegitimate basename, deprecated.</p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.fix_names"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">fix_names</code><span class="sig-paren">(</span><em class="sig-param">file_dir</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#fix_names"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.fix_names" title="Permalink to this definition">¶</a></dt> +<dd><p>Fixes basenames, deprecated.</p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.generate_patch_pipeline"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">generate_patch_pipeline</code><span class="sig-paren">(</span><em class="sig-param">basename</em>, <em class="sig-param">input_dir='./'</em>, <em class="sig-param">annotations=[]</em>, <em class="sig-param">threshold=0.5</em>, <em class="sig-param">patch_size=224</em>, <em class="sig-param">out_db='patch_info.db'</em>, <em class="sig-param">generate_finetune_segmentation=False</em>, <em class="sig-param">target_class=0</em>, <em class="sig-param">intensity_threshold=100.0</em>, <em class="sig-param">target_threshold=0.0</em>, <em class="sig-param">adj_mask=''</em>, <em class="sig-param">basic_preprocess=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#generate_patch_pipeline"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.generate_patch_pipeline" title="Permalink to this definition">¶</a></dt> +<dd><p>Short summary.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>basename:str</strong></dt><dd><p>Patient ID.</p> +</dd> +<dt><strong>input_dir:str</strong></dt><dd><p>Input directory.</p> +</dd> +<dt><strong>annotations:list</strong></dt><dd><p>List of annotations to record, these can be different tissue types, must correspond with XML labels.</p> +</dd> +<dt><strong>threshold:float</strong></dt><dd><p>Value between 0 and 1 that indicates the minimum amount of patch that musn’t be background for inclusion.</p> +</dd> +<dt><strong>patch_size:int</strong></dt><dd><p>Patch size of patches; this will become one of the tables.</p> +</dd> +<dt><strong>out_db:str</strong></dt><dd><p>Output SQL database.</p> +</dd> +<dt><strong>generate_finetune_segmentation:bool</strong></dt><dd><p>Deprecated.</p> +</dd> +<dt><strong>target_class:int</strong></dt><dd><p>Number of segmentation classes desired, from 0th class to target_class-1 will be annotated in SQL.</p> +</dd> +<dt><strong>intensity_threshold:float</strong></dt><dd><p>Value between 0 and 255 that represents minimum intensity to not include as background. Will be modified with new transforms.</p> +</dd> +<dt><strong>target_threshold:float</strong></dt><dd><p>Deprecated.</p> +</dd> +<dt><strong>adj_mask:str</strong></dt><dd><p>Adjusted mask if performed binary opening operations in previous preprocessing step.</p> +</dd> +<dt><strong>basic_preprocess:bool</strong></dt><dd><p>Do not store patch level information.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.grab_interior_points"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">grab_interior_points</code><span class="sig-paren">(</span><em class="sig-param">xml_file</em>, <em class="sig-param">img_size</em>, <em class="sig-param">annotations=[]</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#grab_interior_points"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.grab_interior_points" title="Permalink to this definition">¶</a></dt> +<dd><p>Deprecated.</p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.image2coords"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">image2coords</code><span class="sig-paren">(</span><em class="sig-param">image_file</em>, <em class="sig-param">output_point=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#image2coords"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.image2coords" title="Permalink to this definition">¶</a></dt> +<dd><p>Deprecated.</p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.images2coord_dict"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">images2coord_dict</code><span class="sig-paren">(</span><em class="sig-param">images</em>, <em class="sig-param">output_point=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#images2coord_dict"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.images2coord_dict" title="Permalink to this definition">¶</a></dt> +<dd><p>Deprecated</p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.img2npy_"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">img2npy_</code><span class="sig-paren">(</span><em class="sig-param">input_dir</em>, <em class="sig-param">basename</em>, <em class="sig-param">svs_file</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#img2npy_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.img2npy_" title="Permalink to this definition">¶</a></dt> +<dd><p>Convert SVS, TIF, TIFF to NPY.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>input_dir:str</strong></dt><dd><p>Output file dir.</p> +</dd> +<dt><strong>basename:str</strong></dt><dd><p>Basename of output file</p> +</dd> +<dt><strong>svs_file:str</strong></dt><dd><p>SVS, TIF, TIFF file input.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>str</dt><dd><p>NPY output file.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.is_coords_in_box"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">is_coords_in_box</code><span class="sig-paren">(</span><em class="sig-param">coords</em>, <em class="sig-param">patch_size</em>, <em class="sig-param">boxes</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#is_coords_in_box"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.is_coords_in_box" title="Permalink to this definition">¶</a></dt> +<dd><p>Get area of annotation in patch.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>coords:array</strong></dt><dd><p>X,Y coordinates of patch.</p> +</dd> +<dt><strong>patch_size:int</strong></dt><dd><p>Patch size.</p> +</dd> +<dt><strong>boxes:list</strong></dt><dd><p>Shapely objects for annotations.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>float</dt><dd><p>Area of annotation type.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.is_image_in_boxes"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">is_image_in_boxes</code><span class="sig-paren">(</span><em class="sig-param">image_coord_dict</em>, <em class="sig-param">boxes</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#is_image_in_boxes"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.is_image_in_boxes" title="Permalink to this definition">¶</a></dt> +<dd><p>Find if image intersects with annotations.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>image_coord_dict:dict</strong></dt><dd><p>Dictionary of patches.</p> +</dd> +<dt><strong>boxes:list</strong></dt><dd><p>Shapely annotation shapes.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>dict</dt><dd><p>Dictionary of whether image intersects with any of the annotations.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.is_valid_patch"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">is_valid_patch</code><span class="sig-paren">(</span><em class="sig-param">xs</em>, <em class="sig-param">ys</em>, <em class="sig-param">patch_size</em>, <em class="sig-param">purple_mask</em>, <em class="sig-param">intensity_threshold</em>, <em class="sig-param">threshold=0.5</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#is_valid_patch"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.is_valid_patch" title="Permalink to this definition">¶</a></dt> +<dd><p>Deprecated, computes whether patch is valid.</p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.load_dataset"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">load_dataset</code><span class="sig-paren">(</span><em class="sig-param">in_zarr</em>, <em class="sig-param">in_pkl</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#load_dataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.load_dataset" title="Permalink to this definition">¶</a></dt> +<dd><p>Load ZARR image and annotations pickle.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>in_zarr:str</strong></dt><dd><p>Input image.</p> +</dd> +<dt><strong>in_pkl:str</strong></dt><dd><p>Input annotations.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>dask.array</dt><dd><p>Image array.</p> +</dd> +<dt>dict</dt><dd><p>Annotations dictionary.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.load_image"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">load_image</code><span class="sig-paren">(</span><em class="sig-param">svs_file</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#load_image"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.load_image" title="Permalink to this definition">¶</a></dt> +<dd><p>Load SVS, TIF, TIFF</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>svs_file:type</strong></dt><dd><p>Description of parameter <cite>svs_file</cite>.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>type</dt><dd><p>Description of returned object.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.load_process_image"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">load_process_image</code><span class="sig-paren">(</span><em class="sig-param">svs_file</em>, <em class="sig-param">xml_file=None</em>, <em class="sig-param">npy_mask=None</em>, <em class="sig-param">annotations=[]</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#load_process_image"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.load_process_image" title="Permalink to this definition">¶</a></dt> +<dd><p>Load SVS-like image (including NPY), segmentation/classification annotations, generate dask array and dictionary of annotations.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>svs_file:str</strong></dt><dd><p>Image file</p> +</dd> +<dt><strong>xml_file:str</strong></dt><dd><p>Annotation file.</p> +</dd> +<dt><strong>npy_mask:array</strong></dt><dd><p>Numpy segmentation mask.</p> +</dd> +<dt><strong>annotations:list</strong></dt><dd><p>List of annotations in xml.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>array</dt><dd><p>Dask array of image.</p> +</dd> +<dt>dict</dt><dd><p>Annotation masks.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.load_sql_df"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">load_sql_df</code><span class="sig-paren">(</span><em class="sig-param">sql_file</em>, <em class="sig-param">patch_size</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#load_sql_df"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.load_sql_df" title="Permalink to this definition">¶</a></dt> +<dd><p>Load pandas dataframe from SQL, accessing particular patch size within SQL.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>sql_file:str</strong></dt><dd><p>SQL db.</p> +</dd> +<dt><strong>patch_size:int</strong></dt><dd><p>Patch size.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>dataframe</dt><dd><p>Patch level information.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt> +<code class="sig-name descname">modify_patch_info(input_info_db='patch_info.db', slide_labels=Empty DataFrame</code></dt> +<dt> +<code class="sig-name descname">Columns: []</code></dt> +<dt> +<code class="sig-name descname">Index: [], pos_annotation_class='', patch_size=224, segmentation=False, other_annotations=[], target_segmentation_class=-1, target_threshold=0.0, classify_annotations=False)</code></dt> +<dd><p>Modify the patch information to get ready for deep learning, incorporate whole slide labels if needed.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>input_info_db:str</strong></dt><dd><p>SQL DB file.</p> +</dd> +<dt><strong>slide_labels:dataframe</strong></dt><dd><p>Dataframe with whole slide labels.</p> +</dd> +<dt><strong>pos_annotation_class:str</strong></dt><dd><p>Tissue/annotation label to label with whole slide image label, if not supplied, any slide’s patches receive the whole slide label.</p> +</dd> +<dt><strong>patch_size:int</strong></dt><dd><p>Patch size.</p> +</dd> +<dt><strong>segmentation:bool</strong></dt><dd><p>Segmentation?</p> +</dd> +<dt><strong>other_annotations:list</strong></dt><dd><p>Other annotations to access from patch information.</p> +</dd> +<dt><strong>target_segmentation_class:int</strong></dt><dd><p>Segmentation class to threshold.</p> +</dd> +<dt><strong>target_threshold:float</strong></dt><dd><p>Include patch if patch has target area greater than this.</p> +</dd> +<dt><strong>classify_annotations:bool</strong></dt><dd><p>Classifying annotations for pretraining, or final model?</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>dataframe</dt><dd><p>Modified patch information.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.npy2da"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">npy2da</code><span class="sig-paren">(</span><em class="sig-param">npy_file</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#npy2da"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.npy2da" title="Permalink to this definition">¶</a></dt> +<dd><p>Numpy to dask array.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>npy_file:str</strong></dt><dd><p>Input npy file.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>dask.array</dt><dd><p>Converted numpy array to dask.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.parse_coord_return_boxes"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">parse_coord_return_boxes</code><span class="sig-paren">(</span><em class="sig-param">xml_file</em>, <em class="sig-param">annotation_name=''</em>, <em class="sig-param">return_coords=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#parse_coord_return_boxes"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.parse_coord_return_boxes" title="Permalink to this definition">¶</a></dt> +<dd><p>Get list of shapely objects for each annotation in the XML object.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>xml_file:str</strong></dt><dd><p>Annotation file.</p> +</dd> +<dt><strong>annotation_name:str</strong></dt><dd><p>Name of xml annotation.</p> +</dd> +<dt><strong>return_coords:bool</strong></dt><dd><p>Just return list of coords over shapes.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>list</dt><dd><p>List of shapely objects.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.process_svs"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">process_svs</code><span class="sig-paren">(</span><em class="sig-param">svs_file</em>, <em class="sig-param">xml_file</em>, <em class="sig-param">annotations=[]</em>, <em class="sig-param">output_dir='./'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#process_svs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.process_svs" title="Permalink to this definition">¶</a></dt> +<dd><p>Store images into npy format and store annotations into pickle dictionary.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>svs_file:str</strong></dt><dd><p>Image file.</p> +</dd> +<dt><strong>xml_file:str</strong></dt><dd><p>Annotations file.</p> +</dd> +<dt><strong>annotations:list</strong></dt><dd><p>List of annotations in image.</p> +</dd> +<dt><strong>output_dir:str</strong></dt><dd><p>Output directory.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.retain_images"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">retain_images</code><span class="sig-paren">(</span><em class="sig-param">image_dir</em>, <em class="sig-param">xml_file</em>, <em class="sig-param">annotation=''</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#retain_images"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.retain_images" title="Permalink to this definition">¶</a></dt> +<dd><p>Deprecated</p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.return_image_coord"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">return_image_coord</code><span class="sig-paren">(</span><em class="sig-param">nx=0</em>, <em class="sig-param">ny=0</em>, <em class="sig-param">xl=3333</em>, <em class="sig-param">yl=3333</em>, <em class="sig-param">xi=0</em>, <em class="sig-param">yi=0</em>, <em class="sig-param">xc=3</em>, <em class="sig-param">yc=3</em>, <em class="sig-param">dimx=224</em>, <em class="sig-param">dimy=224</em>, <em class="sig-param">output_point=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#return_image_coord"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.return_image_coord" title="Permalink to this definition">¶</a></dt> +<dd><p>Deprecated</p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.return_image_in_boxes_dict"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">return_image_in_boxes_dict</code><span class="sig-paren">(</span><em class="sig-param">image_dir</em>, <em class="sig-param">xml_file</em>, <em class="sig-param">annotation=''</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#return_image_in_boxes_dict"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.return_image_in_boxes_dict" title="Permalink to this definition">¶</a></dt> +<dd><p>Deprecated</p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.run_preprocessing_pipeline"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">run_preprocessing_pipeline</code><span class="sig-paren">(</span><em class="sig-param">svs_file</em>, <em class="sig-param">xml_file=None</em>, <em class="sig-param">npy_mask=None</em>, <em class="sig-param">annotations=[]</em>, <em class="sig-param">out_zarr='output_zarr.zarr'</em>, <em class="sig-param">out_pkl='output.pkl'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#run_preprocessing_pipeline"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.run_preprocessing_pipeline" title="Permalink to this definition">¶</a></dt> +<dd><p>Run preprocessing pipeline. Store image into zarr format, segmentations maintain as npy, and xml annotations as pickle.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>svs_file:str</strong></dt><dd><p>Input image file.</p> +</dd> +<dt><strong>xml_file:str</strong></dt><dd><p>Input annotation file.</p> +</dd> +<dt><strong>npy_mask:str</strong></dt><dd><p>NPY segmentation mask.</p> +</dd> +<dt><strong>annotations:list</strong></dt><dd><p>List of annotations.</p> +</dd> +<dt><strong>out_zarr:str</strong></dt><dd><p>Output zarr for image.</p> +</dd> +<dt><strong>out_pkl:str</strong></dt><dd><p>Output pickle for annotations.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.save_all_patch_info"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">save_all_patch_info</code><span class="sig-paren">(</span><em class="sig-param">basenames</em>, <em class="sig-param">input_dir='./'</em>, <em class="sig-param">annotations=[]</em>, <em class="sig-param">threshold=0.5</em>, <em class="sig-param">patch_size=224</em>, <em class="sig-param">output_pkl='patch_info.pkl'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#save_all_patch_info"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.save_all_patch_info" title="Permalink to this definition">¶</a></dt> +<dd><p>Deprecated.</p> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.save_dataset"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">save_dataset</code><span class="sig-paren">(</span><em class="sig-param">arr</em>, <em class="sig-param">masks</em>, <em class="sig-param">out_zarr</em>, <em class="sig-param">out_pkl</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#save_dataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.save_dataset" title="Permalink to this definition">¶</a></dt> +<dd><p>Saves dask array image, dictionary of annotations to zarr and pickle respectively.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>arr:array</strong></dt><dd><p>Image.</p> +</dd> +<dt><strong>masks:dict</strong></dt><dd><p>Dictionary of annotation shapes.</p> +</dd> +<dt><strong>out_zarr:str</strong></dt><dd><p>Zarr output file for image.</p> +</dd> +<dt><strong>out_pkl:str</strong></dt><dd><p>Pickle output file.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.segmentation_predictions2npy"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">segmentation_predictions2npy</code><span class="sig-paren">(</span><em class="sig-param">y_pred</em>, <em class="sig-param">patch_info</em>, <em class="sig-param">segmentation_map</em>, <em class="sig-param">npy_output</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#segmentation_predictions2npy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.segmentation_predictions2npy" title="Permalink to this definition">¶</a></dt> +<dd><p>Convert segmentation predictions from model to numpy masks.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>y_pred:list</strong></dt><dd><p>List of patch segmentation masks</p> +</dd> +<dt><strong>patch_info:dataframe</strong></dt><dd><p>Patch information from DB.</p> +</dd> +<dt><strong>segmentation_map:array</strong></dt><dd><p>Existing segmentation mask.</p> +</dd> +<dt><strong>npy_output:str</strong></dt><dd><p>Output npy file.</p> +</dd> +</dl> +</dd> +</dl> +</dd></dl> + +<dl class="function"> +<dt id="pathflowai.utils.svs2dask_array"> +<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">svs2dask_array</code><span class="sig-paren">(</span><em class="sig-param">svs_file</em>, <em class="sig-param">tile_size=1000</em>, <em class="sig-param">overlap=0</em>, <em class="sig-param">remove_last=True</em>, <em class="sig-param">allow_unknown_chunksizes=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#svs2dask_array"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.svs2dask_array" title="Permalink to this definition">¶</a></dt> +<dd><p>Convert SVS, TIF or TIFF to dask array.</p> +<dl class="field-list"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><dl class="simple"> +<dt><strong>svs_file:str</strong></dt><dd><p>Image file.</p> +</dd> +<dt><strong>tile_size:int</strong></dt><dd><p>Size of chunk to be read in.</p> +</dd> +<dt><strong>overlap:int</strong></dt><dd><p>Do not modify, overlap between neighboring tiles.</p> +</dd> +<dt><strong>remove_last:bool</strong></dt><dd><p>Remove last tile because it has a custom size.</p> +</dd> +<dt><strong>allow_unknown_chunksizes: bool</strong></dt><dd><p>Allow different chunk sizes, more flexible, but slowdown.</p> +</dd> +</dl> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><dl class="simple"> +<dt>dask.array</dt><dd><p>Dask Array.</p> +</dd> +</dl> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">arr</span><span class="o">=</span><span class="n">svs2dask_array</span><span class="p">(</span><span class="n">svs_file</span><span class="p">,</span> <span class="n">tile_size</span><span class="o">=</span><span class="mi">1000</span><span class="p">,</span> <span class="n">overlap</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">remove_last</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">allow_unknown_chunksizes</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +<span class="go"> ..</span> +</pre></div> +</div> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">arr2</span><span class="o">=</span><span class="n">arr</span><span class="o">.</span><span class="n">compute</span><span class="p">()</span> +<span class="go"> ..</span> +</pre></div> +</div> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">arr3</span><span class="o">=</span><span class="n">to_pil</span><span class="p">(</span><span class="n">cv2</span><span class="o">.</span><span class="n">resize</span><span class="p">(</span><span class="n">arr2</span><span class="p">,</span> <span class="n">dsize</span><span class="o">=</span><span class="p">(</span><span class="mi">1440</span><span class="p">,</span><span class="mi">700</span><span class="p">),</span> <span class="n">interpolation</span><span class="o">=</span><span class="n">cv2</span><span class="o">.</span><span class="n">INTER_CUBIC</span><span class="p">))</span> +<span class="go"> ..</span> +</pre></div> +</div> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">arr3</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">test_image_name</span><span class="p">)</span> +<span class="go"> ..</span> +</pre></div> +</div> +</dd> +</dl> +</dd></dl> + +</div> +</div> +<div class="section" id="indices-and-tables"> +<h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h1> +<ul class="simple"> +<li><p><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></p></li> +<li><p><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></p></li> +<li><p><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></p></li> +</ul> +</div> + + + </div> + + </div> + <footer> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2019, Joshua Levy + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + + + + + + +</body> +</html> \ No newline at end of file