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

Draft: Overhaul PyDesigner Code #307

Merged
merged 43 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a4d05f2
Init poetry config
TheJaeger May 13, 2023
ef6a44c
Refactor pydesigner package
TheJaeger May 13, 2023
38bdf6e
Replace deprecated `np.str` with `str()`
TheJaeger May 13, 2023
a90f8fd
Update .gitignore
TheJaeger May 19, 2023
fae4512
Introduce type hints [1/2]
TheJaeger May 19, 2023
82fe749
Introduce type hints [2/2]
TheJaeger Sep 21, 2023
733e822
Update .gitignore
TheJaeger Sep 21, 2023
3ba6bb0
Fix type hints
Oct 7, 2023
c548316
Add ODF conversion
Oct 7, 2023
59939be
Fix ODFs and add pre-commit
Oct 7, 2023
4d7d1d0
pre-commit autofixes
Oct 7, 2023
f76349f
Add pre-commit badge
Oct 7, 2023
c37a2d3
Update hooks
Oct 8, 2023
3a7499a
Fix RTD hooks
Oct 8, 2023
6aa3777
Add flake8 and isort checks
Oct 8, 2023
82953b7
Migrate flake8 and isort config
Oct 8, 2023
888d40c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 8, 2023
4878cf8
Refine pre-commit hooks
Oct 8, 2023
bf6162a
Merge remote-tracking branch 'origin/feature/overhaul-project' into f…
Oct 8, 2023
e717c92
Refine pre-commit hooks
Oct 8, 2023
e058da8
Scrape flake8 and isort for ruff
Oct 8, 2023
c435c97
Add test data
TheJaeger Oct 12, 2023
6a6dc88
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 12, 2023
a725326
Resolve ruff checks
TheJaeger Oct 13, 2023
ad35d44
Update Python packages
TheJaeger Oct 13, 2023
ba7942d
Fix lots of issues
TheJaeger Oct 13, 2023
df61d38
Remove logging file
TheJaeger Oct 13, 2023
5ed08b6
Enable isort within ruff
TheJaeger Oct 13, 2023
498e21b
Refine pre-commit hooks
TheJaeger Oct 13, 2023
def5211
disable poetry_export hook
TheJaeger Oct 13, 2023
de2e9b9
Init unit tests
TheJaeger Oct 13, 2023
75488f5
Remove flak8 config
TheJaeger Oct 13, 2023
2bd24c0
Migrate package info to pyproject.toml
TheJaeger Oct 13, 2023
e8fc1bf
Fix bad space
TheJaeger Oct 13, 2023
b3f7900
Init dwipy unit tests
TheJaeger Oct 17, 2023
2072143
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 17, 2023
a36a4ec
Fix ruff errors
TheJaeger Oct 17, 2023
3c4502e
Init GitHub Action CI/CD
TheJaeger Nov 3, 2023
6bf388b
Modify workflows
TheJaeger Nov 3, 2023
191c762
Modify docker workflow
TheJaeger Nov 3, 2023
69c026f
Add multiple build tags
TheJaeger Nov 3, 2023
4b8ef31
Docker build now only runs on tag
TheJaeger Nov 3, 2023
2abd2cd
Save progress for MR move
TheJaeger Nov 3, 2023
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
39 changes: 39 additions & 0 deletions .github/workflows/pydesigner_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# name: Docker Build and Push

# on:
# push:
# tags:
# - '**'

# jobs:
# docker:
# runs-on: ubuntu-latest
# steps:
# -
# name: Checkout
# uses: actions/checkout@v3
# -
# name: Fetch version
# uses: SebRollen/[email protected]
# id: version
# with:
# file: 'pyproject.toml'
# field: 'tool.poetry.version'
# -
# name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# -
# name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# -
# name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# -
# name: Build and push
# uses: docker/build-push-action@v5
# with:
# push: true
# tags: dmri/neurodock:latest,dmri/neurodock:${{ steps.version.outputs.value }}
28 changes: 28 additions & 0 deletions .github/workflows/pydesigner_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: CI

on:
pull_request:
push:
branches: [main]


jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
- name: Run Pre-Commit
uses: pre-commit/[email protected]
with:
pre-commit_version: latest
python_version: 3.8
system: true
# - name: Auto-commit changed files
# uses: stefanzweifel/git-auto-commit-action@v5
# with:
# commit_message: "Pre-commit fixes"


4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ __pycache__/
.vscode/
/docs/build/
dist/
.python-version
.venv/
docs/html/
docs/doctrees/

# Files to ignore
.DS_Store
Expand Down
37 changes: 37 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.5.0'
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: '0.27.0'
hooks:
- id: check-readthedocs

- repo: https://github.com/thclark/pre-commit-sphinx
rev: '0.0.3'
hooks:
- id: build-docs
args: ['--html-dir', 'docs/html', '--source-dir', 'docs/source']
language_version: python3

- repo: https://github.com/psf/black
rev: '23.9.1'
hooks:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.1.0'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/python-poetry/poetry
rev: '1.6.0'
hooks:
- id: poetry-check
# - id: poetry-lock
- id: poetry-export
31 changes: 15 additions & 16 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
# .readthedocs.yml
# Read the Docs configuration file
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/source directory with Sphinx
# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.8"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/source/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

# Optionally set the version of Python and requirements required to build your docs
# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
version: 3.6
install:
- requirements: docs/requirements.txt
- method: pip
path: .
system_packages: true
install:
- requirements: docs/requirements.txt
- method: pip
path: .
8 changes: 4 additions & 4 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ Dec 22, 2020

**Changed**

* Replaced ``preprocessing.util.bvec_is_fullsphere()`` and
``preprocessing.util.vecs_are_fullsphere()`` with
* Replaced ``preprocessing.util.bvec_is_fullsphere()`` and
``preprocessing.util.vecs_are_fullsphere()`` with
``preprocessing.mrinfoutil.is_fullsphere()``. Even though datasets
may be half-shelled, it is inaccurate to label them as such because
distortion relative to b-value is not linear. As such, the
Expand Down Expand Up @@ -383,7 +383,7 @@ Apr 8, 2020
faster EPI distortion correction without degrading DTI/DKI maps.
* Documentation moved to ReadTheDocs
* Moved B0 production module from designer.preprocessing.brainmask to
a separate function at ``designer.preprocessing.extractmeanbzero()``
a separate function at ``designer.preprocessing.extractmeanbzero()``
that gets called by PyDesigner main. This allows a B0.nii to be
produced regardless of the ``--mask`` flag.

Expand Down Expand Up @@ -461,4 +461,4 @@ Initial port of MATLAB code to Python. 200,000,000,000 BCE
.. _v0.3: https://github.com/m-ama/PyDesigner/releases/tag/v0.3
.. _v0.2 [The Cupid Release]: https://github.com/m-ama/PyDesigner/releases/tag/v0.2
.. _dev-0.11: https://github.com/m-ama/PyDesigner/releases/tag/dev-0.11
.. _0.1-dev: https://github.com/m-ama/PyDesigner/releases/tag/0.1-dev
.. _0.1-dev: https://github.com/m-ama/PyDesigner/releases/tag/0.1-dev
52 changes: 25 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,61 +14,57 @@
# ==============================================================================

# Load base Ubuntu image
FROM debian:buster-slim
FROM python:3.11-bullseye

# Add LABEL Information
# ARG BUILD_DATE
# ARG VCS_REF

# Labels.
LABEL maintainer="Siddhartha Dhiman ([email protected])"
# Labels
LABEL maintainer="Siddhartha Dhiman ([email protected])"
LABEL org.label-schema.schema-version="1.0.0-rc1"
LABEL org.label-schema.build-date=$BUILD_DATE
LABEL org.label-schema.name="dmri/pydesigner"
LABEL org.label-schema.description="A state-of-the-art difusion and kurtosis MRI processing pipeline"
LABEL org.label-schema.url="https://github.com/m-ama/"
LABEL org.label-schema.vcs-url="https://github.com/m-ama/NeuroDock.git"
LABEL org.label-schema.vcs-ref=$VCS_REF
LABEL org.label-schema.vendor="MAMA"
LABEL org.label-schema.vendor="MUSC BRIDGE"

ARG DEBIAN_FRONTEND=noninteractive
# ARG DEBIAN_FRONTEND=noninteractive

# Initial update
RUN apt-get update && \
RUN apt update && \
apt-get install -y \
apt-utils \
wget \
curl \
nano \
software-properties-common \
python2.7 python-pip \
python3 \
python3-pip \
jq \
libblas-dev \
liblapack-dev \
libatlas-base-dev \
gfortran

# Install MRTRIX3 dependencies
RUN apt-get install -y --no-install-recommends \
clang \
gfortran \
git \
g++ \
python \
libeigen3-dev \
zlib1g-dev \
libqt4-opengl-dev \
libqt5opengl5-dev \
libqt5svg5-dev \
libgl1-mesa-dev \
libfftw3-dev \
libtiff5-dev \
libomp-dev

RUN rm /bin/sh && ln -s /bin/bash /bin/sh
libpng-dev

# Copy and install PyDesigner
RUN mkdir -p /tmp/PyDesigner
ADD . / /tmp/PyDesigner/
RUN pip3 install /tmp/PyDesigner
RUN echo "alias python=python3" >> ~/.bashrc && source ~/.bashrc
RUN echo "alias pip=pip3" >> ~/.bashrc && source ~/.bashrc
RUN mkdir -p /pydesigner
COPY /pydesigner /app/pydesigner
COPY pyproject.toml app/
RUN ls
RUN ls -la /app
WORKDIR /app
ENV PYTHONPATH=${PYTHONPATH}:${PWD}
RUN pip3 install poetry
RUN poetry config virtualenvs.create false
RUN poetry install --no-dev

# Install Python dependencies
RUN pip3 install --upgrade setuptools && \
Expand Down Expand Up @@ -104,3 +100,5 @@ ENV PATH=$PATH:/usr/lib/mrtrix3/bin
# Remove unwanted packages
RUN apt-get autoremove && apt-get clean
RUN rm /tmp/fslinstaller.py && rm -r /tmp/PyDesigner

USER bridge
24 changes: 14 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ PyDesigner
.. image:: https://img.shields.io/github/downloads-pre/m-ama/pydesigner/latest/total?style=flat-square
:target: https://github.com/m-ama/PyDesigner/releases/latest
:alt: GitHub release (latest SemVer including pre-releases)

.. image:: https://img.shields.io/readthedocs/pydesigner?style=flat-square
:target: https://pydesigner.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://results.pre-commit.ci/badge/github/muscbridge/PyDesigner/master.svg
:target: https://results.pre-commit.ci/latest/github/muscbridge/PyDesigner/master
:alt: pre-commit.ci status

Welcome to the official PyDesigner project!
*******************************************

Expand Down Expand Up @@ -105,13 +109,13 @@ The PyDesigner software packages is based upon the the references
listed below. Please be sure to cite them if PyDesigner was used
in any publications.

1. Jensen JH, Helpern JA, Ramani A, Lu H, Kaczynski K. Diffusional kurtosis imaging: the quantification of non-Gaussian water diffusion by means of MRI. Magn Reson Med 2005;53:1432-1440. doi: 10.1002/mrm.20508
2. Jensen JH, Helpern JA. MRI Quantification of non-Gaussian water diffusion by kurtosis analysis. NMR Biomed 2010;23:698-710. doi: 10.1002/nbm.1518
3. Fieremans E, Jensen JH, Helpern JA. White matter characterization with diffusional kurtosis imaging. Neuroimage 2011;58:177-188. doi: 10.1016/j.neuroimage.2011.06.006
4. Tabesh A, Jensen JH, Ardekani BA, Helpern JA. Estimation of tensors and tensor-derived measures in diffusional kurtosis imaging. Magn Reson Med 2011;65:823-836. doi: 10.1002/mrm.22655
5. Glenn GR, Helpern JA, Tabesh A, Jensen JH. Quantitative assessment of diffusional kurtosis anisotropy. NMR Biomed 2015;28:448-459. doi: 10.1002/nbm.3271
6. Jensen JH, Glenn GR, Helpern JA. Fiber ball imaging. Neuroimage 2016; 124:824-833. doi: 10.1016/j.neuroimage.2015.09.049
7. McKinnon ET, Helpern JA, Jensen JH. Modeling white matter microstructure with fiber ball imaging. Neuroimage 2018;176:11-21. doi: 10.1016/j.neuroimage.2018.04.025
8. Ades-Aron B, Veraart J, Kochunov P, McGuire S, Sherman P, Kellner E, Novikov DS, Fieremans E. Evaluation of the accuracy and precision of the diffusion parameter EStImation with Gibbs and NoisE removal pipeline. Neuroimage. 2018;183:532-543. doi: 10.1016/j.neuroimage.2018.07.066
1. Jensen JH, Helpern JA, Ramani A, Lu H, Kaczynski K. Diffusional kurtosis imaging: the quantification of non-Gaussian water diffusion by means of MRI. Magn Reson Med 2005;53:1432-1440. doi: 10.1002/mrm.20508
2. Jensen JH, Helpern JA. MRI Quantification of non-Gaussian water diffusion by kurtosis analysis. NMR Biomed 2010;23:698-710. doi: 10.1002/nbm.1518
3. Fieremans E, Jensen JH, Helpern JA. White matter characterization with diffusional kurtosis imaging. Neuroimage 2011;58:177-188. doi: 10.1016/j.neuroimage.2011.06.006
4. Tabesh A, Jensen JH, Ardekani BA, Helpern JA. Estimation of tensors and tensor-derived measures in diffusional kurtosis imaging. Magn Reson Med 2011;65:823-836. doi: 10.1002/mrm.22655
5. Glenn GR, Helpern JA, Tabesh A, Jensen JH. Quantitative assessment of diffusional kurtosis anisotropy. NMR Biomed 2015;28:448-459. doi: 10.1002/nbm.3271
6. Jensen JH, Glenn GR, Helpern JA. Fiber ball imaging. Neuroimage 2016; 124:824-833. doi: 10.1016/j.neuroimage.2015.09.049
7. McKinnon ET, Helpern JA, Jensen JH. Modeling white matter microstructure with fiber ball imaging. Neuroimage 2018;176:11-21. doi: 10.1016/j.neuroimage.2018.04.025
8. Ades-Aron B, Veraart J, Kochunov P, McGuire S, Sherman P, Kellner E, Novikov DS, Fieremans E. Evaluation of the accuracy and precision of the diffusion parameter EStImation with Gibbs and NoisE removal pipeline. Neuroimage. 2018;183:532-543. doi: 10.1016/j.neuroimage.2018.07.066
9. Moss H, McKinnon ET, Glenn GR, Helpern JA, Jensen JH. Optimization of data acquisition and analysis for fiber ball imaging. Neuroimage 2019;200;690-703. doi: 10.1016/j.neuroimage.2019.07.005
10. Moss HG, Jensen JH. Optimized rectification of fiber orientation density function. Magn Reson Med. 2020 Jul 25. doi: 10.1002/mrm.28406. Online ahead of print.
10. Moss HG, Jensen JH. Optimized rectification of fiber orientation density function. Magn Reson Med. 2020 Jul 25. doi: 10.1002/mrm.28406. Online ahead of print.
Binary file removed designer/._DESIGNER.py
Binary file not shown.
4 changes: 0 additions & 4 deletions designer/fitting/__init__.py

This file was deleted.

60 changes: 0 additions & 60 deletions designer/fitting/dwi_fnames.py

This file was deleted.

Loading
Loading