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

Revamp the software section #19

Merged
merged 15 commits into from
Dec 12, 2021
Binary file added .gitbook/assets/github-mark-120px-plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ _build/

.DS_Store
Thumbs.db

gallery.txt
94 changes: 94 additions & 0 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
extensions = [
'myst_parser', # there's also myst_nb, which supports embedding Jupyter notebooks, but is heavier.
'sphinx_panels',
'sphinx_design',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a strange dependency. It pulls in bootstrap? But bootstrap has already been deprecated for several years by the existence of https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Grids. If I look at the web debugger in https://sphinx-design.readthedocs.io/en/sbt-theme/grids.html#grid-options I see they're not using that at all though:

2021-12-04-173551_337x69_scrot

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is needed, otherwise on compilation i get:

/Users/julien/code/neuro.polymtl.ca/gallery.txt:2: WARNING: Unknown directive type "grid".

]

myst_heading_anchors = 4 # enable #section links: https://myst-parser.readthedocs.io/en/latest/syntax/optional.html#syntax-header-anchors
Expand Down Expand Up @@ -103,3 +104,96 @@
"README.html")): # don't create dangling symlinks;
# it annoyes Github Pages.
os.symlink("README.html", z)




# -- Custom scripts ----------------------------------------------------------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be above

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, fixed in 176ebe5


import os
from pathlib import Path
import random
import requests
from subprocess import run
from textwrap import dedent
from urllib.parse import urlparse
from ghapi.all import GhApi
import pandas as pd

import yaml

from sphinx.application import Sphinx
from sphinx.util import logging

LOGGER = logging.getLogger("conf")

def build_gallery(app: Sphinx):
Copy link
Member

@kousu kousu Dec 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's inelegant to do all this in the conf.py file, running it on every parse like this.

It would be significantly cleaner to package this script as a custom directive, stick it up on pypi, and then instead of

```{include} gallery.txt

```

do

```{gallery}
- name: Spinal Cord Toolbox
  website: https://spinalcordtoolbox.com/
  repository: https://github.com/spinalcordtoolbox/spinalcordtoolbox
  image: https://raw.githubusercontent.com/spinalcordtoolbox/spinalcordtoolbox/master/documentation/source/_static/img/logo_sct.png
- name: ivadomed
  website: https://ivadomed.org
  repository: https://github.com/ivadomed/ivadomed
  image: https://raw.githubusercontent.com/ivadomed/ivadomed/master/images/ivadomed_logo.png
- name: qMRLab
  website: https://qmrlab.readthedocs.io
  repository: https://github.com/qMRLab/qMRLab
  image: https://raw.githubusercontent.com/qMRLab/documentation/master/logo/qMR_logo_orig.png
- name: Shimming Toolbox
  website: https://shimming-toolbox.org
  repository: https://github.com/shimming-toolbox
  image: https://raw.githubusercontent.com/shimming-toolbox/shimming-toolbox/master/docs/source/_static/img/shimming_toolbox_logo.png
- name: AxonDeepSeg
  website: https://axondeepseg.readthedocs.io/
  repository: https://github.com/neuropoly/axondeepseg
  image: https://raw.githubusercontent.com/neuropoly/axondeepseg/master/docs/source/_static/logo_ads-alpha.png
```

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and those images should be inlined

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed-- but i don't have the time to do it, so #47

# Build the gallery file
LOGGER.info("building gallery...")
grid_items = []
projects = yaml.safe_load((Path(app.srcdir) / "gallery.yml").read_text())
random.shuffle(projects)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'shuffle'?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah! thanks, i was wondering why they were shuffled 😅

fixed in c3e6c8c

for item in projects:
if not item.get("image"):
item["image"] = "https://jupyterbook.org/_images/logo-square.svg"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This image should be inlined

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, fixed in 72c5bf1


repo_text = ""
star_text = ""

if item["repository"]:
repo_text = f'{{bdg-link-secondary}}`repo <{item["repository"]}>`'

try:
url = urlparse(item["repository"])
if url.netloc == "github.com":
_, org, repo = url.path.rstrip("/").split("/")
star_text = f"[![GitHub Repo stars](https://img.shields.io/github/stars/{org}/{repo}?style=social)]({item['repository']})"
except Exception as error:
pass

grid_items.append(
f"""\
`````{{grid-item-card}} {" ".join(item["name"].split())}
:text-align: center
<img src="{item["image"]}" alt="logo" loading="lazy" style="max-width: 100%; max-height: 200px; margin-top: 1rem;" />
+++
````{{grid}} 2 2 2 2
:margin: 0 0 0 0
:padding: 0 0 0 0
:gutter: 1
```{{grid-item}}
:child-direction: row
:child-align: start
:class: sd-fs-5
{{bdg-link-secondary}}`website <{item["website"]}>`
{repo_text}
```
```{{grid-item}}
:child-direction: row
:child-align: end
{star_text}
```
````
`````
"""
)
grid_items = "\n".join(grid_items)

# :column: text-center col-6 col-lg-4
# :card: +my-2
# :img-top-cls: w-75 m-auto p-2
# :body: d-none

panels = f"""
``````{{grid}} 1 2 3 3
:gutter: 1 1 2 2
:class-container: full-width
{dedent(grid_items)}
``````
"""
(Path(app.srcdir) / "gallery.txt").write_text(panels)


def setup(app: Sphinx):
app.add_css_file("_static/theme.css")
app.connect("builder-inited", build_gallery)
20 changes: 20 additions & 0 deletions gallery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- name: Spinal Cord Toolbox
website: https://spinalcordtoolbox.com/
repository: https://github.com/spinalcordtoolbox/spinalcordtoolbox
image: https://raw.githubusercontent.com/spinalcordtoolbox/spinalcordtoolbox/master/documentation/source/_static/img/logo_sct.png
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These images should be inlined

Copy link
Member

@jcohenadad jcohenadad Dec 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't understand this comment (ie: what do you mean by 'inlined'?)

- name: ivadomed
website: https://ivadomed.org
repository: https://github.com/ivadomed/ivadomed
image: https://raw.githubusercontent.com/ivadomed/ivadomed/master/images/ivadomed_logo.png
- name: qMRLab
website: https://qmrlab.readthedocs.io
repository: https://github.com/qMRLab/qMRLab
image: https://raw.githubusercontent.com/qMRLab/documentation/master/logo/qMR_logo_orig.png
- name: Shimming Toolbox
website: https://shimming-toolbox.org
repository: https://github.com/shimming-toolbox
image: https://raw.githubusercontent.com/shimming-toolbox/shimming-toolbox/master/docs/source/_static/img/shimming_toolbox_logo.png
- name: AxonDeepSeg
website: https://axondeepseg.readthedocs.io/
repository: https://github.com/neuropoly/axondeepseg
image: https://raw.githubusercontent.com/neuropoly/axondeepseg/master/docs/source/_static/logo_ads-alpha.png
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"myst-parser",
"sphinx-book-theme",
"sphinx-panels",
# pinned because of this bug https://github.com/pydata/pydata-sphinx-theme/pull/509
"sphinx-design~=0.0.11",
# pinned because of this bug https://github.com/pydata/pydata-sphinx-theme/pull/509
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

careful, this changed the meaning of the comment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, fixed in 72c5bf1

# and that the patched sphinx-book-theme isn't out yet: https://github.com/executablebooks/sphinx-book-theme/issues/428#issuecomment-966021270
"sphinx~=4.2.0", # TODO: unpin when the next sphinx-book-theme is released
],
Expand Down
43 changes: 22 additions & 21 deletions software.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,29 @@

Below is a list of software projects created at **NeuroPoly** or at collaborative institutions. These projects are open source and freely available.

### MRI

| Name | Description | Source | Documentation |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ivadomed | Comprehensive and open-source repository of deep learning methods for medical data segmentation | [<i class="fab fa-github" title="Source" aria-hidden="true"></i><span>Source</span>](https://github.com/ivadomed/ivadomed) | [<i class="fa fa-book" title="Documentation" aria-hidden="true"></i><span>Documentation</span>](https://ivadomed.org/en/latest/) |
| Multiclass Segmentation | Code related to the NIH marmoset longitudinal segmentation project | [<i class="fab fa-github" title="Source" aria-hidden="true"></i><span>Source</span>](https://github.com/neuropoly/multiclass-segmentation) | [<i class="fa fa-book" title="Documentation" aria-hidden="true"></i><span>Documentation</span>](https://github.com/neuropoly/multiclass-segmentation/blob/master/README.md) |
| qMRLab | Software for data aimulation, analysis, and visualization of qMRI data (Magnetization Transfer, Diffusion, etc.) | [<i class="fab fa-github" title="Source" aria-hidden="true"></i><span>Source</span>](https://github.com/qMRLab/qMRLab) | [<i class="fa fa-book" title="Documentation" aria-hidden="true"></i><span>Documentation</span>](https://qmrlab.readthedocs.io/en/master/) |
| Shimming Toolbox | Code for performing real-time shimming using external MRI shim coils | [<i class="fab fa-github" title="Source" aria-hidden="true"></i><span>Source</span>](https://github.com/shimming-toolbox) | [<i class="fa fa-book" title="Documentation" aria-hidden="true"></i><span>Documentation</span>](https://shimming-toolbox.org/en/latest/) |
| Spinal Cord Toolbox | Comprehensive and open-source library of analysis tools for multi-parametric MRI of the spinal cord | [<i class="fab fa-github" title="Source" aria-hidden="true"></i><span>Source</span>](https://github.com/neuropoly/spinalcordtoolbox) | [<i class="fa fa-book" title="Documentation" aria-hidden="true"></i><span>Documentation</span>](https://spinalcordtoolbox.com/en/latest/) |
| Template | A framework for creating unbiased MRI templates of the spinal cord | [<i class="fab fa-github" title="Source" aria-hidden="true"></i><span>Source</span>](https://github.com/neuropoly/template) | [<i class="fa fa-book" title="Documentation" aria-hidden="true"></i><span>Documentation</span>](https://github.com/neuropoly/template/blob/master/README.md) |

### Histology

| Name | Description | Source | Documentation |
| ---------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Atlas Rat | Scripts to generate a microstructure atlas of the rat spinal cord | [<i class="fab fa-github" title="Source" aria-hidden="true"></i><span>Source</span>](https://github.com/neuropoly/atlas-rat) | [<i class="fa fa-book" title="Documentation" aria-hidden="true"></i><span>Documentation</span>](https://github.com/neuropoly/atlas-rat/blob/master/README.md\|Documentation) |
| AxonSeg | Automatic segmentation of axon and myelin from microscopy data | [<i class="fab fa-github" title="Source" aria-hidden="true"></i><span>Source</span>](https://github.com/neuropoly/axonseg) | [<i class="fa fa-book" title="Documentation" aria-hidden="true"></i><span>Documentation</span>](https://github.com/neuropoly/axonseg/blob/master/README.md) |
| AxonDeepSeg | Segmentation software for microscopy data using deep learning | [<i class="fab fa-github" title="Source" aria-hidden="true"></i><span>Source</span>](https://github.com/neuropoly/axondeepseg) | [<i class="fa fa-book" title="Documentation" aria-hidden="true"></i><span>Documentation</span>](https://axondeepseg.readthedocs.io/en/latest/) |
| AxonPacking | Simulation software for arrangements of axons in white matter | [<i class="fab fa-github" title="Source" aria-hidden="true"></i><span>Source</span>](https://github.com/neuropoly/axonpacking) | [<i class="fa fa-book" title="Documentation" aria-hidden="true"></i><span>Documentation</span>](https://github.com/neuropoly/axonpacking/blob/master/README.md) |
| Tract Clustering | Data-driven approach for tracts in rat histology | [<i class="fab fa-github" title="Source" aria-hidden="true"></i><span>Source</span>](https://github.com/neuropoly/tract-clustering) | [<i class="fa fa-book" title="Documentation" aria-hidden="true"></i><span>Documentation</span>](https://github.com/neuropoly/tract-clustering/blob/master/README.md) |
```{include} gallery.txt
```

<!-- Deprecated software:

| | Multiclass Segmentation | Code related to the NIH marmoset longitudinal segmentation project | [<i class="fab fa-github" title="Source" aria-hidden="true"></i><span>Source</span>](https://github.com/neuropoly/multiclass-segmentation) | [<i class="fa fa-book" title="Documentation" aria-hidden="true"></i><span>Documentation</span>](https://github.com/neuropoly/multiclass-segmentation/blob/master/README.md) |

| | AxonSeg | Automatic segmentation of axon and myelin from microscopy data | [<i class="fab fa-github" title="Source" aria-hidden="true"></i><span>Source</span>](https://github.com/neuropoly/axonseg) | [<i class="fa fa-book" title="Documentation" aria-hidden="true"></i><span>Documentation</span>](https://github.com/neuropoly/axonseg/blob/master/README.md) |


| | AxonPacking | Simulation software for arrangements of axons in white matter | [<i class="fab fa-github" title="Source" aria-hidden="true"></i><span>Source</span>](https://github.com/neuropoly/axonpacking) | [<i class="fa fa-book" title="Documentation" aria-hidden="true"></i><span>Documentation</span>](https://github.com/neuropoly/axonpacking/blob/master/README.md) |
-->

<!-- Data / Atlas to add in another section

| | Template | A framework for creating unbiased MRI templates of the spinal cord | [<i class="fab fa-github" title="Source" aria-hidden="true"></i><span>Source</span>](https://github.com/neuropoly/template) | [<i class="fa fa-book" title="Documentation" aria-hidden="true"></i><span>Documentation</span>](https://github.com/neuropoly/template/blob/master/README.md) |

| | Atlas Rat | Scripts to generate a microstructure atlas of the rat spinal cord | [<i class="fab fa-github" title="Source" aria-hidden="true"></i><span>Source</span>](https://github.com/neuropoly/atlas-rat) | [<i class="fa fa-book" title="Documentation" aria-hidden="true"></i><span>Documentation</span>](https://github.com/neuropoly/atlas-rat/blob/master/README.md) |

| | Tract Clustering | Data-driven approach for tracts in rat histology | [<i class="fab fa-github" title="Source" aria-hidden="true"></i><span>Source</span>](https://github.com/neuropoly/tract-clustering) | [<i class="fa fa-book" title="Documentation" aria-hidden="true"></i><span>Documentation</span>](https://github.com/neuropoly/tract-clustering/blob/master/README.md) |
-->


### Contributing

**NeuroPoly** welcomes and appreciates contributions. To get started, please check out [**NeuroPoly**'s contributing guidelines](https://intranet.neuro.polymtl.ca/geek-tips/contributing).