Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic documentation with Sphinx and Read the Docs #104

Draft
wants to merge 64 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
cc19190
- update documentation with sphinx
PaulBautin Mar 12, 2021
4065a74
- add link to docs on README
PaulBautin Mar 12, 2021
a493021
add link to readthedocs
PaulBautin Mar 12, 2021
c912d98
- remove venv
PaulBautin Mar 13, 2021
f4ee0c3
Merge remote-tracking branch 'origin/docs' into docs
PaulBautin Mar 13, 2021
7dc4f2c
- update conf
PaulBautin Mar 17, 2021
0ba8b81
add jsonschema to requirements
PaulBautin Mar 18, 2021
628a244
- update documentation for both dataframes subject and rescale
PaulBautin Mar 18, 2021
cb33d65
- add between subject sample size
PaulBautin May 11, 2021
8e5796f
- test math markdown
PaulBautin May 11, 2021
90873c9
- add latex instruction for formula
PaulBautin May 11, 2021
2f6869e
- improve latex formula for indexing
PaulBautin May 12, 2021
462dcad
- change mean to latex \overline and STD to \sigma
PaulBautin May 12, 2021
f1e88b2
- minor change on SD of error
PaulBautin May 12, 2021
749db90
- improve math indexing for formulas
PaulBautin May 12, 2021
007f5d4
- add rescale dataframe file
PaulBautin May 12, 2021
ef30058
- add subject dataframe file and sample size
PaulBautin May 12, 2021
dfbe658
- remove redundancy in sections
PaulBautin May 12, 2021
f817094
- statistics page on main welcome page
PaulBautin May 12, 2021
86122bf
- sous section pour les stats
PaulBautin May 12, 2021
d9d6400
- update rescale dataframe formula
PaulBautin May 12, 2021
61e9ff3
- correct formulas for error
PaulBautin May 12, 2021
e1d0c5c
- add computation of for each section
PaulBautin May 12, 2021
9d0828e
- add blurb for doc presentation and image
PaulBautin May 17, 2021
62f4d4f
- test why image is not displayed
PaulBautin May 17, 2021
d4b25b5
- test why image is not displayed 2
PaulBautin May 17, 2021
30633db
- add image in docs to see if it is found
PaulBautin May 17, 2021
c44d5ef
- refactor an rearrange files
PaulBautin May 17, 2021
4e19603
- Replace index and file overview
PaulBautin May 17, 2021
1676be3
- remove rst extension in index file
PaulBautin May 17, 2021
3bc4242
- add files to git
PaulBautin May 17, 2021
c1df404
- regroup stats under one file
PaulBautin May 17, 2021
af53654
- add spacing in index
PaulBautin May 17, 2021
980f954
- Change Overview.rst to overview.rst
PaulBautin May 17, 2021
e812a23
- update title for overview
PaulBautin May 17, 2021
7e1955b
- remove build files
PaulBautin May 17, 2021
d7ebca7
- change master toctree test + remove rst (build fail)
PaulBautin May 17, 2021
68406a1
- replace index as master doc
PaulBautin May 17, 2021
1a35521
- test remove hidden
PaulBautin May 17, 2021
c4decbb
- add overview in index file
PaulBautin May 17, 2021
c01b87c
- remove overview file
PaulBautin May 17, 2021
eb20833
- test glob on toctree
PaulBautin May 17, 2021
7018e73
- change into to introduction
PaulBautin May 17, 2021
531d0a9
- index change back to hidden
PaulBautin May 17, 2021
ce9d6b1
- remove autofunction in sample size file
PaulBautin May 17, 2021
003c933
- remove autofunction in sample size file
PaulBautin May 20, 2021
c5671c2
- Change per subject to intra-subject and per scaling to inter-subject
PaulBautin May 20, 2021
70e9ff7
- Adjust text for each statistic
PaulBautin May 20, 2021
755fa88
- remove README from file doc
PaulBautin May 20, 2021
76fa102
- move quality control to RTD
PaulBautin May 27, 2021
3045ced
- move quality control to RTD
PaulBautin May 27, 2021
5b3dd4e
- update formula to match manuscript
PaulBautin Jun 1, 2021
c52875c
- add brace on formula
PaulBautin Jun 1, 2021
e0b973c
- add brace on formula for inter
PaulBautin Jun 1, 2021
71f963e
- add brace on formula 3
PaulBautin Jun 1, 2021
d61e75e
- move quality control in statistics
PaulBautin Jun 1, 2021
8de1066
- change toctree maxdepth to 2
PaulBautin Jun 1, 2021
588aadc
- reverse toctree maxdepth
PaulBautin Jun 1, 2021
7b62bac
- add how to run
PaulBautin Jun 1, 2021
5841424
- changer placement dans index.rst
PaulBautin Jun 1, 2021
2f6f80b
- changer placement dans index.rst
PaulBautin Jun 1, 2021
ae912c3
- add title to how to run
PaulBautin Jun 1, 2021
d33e825
- update link to spine generic
PaulBautin Jun 1, 2021
033688d
- remove plot results in README
PaulBautin Jun 1, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
![csa-atrophy](https://github.com/sct-pipeline/csa-atrophy/blob/master/csa_atrophy_scheme3.png)

[![Documentation Status](https://readthedocs.org/projects/sphinx/badge/?version=master)](https://csa-atrophy.readthedocs.io/en/latest/)

# csa-atrophy

Evaluate the sensitivity of atrophy detection with SCT. The algorithm works as follows:
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
1 change: 1 addition & 0 deletions docs/README.md
Binary file added docs/_build/doctrees/README.doctree
Binary file not shown.
Binary file added docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file added docs/_build/doctrees/index.doctree
Binary file not shown.
Binary file added docs/_build/doctrees/statistics.doctree
Binary file not shown.
4 changes: 4 additions & 0 deletions docs/_build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 70aef56d01745b281df3c0294204b2b4
tags: 645f666f9bcd5a90fca523b33c5a78b7
309 changes: 309 additions & 0 deletions docs/_build/html/README.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,309 @@


<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>csa-atrophy &mdash; csa-atrophy v1.0 documentation</title>



<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />







<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->


<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>

<script type="text/javascript" src="_static/js/theme.js"></script>


<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="STATISTICS" href="statistics.html" />
<link rel="prev" title="Welcome to csa-atrophy’s documentation!" href="index.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="index.html" class="icon icon-home" alt="Documentation Home"> csa-atrophy



</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">






<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">csa-atrophy</a></li>
<li class="toctree-l1"><a class="reference internal" href="#how-to-run">How to run</a></li>
<li class="toctree-l1"><a class="reference internal" href="#quality-control">Quality Control</a></li>
<li class="toctree-l1"><a class="reference internal" href="#statistics">Statistics</a></li>
<li class="toctree-l1"><a class="reference internal" href="statistics.html">STATISTICS</a></li>
</ul>



</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="index.html">csa-atrophy</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="index.html" class="icon icon-home"></a> &raquo;</li>

<li>csa-atrophy</li>


<li class="wy-breadcrumbs-aside">


<a href="_sources/README.md.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">

<p><img alt="csa-atrophy" src="https://github.com/sct-pipeline/csa-atrophy/blob/master/csa_atrophy_scheme3.png" /></p>
<p><a class="reference external" href="https://csa-atrophy.readthedocs.io/en/latest/"><img alt="Documentation Status" src="https://readthedocs.org/projects/sphinx/badge/?version=master" /></a></p>
<div class="section" id="csa-atrophy">
<h1>csa-atrophy<a class="headerlink" href="#csa-atrophy" title="Permalink to this headline">¶</a></h1>
<p>Evaluate the sensitivity of atrophy detection with SCT. The algorithm works as follows:</p>
<ul class="simple">
<li><p>Consider subject I –&gt; sI</p></li>
<li><p>Applies a rescaling on the native image (e.g. 1, 0.95, 0.8) –&gt; rX</p></li>
<li><p>Applies random affine transformation –&gt; tY</p></li>
<li><p>Segment the cord</p></li>
<li><p>Compute CSA –&gt; CSA(sI, rX, tY)</p></li>
</ul>
</div>
<div class="section" id="how-to-run">
<h1>How to run<a class="headerlink" href="#how-to-run" title="Permalink to this headline">¶</a></h1>
<p>This code has been tested using Python 3.7.</p>
<p>Download (or git clone) this repository:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">clone</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">sct</span><span class="o">-</span><span class="n">pipeline</span><span class="o">/</span><span class="n">csa</span><span class="o">-</span><span class="n">atrophy</span><span class="o">.</span><span class="n">git</span>
<span class="n">cd</span> <span class="n">csa</span><span class="o">-</span><span class="n">atrophy</span>
</pre></div>
</div>
<p>Installation:
csa-atrophy requires specific python packages for computing statistics and processing images. If not already present on the computer’s python environment such packages will automatically be installed by running pip command:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="o">-</span><span class="n">e</span> <span class="o">.</span>
</pre></div>
</div>
<p>Download the <a class="reference external" href="https://github.com/spine-generic/data-multi-subject#download">Spine Generic Multi-Subject dataset</a>.</p>
<p>Edit the file <code class="docutils literal notranslate"><span class="pre">config_sct_run_batch.yml</span></code> according to your setup. Notable flags include:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">path_data</span></code>: If you downloaded the spine-generic data at another location, make sure to update the path;</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">include_list</span></code>: If you only want to run the script in a few subjects, list them here. Example:
<code class="docutils literal notranslate"><span class="pre">include_list:</span> <span class="pre">['sub-unf04',</span> <span class="pre">'sub-unf05']</span></code></p></li>
</ul>
<p>See <code class="docutils literal notranslate"><span class="pre">sct_run_batch</span> <span class="pre">-h</span></code> to look at the available options.</p>
<p>Run the analysis:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sct_run_batch</span> <span class="o">-</span><span class="n">config</span> <span class="n">config_sct_run_batch</span><span class="o">.</span><span class="n">yml</span>
</pre></div>
</div>
<p>:note: <strong>desired subjects using flag -include and in parallel processing using flag -jobs.</strong></p>
<p>To output statistics, run in Dataset</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">csa_rescale_stat</span> <span class="o">-</span><span class="n">i</span> <span class="n">csa_atrophy_results</span><span class="o">/</span><span class="n">results</span> <span class="o">-</span><span class="n">o</span> <span class="n">csa_atrophy_results</span> <span class="o">-</span><span class="n">config</span> <span class="n">config_script</span><span class="o">.</span><span class="n">yml</span> <span class="o">-</span><span class="n">fig</span>
</pre></div>
</div>
</div>
<div class="section" id="quality-control">
<h1>Quality Control<a class="headerlink" href="#quality-control" title="Permalink to this headline">¶</a></h1>
<p>After running the analysis, check your Quality Control (QC) report by opening the file qc/index.html. Use the
“Search” feature of the QC report to quickly jump to segmentations or labeling results. If you spot issues
(wrong labeling), add their filenames in the ‘config_correction.yml’ file
(see https://spine-generic.rtfd.io/en/latest/analysis-pipeline.html for further indications). Then, manually create
labels in the cord at the level of inter-vertebral discs C1-C2, C2-C3, …, C4-C5 with the command:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">manual_correction</span> <span class="o">-</span><span class="n">config</span> <span class="n">config_correction</span><span class="o">.</span><span class="n">yml</span> <span class="o">-</span><span class="n">path</span><span class="o">-</span><span class="ow">in</span> <span class="n">csa_atrophy_results</span><span class="o">/</span><span class="n">data_processed</span> <span class="o">-</span><span class="n">path</span><span class="o">-</span><span class="n">out</span> <span class="n">PATH_DATA</span>
</pre></div>
</div>
<p>The bash script outputs all manual labelings to the derivatives directory in the dataset path defined in <code class="docutils literal notranslate"><span class="pre">path_data</span></code>.
It is now possible to re-run the whole process. With the command below labeling will use the manual corrections that
are present in the derivatives/ folder of the dataset, otherwise labeling will be done automatically.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sct_run_batch</span> <span class="o">-</span><span class="n">config</span> <span class="n">config_sct_run_batch</span><span class="o">.</span><span class="n">yml</span>
</pre></div>
</div>
</div>
<div class="section" id="statistics">
<h1>Statistics<a class="headerlink" href="#statistics" title="Permalink to this headline">¶</a></h1>
<p>After everything is done, compute stats:
Per-subject stat: Panda dataframe <code class="docutils literal notranslate"><span class="pre">df_sub</span></code>:</p>
<ul class="simple">
<li><p>intra-subject MEAN: MEAN[CSA(sI, rX, :)] –&gt; MEAN_intra(sI, rX): <code class="docutils literal notranslate"><span class="pre">df_sub['mean']</span></code></p></li>
<li><p>intra-subject STD: STD[CSA(sI, rX, :)] –&gt; STD_intra(sI, rX): <code class="docutils literal notranslate"><span class="pre">df_sub['std']</span></code></p></li>
<li><p>intra-subject COV: STD[CSA(sI, rX, :)] / MEAN[CSA(sI, rX, :)] –&gt; COV_intra(sI, rX): <code class="docutils literal notranslate"><span class="pre">df_sub['cov']</span></code></p></li>
<li><p>rescale_estimated_subject MEAN: MEAN[CSA(sI, rX, :) / CSA(sI, 1, :)] –&gt; MEAN_rescale_estimated_subject(sI, rX): <code class="docutils literal notranslate"><span class="pre">df_sub['rescale_estimated']</span></code></p></li>
<li><p>intra-subject error MEAN: MEAN[CSA(sI, rX, :)] - (rX^2 * MEAN[CSA(sI, 1, :)]) –&gt; MEAN_error_intra(sI, rX): <code class="docutils literal notranslate"><span class="pre">df_sub['error']</span></code></p></li>
<li><p>intra-subject error in percentage MEAN: [MEAN[CSA(sI, rX, :)] - (rX^2 * MEAN[CSA(sI, 1, :)])] / MEAN[CSA(sI, rX, :)] –&gt; MEAN_error_intra_perc(sI, rX): <code class="docutils literal notranslate"><span class="pre">df_sub['perc_error']</span></code></p></li>
</ul>
<p>Across-subject stats: Panda dataframe <code class="docutils literal notranslate"><span class="pre">df_rescale</span></code></p>
<ul class="simple">
<li><p>intra-subject STD: MEAN[STD_intra(:, rX)] –&gt; STD_intra(rX): <code class="docutils literal notranslate"><span class="pre">df_rescale['std_intra']</span></code></p></li>
<li><p>intra-subject COV: MEAN[COV_intra_sub(:, rX)] –&gt; COV_intra(rX): <code class="docutils literal notranslate"><span class="pre">df_rescale['cov']</span></code></p></li>
<li><p>inter-subject STD: STD[MEAN_intra(:, rX)] –&gt; STD_inter(rX): <code class="docutils literal notranslate"><span class="pre">df_rescale['std_inter']</span></code></p></li>
<li><p>rescale_estimated (across subjects) MEAN: MEAN[MEAN_rescale_estimated_subject(:, rX)] –&gt; MEAN_rescale_estimated(rX): <code class="docutils literal notranslate"><span class="pre">df_rescale['mean_rescale_estimated']</span></code></p></li>
<li><p>rescale_estimated (across subjects) STD: STD[MEAN_rescale_estimated_subject(:, rX)] –&gt; STD_rescale_estimated(rX): <code class="docutils literal notranslate"><span class="pre">df_rescale['std_rescale_estimated']</span></code></p></li>
<li><p>error in percentage (across subjects) MEAN: MEAN[MEAN_error_intra(:, rX)]</p></li>
<li><p>error in percentage (across subjects) STD: STD[MEAN_error_intra(:, rX)]</p></li>
</ul>
<p>Power analysis:</p>
<ul class="simple">
<li><p>sample size: [(z(uncertainty) + z(power))^2 * (2 * STD[MEAN(:, rX)]^2)] / [MEAN[CSA(sI, 1, :)] - MEAN[CSA(sI, rX, :)]]</p></li>
</ul>
<p>Plot results:</p>
<ul class="simple">
<li><p>STD_intersub</p></li>
<li><p>Mean and STD inter-subject error percentage in function of rescaling</p></li>
<li><p>sample size: minimum number of patients to detect an atrophy of X with Y% power and Z% uncertainty</p></li>
<li><p>CSA values boxplot in function of rescaling</p></li>
<li><p>Error values boxplot in function of rescaling</p></li>
</ul>
</div>


</div>

</div>
<footer>

<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">

<a href="statistics.html" class="btn btn-neutral float-right" title="STATISTICS" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>


<a href="index.html" class="btn btn-neutral float-left" title="Welcome to csa-atrophy’s documentation!" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>

</div>


<hr/>

<div role="contentinfo">
<p>

&copy; Copyright 2021, Paul Bautin

</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>
Loading