Skip to content

Commit

Permalink
Merge branch 'mrds-issue-12'
Browse files Browse the repository at this point in the history
  • Loading branch information
sinhaharsh committed Nov 20, 2023
2 parents c140927 + d919e67 commit 868ee9b
Show file tree
Hide file tree
Showing 65 changed files with 7,739 additions and 1,913 deletions.
28 changes: 28 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[run]
branch = True
omit = */tests/*
_*.py
plotting.py

[report]
; Regexes for lines to exclude from consideration
exclude_also =
; Don't complain about missing debug-only code:
def __repr__
if self\.debug

; Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError

; Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:

; Don't complain about abstract methods, they aren't run:
@(abc\.)?abstractmethod

ignore_errors = True

[html]
directory = htmlcov
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ insert_final_newline = false

[Makefile]
indent_style = tab

[*.py]
max_line_length = 80
41 changes: 41 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: tests

on:
push:
branches:
- master

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.8" ]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install git+https://github.com/sinhaharsh/protocol.git#egg=protocol
pip install git+https://github.com/sinhaharsh/MRdataset.git#egg=MRdataset
if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi
pip install .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,6 @@ ENV/
.vscode/
.idea/
/update_today.txt

# codacy
results.sarif
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

6 changes: 5 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ include HISTORY.rst
include LICENSE
include README.rst

recursive-include tests *
graft mrQA/tests
prune mrQA/tests/htmlcov
prune mrQA/tests/.hypothesis
graft mrQA/scripts
graft mrQA/resources
recursive-exclude * __pycache__
recursive-exclude * *.py[co]

Expand Down
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ clean-test: ## remove test and coverage artifacts
rm -fr .pytest_cache

lint/flake8: ## check style with flake8
flake8 mrQA tests
flake8 mrQA

lint: lint/flake8 ## check style

Expand All @@ -59,18 +59,15 @@ test-all: ## run tests on every Python version with tox
tox

coverage: ## check code coverage quickly with the default Python
coverage run --source mrQA -m pytest
coverage run --rcfile=.coveragerc --source mrQA -m pytest
coverage report -m
coverage html
$(BROWSER) htmlcov/index.html

docs: ## generate Sphinx HTML documentation, including API docs
rm -f docs/mrQA.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs/ mrQA
$(MAKE) -C docs clean
$(MAKE) -C docs html
$(BROWSER) docs/_build/html/index.html
$(BROWSER) docs/build/html/index.html

servedocs: docs ## compile the docs watching for changes
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
Expand Down
8 changes: 6 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ mrQA : automatic protocol compliance checks on MR datasets
.. image:: https://img.shields.io/pypi/v/mrQA.svg
:target: https://pypi.python.org/pypi/mrQA

.. image:: https://img.shields.io/travis/Open-Minds-Lab/mrQA.svg
:target: https://travis-ci.com/Open-Minds-Lab/mrQA
.. image:: https://app.codacy.com/project/badge/Grade/8cd263e1eaa0480d8fac50eba0094401
:target: https://app.codacy.com/gh/sinhaharsh/mrQA/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade

.. image:: https://github.com/sinhaharsh/mrQA/actions/workflows/continuos-integration.yml/badge.svg
:target: https://github.com/sinhaharsh/mrQA/actions/workflows/continuos-integration.yml


.. image:: https://raw.githubusercontent.com/jupyter/design/master/logos/Badges/nbviewer_badge.svg
:target: https://nbviewer.org/github/Open-Minds-Lab/mrQA/blob/master/examples/usage.ipynb
Expand Down
7 changes: 7 additions & 0 deletions docs/cli.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Command Line
============

.. argparse::
:module: mrQA.cli
:func: get_parser
:prog: mrQA
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon']
'sphinx.ext.napoleon',
'sphinxarg.ext']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down
12 changes: 10 additions & 2 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@ CLI usage
A protocol compliance report can be generated directly from the command line
interface. The following is an example of generating a protocol compliance report

For a DICOM dataset::
For a DICOM dataset

.. code:: bash
mrqa --data-source /path/to/dataset --format dicom --name my_dataset
For a BIDS dataset::
For a BIDS dataset

.. code:: bash
mrqa --data-source /path/to/dataset --format bids --name my_dataset
.. toctree::
:maxdepth: 1

cli

API Tutorial
------------
Expand Down
37 changes: 37 additions & 0 deletions examples/check_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from pathlib import Path
from mrQA import monitor
import tempfile
import shutil

from mrQA.tests.test_utils import copy2dest


def run(folder_path):
folder_path = Path(folder_path).resolve()
config_path = Path('./mri-config.json').resolve()
# make a temporary output folder using tempfile
with tempfile.TemporaryDirectory() as tmpdirname:
output_dir = Path(tmpdirname) / 'output'
input_dir = Path(tmpdirname) / 'input'
output_dir.mkdir(exist_ok=True, parents=True)
input_dir.mkdir(exist_ok=True, parents=True)
i = 0
# copy a folder from folder_path to tmpdirname
for folder in folder_path.iterdir():
if folder.is_dir():
copy2dest(folder, folder_path, input_dir)

# Run monitor on the temporary folder
monitor(name='dummy_dataset',
data_source=input_dir,
output_dir=output_dir,
decimals=2,
config_path=config_path,
verbose=False,
reference_path='./wpc-6106.xml'
)
copy2dest(output_dir, tmpdirname, '/tmp')
print('simulation-over')


run('/home/sinhah/scan_data/WPC-6106')
Loading

0 comments on commit 868ee9b

Please sign in to comment.