-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added sphinx for rtd * updated readme, removed utils.bids.py * standardizing docstring formatting * start laying out RTD site * add rtd config, update pyproject.toml * add linting and spellcheck * fix spelling, ignore poetry.lock
- Loading branch information
1 parent
f26bd10
commit e67ad8f
Showing
21 changed files
with
1,250 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# We want to make sure that a user is able to build the docs locally before pushing to RTD. | ||
# Additionally, this helps us to better determine if there is an issue with the RTD build | ||
# versus an issue with sphinx and mkdocs itself. | ||
name: Build Docs with Actions | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
build-install: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
# we only use 3.9 for RTD at this time. | ||
python-version: ["3.9"] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Check python3 == python${{ matrix.python-version }} | ||
run: | | ||
installed_python=$(python3 --version) | ||
echo "Installed Python: $installed_python" | ||
if [[ "$installed_python" != *"${{ matrix.python-version }}"* ]]; then | ||
echo "Python version mismatch. Expected: ${{ matrix.python-version }}, but got: $installed_python" | ||
exit 1 | ||
fi | ||
- name: Install Poetry | ||
run: | | ||
curl -sSL https://install.python-poetry.org | python3 - | ||
- name: Install Dependencies | ||
run: | | ||
poetry install --with dev | ||
- name: Build Docs | ||
run: make docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Codespell configuration is within .codespellrc | ||
name: Lint and Spellcheck | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
pull_request: | ||
branches: [main] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
lintandspell: | ||
name: Check for spelling and formatting errors | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Annotate locations with typos | ||
uses: codespell-project/codespell-problem-matcher@v1 | ||
|
||
- name: Codespell | ||
uses: codespell-project/actions-codespell@v2 | ||
with: | ||
exclude_file: poetry.lock | ||
|
||
- name: Install Poetry | ||
run: | | ||
curl -sSL https://install.python-poetry.org | python3 - | ||
- name: Install Dependencies | ||
run: | | ||
poetry install --with dev | ||
- name: Lint files with Black | ||
run: make check-black |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Read the Docs configuration file | ||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details | ||
|
||
# Required | ||
version: 2 | ||
|
||
# Set the OS, Python version, and other tools you might need | ||
build: | ||
os: ubuntu-24.04 | ||
tools: | ||
python: "3.9" | ||
jobs: | ||
post_create_environment: | ||
- pip install poetry | ||
- poetry config virtualenvs.create false | ||
post_install: | ||
- poetry install --with dev | ||
|
||
# Build documentation in the "docs/" directory with Sphinx | ||
sphinx: | ||
configuration: docs/conf.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Configuration file for the Sphinx documentation builder. | ||
# | ||
# For the full list of built-in configuration values, see the documentation: | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
|
||
# -- Project information ----------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information | ||
|
||
project = "petprep_extract_tacs" | ||
copyright = "2024, Martin Norgaard" | ||
author = "Martin Norgaard" | ||
|
||
# -- General configuration --------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration | ||
|
||
import os | ||
import sys | ||
|
||
sys.path.insert(0, os.path.abspath("..")) | ||
|
||
extensions = [ | ||
"sphinx.ext.autodoc", | ||
"sphinx.ext.napoleon", | ||
] | ||
|
||
templates_path = ["_templates"] | ||
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] | ||
|
||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output | ||
|
||
html_theme = "sphinx_rtd_theme" | ||
# html_static_path = ["_static"] | ||
|
||
|
||
def get_opt_fwhm(opt_params): | ||
""" | ||
Obtain optimal FWHM values from a parameters file. | ||
:param opt_params: Path to the file containing optimal FWHM parameters. | ||
:type opt_params: str | ||
:return: A tuple containing: | ||
- **fwhm_x** (*float*): FWHM value along the x-axis. | ||
- **fwhm_y** (*float*): FWHM value along the y-axis. | ||
- **fwhm_z** (*float*): FWHM value along the z-axis. | ||
- **tsv_file** (*str*): Path to the generated TSV file with FWHM values. | ||
:rtype: tuple | ||
:notes: | ||
This function reads the optimal FWHM parameters from the given file, creates a DataFrame, | ||
saves it as a TSV file named `pvc-agtm_desc-fwhm_confounds.tsv` in the current working directory, | ||
and returns the FWHM values along with the path to the TSV file. | ||
""" | ||
import os | ||
import pandas as pd | ||
|
||
new_pth = os.getcwd() | ||
|
||
with open(opt_params, "r") as file: | ||
contents = file.read() | ||
|
||
# Extracting the FWHM values for x, y, and z from the file | ||
fwhm_values = contents.split() | ||
|
||
# Assigning the values to fwhm_x, fwhm_y, and fwhm_z | ||
fwhm_x, fwhm_y, fwhm_z = map(float, fwhm_values) | ||
|
||
fwhm = pd.DataFrame({"fwhm_x": [fwhm_x], "fwhm_y": [fwhm_y], "fwhm_z": [fwhm_z]}) | ||
|
||
fwhm.to_csv( | ||
os.path.join(new_pth, "pvc-agtm_desc-fwhm_confounds.tsv"), sep="\t", index=False | ||
) | ||
|
||
tsv_file = os.path.join(new_pth, "pvc-agtm_desc-fwhm_confounds.tsv") | ||
|
||
return fwhm_x, fwhm_y, fwhm_z, tsv_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
.. petprep_extract_tacs documentation master file, created by | ||
sphinx-quickstart on Tue Nov 26 14:20:42 2024. | ||
You can adapt this file completely to your liking, but it should at least | ||
contain the root `toctree` directive. | ||
Welcome to petprep_extract_tacs's documentation! | ||
================================================ | ||
|
||
Overview | ||
-------- | ||
|
||
This BIDS App is designed to extract time activity curves (TACs) from PET data. The workflow has options to extract TACs from different regions of the brain, and it uses the Brain Imaging Data Structure (BIDS) standard for organizing and describing the data. This README will guide you through how to use the app and the various options available. The workflow requires that freesurfer's recon-all was already executed for these subjects, and exist as a 'freesurfer' directory inside the derivatives directory for the given BIDS dataset. | ||
|
||
Features | ||
--------- | ||
|
||
* BIDS compliant PET data input and output | ||
* Time Activity Curve extraction from various brain regions | ||
* Options for both surface and volume-based extractions including smoothing options | ||
|
||
Requirements | ||
------------ | ||
|
||
* Python 3.9+ | ||
* FreeSurfer v. 7.3.2 | ||
* MATLAB RUNTIME (`sudo fs_install_mcr R2019b` when FreeSurfer is installed) | ||
|
||
Installation | ||
------------ | ||
|
||
Clone the repository and install the required packages: | ||
|
||
.. code-block:: bash | ||
git clone | ||
git clone https://github.com/mnoergaard/petprep_extract_tacs.git | ||
cd petprep_extract_tacs | ||
pip install -e . | ||
The package is also pip installable and can be installed using the following command | ||
|
||
.. code-block:: bash | ||
pip install petprep-extract-tacs | ||
Quickstart | ||
---------- | ||
|
||
After installation, you'll need to have your data organized according to the BIDS standard. Once that's in place, you can run the app like this: | ||
|
||
.. code-block:: bash | ||
petprep_extract_tacs /path/to/your/bids/dataset /path/to/output/dir --n_procs 4 --wm | ||
Alternatively, you can run the code directly with Python using the `run.py` entrypoint: | ||
|
||
.. code-block:: bash | ||
python3 run.py /path/to/your/bids/dataset /path/to/output/dir --n_procs 4 --wm | ||
This will run the app on your BIDS dataset and save the output to the specified directory. Additional region-specific and smoothing options can be specified as detailed below. | ||
|
||
.. _usage_page: usage.html | ||
|
||
For more detailed usage see the usage_page_ section. | ||
|
||
|
||
.. toctree:: | ||
usage | ||
petprep_extract_tacs | ||
utils | ||
interfaces | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.. _interfaces: | ||
|
||
interfaces | ||
========== | ||
|
||
fs_model | ||
-------- | ||
|
||
.. automodule:: petprep_extract_tacs.interfaces.fs_model | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
fs_preprocess | ||
------------- | ||
|
||
.. automodule:: petprep_extract_tacs.interfaces.fs_preprocess | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
petsurfer | ||
--------- | ||
|
||
.. automodule:: petprep_extract_tacs.interfaces.petsurfer | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
segment | ||
------- | ||
|
||
.. automodule:: petprep_extract_tacs.interfaces.segment | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
Oops, something went wrong.