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

MCR support #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 16 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@ name: Test
on: [push, pull_request]
jobs:
check:
if: github.event_name != 'push' || github.ref != 'refs/heads/devel'
if: github.event_name != 'pull_request' || github.repository_owner != 'AMYPAD'
runs-on: ubuntu-latest
strategy:
matrix:
python: [2.7, 3.6, 3.9]
name: Check py${{ matrix.python }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: set PYSHA
run: echo "PYSHA=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v1
Expand All @@ -22,7 +16,7 @@ jobs:
- name: dependencies
run: pip install -U pre-commit
- uses: reviewdog/action-setup@v1
- if: github.event_name != 'schedule'
- if: github.event_name == 'push' || github.event_name == 'pull_request'
name: comment
run: |
if [[ $EVENT == pull_request ]]; then
Expand All @@ -35,15 +29,14 @@ jobs:
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EVENT: ${{ github.event_name }}
- if: startsWith(matrix.python, '3')
run: pre-commit run -a --show-diff-on-failure
- run: SKIP=mbeautify pre-commit run -a --show-diff-on-failure
test:
if: github.event_name != 'pull_request' || github.head_ref != 'devel'
if: github.event_name != 'pull_request' || github.repository_owner != 'AMYPAD'
name: py${{ matrix.python }}
runs-on: ubuntu-latest
strategy:
matrix:
python: [2.7, 3.6, 3.9]
name: Test py${{ matrix.python }}
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -56,22 +49,25 @@ jobs:
run: pytest --durations-min=1
- if: startsWith(matrix.python, '2')
run: pytest
- run: codecov
- uses: codecov/codecov-action@v1
matlab:
if: github.event_name != 'pull_request' || github.head_ref != 'devel'
if: github.event_name != 'pull_request' || github.repository_owner != 'AMYPAD'
name: matlab py${{ matrix.python }}
runs-on: [self-hosted, python, matlab]
name: Test matlab
strategy:
matrix:
python: [3.9]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Run setup-python
run: setup-python -p3.7
run: setup-python -p${{ matrix.python }}
- run: pip install -U .[dev]
- run: pytest --durations-min=1
- run: codecov
- uses: codecov/codecov-action@v1
- name: Post Run setup-python
run: setup-python -p3.7 -Dr
run: setup-python -p${{ matrix.python }} -Dr
if: ${{ always() }}
deploy:
needs: [check, test, matlab]
Expand All @@ -85,7 +81,8 @@ jobs:
- id: dist
uses: casperdcl/deploy-pypi@v2
with:
pip: true
requirements: twine setuptools wheel setuptools_scm[toml]
build: true
gpg_key: ${{ secrets.GPG_KEY }}
password: ${{ secrets.PYPI_TOKEN }}
upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
Expand Down
20 changes: 14 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.1.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -21,25 +21,33 @@ repos:
- id: todo
name: Check TODO
language: pygrep
args: [-i]
entry: TODO
types: [text]
exclude: ^(.pre-commit-config.yaml|.github/workflows/test.yml)$
args: [-i]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
args: [-j8]
additional_dependencies:
- flake8-broken-line
- flake8-bugbear
- flake8-comprehensions
- flake8-debugger
- flake8-isort
- flake8-string-format
- repo: https://github.com/psf/black
rev: 21.7b0
- repo: https://github.com/google/yapf
rev: v0.32.0
hooks:
- id: black
- id: yapf
args: [-i]
additional_dependencies: [toml]
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
rev: 5.10.1
hooks:
- id: isort
- hooks:
- id: mbeautify
repo: https://github.com/AMYPAD/miutil
rev: v0.9.1
2 changes: 1 addition & 1 deletion LICENCE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2020 AMYPAD
Copyright 2020-2022 AMYPAD

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this project except in compliance with the License.
Expand Down
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
[build-system]
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "spm12/_dist_ver.py"
write_to_template = "__version__ = '{version}'\n"

[tool.black]
target_version = ["py27", "py36", "py38"]
34 changes: 21 additions & 13 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ license=Apache 2.0
license_file=LICENCE.md
url=https://github.com/AMYPAD/SPM12
project_urls=
Changelog = https://github.com/AMYPAD/SPM12/releases
Documentation = https://github.com/AMYPAD/SPM12/#SPM12
Changelog=https://github.com/AMYPAD/SPM12/releases
Documentation=https://github.com/AMYPAD/SPM12/#SPM12
Upstream Project=https://www.fil.ion.ucl.ac.uk/spm
maintainer=Casper da Costa-Luis
maintainer_email=casper.dcl@physics.org
Expand Down Expand Up @@ -36,48 +36,56 @@ classifiers=
Topic :: Software Development :: Libraries
Topic :: System :: Installation/Setup
[options]
zip_safe = False
zip_safe=False
setup_requires=setuptools>=42; wheel; setuptools_scm[toml]>=3.4
install_requires=
argopt
miutil[nii,web]>=0.7.2
setuptools # pkg_resources
miutil[nii,web]>=0.8.0
numpy
scipy
setuptools
include_package_data=True
packages=find:
python_requires=>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*
[options.extras_require]
dev=
pre-commit
twine
wheel
pytest
pytest-cov
pytest-timeout
pytest-xdist
codecov
demo=
miutil[plot]>=0.3.0
matplotlib
[options.entry_points]
console_scripts =
console_scripts=
spm12=spm12.cli:main
[options.packages.find]
exclude=tests
[options.package_data]
*=*.md, *.rst, *.m

[bdist_wheel]
universal = 1
universal=1

[flake8]
max_line_length=88
extend-ignore=E203,P1
max_line_length=99
extend-ignore=P1,E261
exclude=.git,__pycache__,build,dist,.eggs

[yapf]
spaces_before_comment=15, 20
arithmetic_precedence_indication=true
allow_split_before_dict_value=false
coalesce_brackets=True
column_limit=99
each_dict_entry_on_separate_line=False
space_between_ending_comma_and_closing_bracket=False
split_before_named_assigns=False
split_before_closing_bracket=False

[isort]
profile=black
line_length=99
known_first_party=spm12,tests

[tool:pytest]
Expand Down
4 changes: 2 additions & 2 deletions spm12/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .regseg import * # NOQA
from .utils import * # NOQA
from .regseg import * # yapf: disable # NOQA
from .utils import * # yapf: disable # NOQA

# version detector. Precedence: installed dist, git, 'UNKNOWN'
try:
Expand Down
2 changes: 1 addition & 1 deletion spm12/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

from .cli import main

if __name__ == "__main__": # pragma: no cover
if __name__ == "__main__": # pragma: no cover
sys.exit(main(sys.argv[1:]))
42 changes: 21 additions & 21 deletions spm12/amypad_coreg.m
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
function [M, x] = amypad_coreg(imref, imflo, costfun, sep, tol, fwhm, params, graphics, visual)
if visual>0
Fgraph = spm_figure('GetWin','Graphics');
Finter = spm_figure('GetWin','Interactive');
end
if visual > 0
Fgraph = spm_figure('GetWin', 'Graphics');
Finter = spm_figure('GetWin', 'Interactive');
end

cflags.cost_fun = costfun;
cflags.sep = sep;
cflags.tol = tol;
cflags.fwhm = fwhm;
cflags.params = params;
cflags.graphics = graphics;
cflags.cost_fun = costfun;
cflags.sep = sep;
cflags.tol = tol;
cflags.fwhm = fwhm;
cflags.params = params;
cflags.graphics = graphics;

VG = strcat(imref,',1');
VF = strcat(imflo,',1');
VG = strcat(imref, ',1');
VF = strcat(imflo, ',1');

%disp('Matlab internal reference image:'); disp(imref);
%disp('Matlab internal floating image:'); disp(imflo);
%disp(cflags);
%disp(tol);
%disp('Matlab internal reference image:'); disp(imref);
%disp('Matlab internal floating image:'); disp(imflo);
%disp(cflags);
%disp(tol);

spm_jobman('initcfg')
x = spm_coreg(VG, VF, cflags);
M = spm_matrix(x);
spm_jobman('initcfg')
x = spm_coreg(VG, VF, cflags);
M = spm_matrix(x);

%disp('translations and rotations:'); disp(x);
%disp('affine matrix:'); disp(M);
%disp('translations and rotations:'); disp(x);
%disp('affine matrix:'); disp(M);
end
10 changes: 5 additions & 5 deletions spm12/amypad_coreg_modify_affine.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function out = amypad_coreg_modify_affine(imflo, M)
VF = strcat(imflo,',1');
MM = zeros(4,4);
MM(:,:) = spm_get_space(VF);
spm_get_space(VF, M\MM(:,:));
out = 0;
VF = strcat(imflo, ',1');
MM = zeros(4, 4);
MM(:, :) = spm_get_space(VF);
spm_get_space(VF, M \ MM(:, :));
out = 0;
end
16 changes: 8 additions & 8 deletions spm12/amypad_normw.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
function out = amypad_normw(def_file, flist4norm)
job.subj.def = {def_file};
job.subj.resample = flist4norm;
job.woptions.bb = [NaN, NaN, NaN; NaN, NaN, NaN];
job.woptions.vox = [2, 2, 2];
job.woptions.interp = 4;
job.woptions.prefix = 'w';
spm_run_norm(job);
out=0;
job.subj.def = {def_file};
job.subj.resample = flist4norm;
job.woptions.bb = [NaN, NaN, NaN; NaN, NaN, NaN];
job.woptions.vox = [2, 2, 2];
job.woptions.interp = 4;
job.woptions.prefix = 'w';
spm_run_norm(job);
out = 0;
end
36 changes: 18 additions & 18 deletions spm12/amypad_resample.m
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
function out = amypad_resample(imref, imflo, M, f_mask, f_mean, f_interp, f_which, f_prefix)
%-Reslicing parameters
rflags.mask = f_mask;
rflags.mean = f_mean;
rflags.interp = f_interp;
rflags.which = f_which;
rflags.wrap = [0 0 0];
rflags.prefix = f_prefix;
%-Reslicing parameters
rflags.mask = f_mask;
rflags.mean = f_mean;
rflags.interp = f_interp;
rflags.which = f_which;
rflags.wrap = [0, 0, 0];
rflags.prefix = f_prefix;

VG = strcat(imref,',1');
VF = strcat(imflo,',1');
VG = strcat(imref, ',1');
VF = strcat(imflo, ',1');

% disp('Matlab internal reference image:'); disp(imref);
% disp('Matlab internal floating image:'); disp(imflo);
% disp(rflags)
% disp('Matlab internal reference image:'); disp(imref);
% disp('Matlab internal floating image:'); disp(imflo);
% disp(rflags)

MM = zeros(4,4);
MM(:, :) = spm_get_space(VF);
spm_get_space(VF, M\MM(:, :));
P = {VG; VF};
spm_reslice(P, rflags);
out = 0;
MM = zeros(4, 4);
MM(:, :) = spm_get_space(VF);
spm_get_space(VF, M \ MM(:, :));
P = {VG; VF};
spm_reslice(P, rflags);
out = 0;
end
Loading