Skip to content

Commit

Permalink
pre-commit: update linters (black=>yapf, mbeautify)
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Jan 10, 2022
1 parent 2fb9d98 commit 2664726
Show file tree
Hide file tree
Showing 16 changed files with 172 additions and 222 deletions.
12 changes: 9 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@ repos:
- 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.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
16 changes: 14 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,24 @@ exclude=tests
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
90 changes: 45 additions & 45 deletions spm12/amypad_seg.m
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
function [param,invdef,fordef] = amypad_seg(f_mri, spm_path, nat_gm, nat_wm, nat_csf, store_fwd, store_inv, visual)
job.channel.vols = {strcat(f_mri,',1')};
job.channel.biasreg = 0.001;
job.channel.biasfwhm = 60;
job.channel.write = [0, 0];
job.tissue(1).tpm = {[spm_path, filesep, 'tpm', filesep, 'TPM.nii,1']};
job.tissue(1).ngaus = 1;
job.tissue(1).native = [nat_gm, 0];
job.tissue(1).warped = [0, 0];
job.tissue(2).tpm = {[spm_path, filesep, 'tpm', filesep, 'TPM.nii,2']};
job.tissue(2).ngaus = 1;
job.tissue(2).native = [nat_wm, 0];
job.tissue(2).warped = [0, 0];
job.tissue(3).tpm = {[spm_path, filesep, 'tpm', filesep, 'TPM.nii,3']};
job.tissue(3).ngaus = 2;
job.tissue(3).native = [nat_csf, 0];
job.tissue(3).warped = [0, 0];
job.tissue(4).tpm = {[spm_path, filesep, 'tpm', filesep, 'TPM.nii,4']};
job.tissue(4).ngaus = 3;
job.tissue(4).native = [0, 0];
job.tissue(4).warped = [0, 0];
job.tissue(5).tpm = {[spm_path, filesep, 'tpm', filesep, 'TPM.nii,5']};
job.tissue(5).ngaus = 4;
job.tissue(5).native = [0, 0];
job.tissue(5).warped = [0, 0];
job.tissue(6).tpm = {[spm_path, filesep, 'tpm', filesep, 'TPM.nii,6']};
job.tissue(6).ngaus = 2;
job.tissue(6).native = [0, 0];
job.tissue(6).warped = [0, 0];
job.warp.mrf = 1;
job.warp.cleanup = 1;
job.warp.reg = [0, 0.001, 0.5, 0.05, 0.2];
job.warp.affreg = 'mni';
job.warp.fwhm = 0;
job.warp.samp = 3;
job.warp.write = [store_fwd, store_inv];
if visual>0
Finter = spm_figure('GetWin','Interactive');
end
spm_jobman('initcfg');
segout = spm_preproc_run(job);
param = segout.param{1};
invdef = segout.invdef{1};
fordef = segout.fordef{1};
%disp(segout);
function [param, invdef, fordef] = amypad_seg(f_mri, spm_path, nat_gm, nat_wm, nat_csf, store_fwd, store_inv, visual)
job.channel.vols = {strcat(f_mri, ',1')};
job.channel.biasreg = 0.001;
job.channel.biasfwhm = 60;
job.channel.write = [0, 0];
job.tissue(1).tpm = {[spm_path, filesep, 'tpm', filesep, 'TPM.nii,1']};
job.tissue(1).ngaus = 1;
job.tissue(1).native = [nat_gm, 0];
job.tissue(1).warped = [0, 0];
job.tissue(2).tpm = {[spm_path, filesep, 'tpm', filesep, 'TPM.nii,2']};
job.tissue(2).ngaus = 1;
job.tissue(2).native = [nat_wm, 0];
job.tissue(2).warped = [0, 0];
job.tissue(3).tpm = {[spm_path, filesep, 'tpm', filesep, 'TPM.nii,3']};
job.tissue(3).ngaus = 2;
job.tissue(3).native = [nat_csf, 0];
job.tissue(3).warped = [0, 0];
job.tissue(4).tpm = {[spm_path, filesep, 'tpm', filesep, 'TPM.nii,4']};
job.tissue(4).ngaus = 3;
job.tissue(4).native = [0, 0];
job.tissue(4).warped = [0, 0];
job.tissue(5).tpm = {[spm_path, filesep, 'tpm', filesep, 'TPM.nii,5']};
job.tissue(5).ngaus = 4;
job.tissue(5).native = [0, 0];
job.tissue(5).warped = [0, 0];
job.tissue(6).tpm = {[spm_path, filesep, 'tpm', filesep, 'TPM.nii,6']};
job.tissue(6).ngaus = 2;
job.tissue(6).native = [0, 0];
job.tissue(6).warped = [0, 0];
job.warp.mrf = 1;
job.warp.cleanup = 1;
job.warp.reg = [0, 0.001, 0.5, 0.05, 0.2];
job.warp.affreg = 'mni';
job.warp.fwhm = 0;
job.warp.samp = 3;
job.warp.write = [store_fwd, store_inv];
if visual > 0
Finter = spm_figure('GetWin', 'Interactive');
end
spm_jobman('initcfg');
segout = spm_preproc_run(job);
param = segout.param{1};
invdef = segout.invdef{1};
fordef = segout.fordef{1};
%disp(segout);
end
4 changes: 1 addition & 3 deletions spm12/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@


def main(argv=None):
logging.basicConfig(
level=logging.DEBUG, format="%(levelname)s:%(funcName)s:%(message)s"
)
logging.basicConfig(level=logging.DEBUG, format="%(levelname)s:%(funcName)s:%(message)s")
args = argopt(__doc__).parse_args(argv)
log.info(args)
if isinstance(args.command, str):
Expand Down

0 comments on commit 2664726

Please sign in to comment.