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

[MAINT] lint with miss hit #30

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,32 @@ repos:
- id: check-merge-conflict


- repo: local

hooks:
- id: mh_style
name: mh_style
entry: mh_style
args: [--process-slx, --fix]
files: ^(.*\.(m|slx))$
language: python
additional_dependencies: [miss_hit_core]

- id: mh_metric
name: mh_metric
entry: mh_metric
args: [--ci]
files: ^(.*\.(m|slx))$
language: python
additional_dependencies: [miss_hit_core]

- id: mh_lint
name: mh_lint
entry: mh_lint
files: ^(.*\.(m|slx))$
language: python
additional_dependencies: [miss_hit]

- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.3
hooks:
Expand Down
20 changes: 20 additions & 0 deletions miss_hit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
project_root

octave: true

# style guide (https://florianschanda.github.io/miss_hit/style_checker.html)
line_length: 110

# camelCase
regex_script_name: "[a-zA-Z0-9]+(_[a-zA-Z0-9]*)*"

suppress_rule: "naming_parameters"
suppress_rule: "copyright_notice"

tab_width: 4

# metrics limit for the code quality (https://florianschanda.github.io/miss_hit/metrics.html)
metric "cnest": limit 4
metric "file_length": limit 500
metric "cyc": limit 47
metric "parameters": limit 5
28 changes: 15 additions & 13 deletions pipeline_group.m
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
%==========================================================================
% ==========================================================================
% C O N F I G U R A T I O N F I L E : G R O U P
%==========================================================================
% ==========================================================================

% Available variables: BIDS and BIDS_App

%==========================================================================
%-Structural mean image
%==========================================================================
a = spm_select('FPListRec',BIDS_App.outdir,'wm.*_T1w.nii');
if isempty(a), error('Cannot find preprocessed T1-weighted images.'); end
% ==========================================================================
% -Structural mean image
% ==========================================================================
a = spm_select('FPListRec', BIDS_App.outdir, 'wm.*_T1w.nii');
if isempty(a)
error('Cannot find preprocessed T1-weighted images.');
end

clear matlabbatch
clear matlabbatch;

matlabbatch{1}.spm.util.imcalc.input = cellstr(a);
matlabbatch{1}.spm.util.imcalc.output = 'meanT1w.nii';
Expand All @@ -19,9 +21,9 @@
matlabbatch{1}.spm.util.imcalc.options.dmtx = 1;
matlabbatch{1}.spm.util.imcalc.options.dtype = 4;

[~,prov] = spm_jobman('run',matlabbatch);
[~, prov] = spm_jobman('run', matlabbatch);

%==========================================================================
%-Second Level fMRI
%==========================================================================
%fprintf('Nothing to do at fMRI second level.\n');
% ==========================================================================
% -Second Level fMRI
% ==========================================================================
% fprintf('Nothing to do at fMRI second level.\n');
57 changes: 30 additions & 27 deletions pipeline_participant.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
%==========================================================================
% ==========================================================================
% C O N F I G U R A T I O N F I L E : P A R T I C I P A N T
%==========================================================================
% ==========================================================================

% Available variables: BIDS and BIDS_App

%==========================================================================
%-fMRI Preprocessing
%==========================================================================
% ==========================================================================
% -fMRI Preprocessing
% ==========================================================================
% ask for: slice timing correction (before or after realign)
% ask for: fieldmap
% ask for: realign and unwarp
Expand All @@ -18,48 +18,51 @@
vox_func = [3 3 3];
FWHM = [12 12 12];

f = spm_BIDS(BIDS,'data', 'modality','func', 'type','bold');
if isempty(f), error('Cannot find BOLD time series.'); end
a = spm_BIDS(BIDS,'data', 'modality','anat', 'type','T1w');
if isempty(a), error('Cannot find T1-weighted image.'); end
f = spm_BIDS(BIDS, 'data', 'modality', 'func', 'type', 'bold');
if isempty(f)
error('Cannot find BOLD time series.');
end
a = spm_BIDS(BIDS, 'data', 'modality', 'anat', 'type', 'T1w');
if isempty(a)
error('Cannot find T1-weighted image.');
end

clear matlabbatch
clear matlabbatch;

% Realign
%------------------------------------------------------------------
matlabbatch{1}.spm.spatial.realign.estwrite.data = cellfun(@(x) {{x}},f)';
% ------------------------------------------------------------------
matlabbatch{1}.spm.spatial.realign.estwrite.data = cellfun(@(x) {{x}}, f)';
matlabbatch{1}.spm.spatial.realign.estwrite.roptions.which = [0 1];

% Coregister
%------------------------------------------------------------------
matlabbatch{2}.spm.spatial.coreg.estimate.ref = cellstr(spm_file(f{1},'prefix','mean','number',1));
% ------------------------------------------------------------------
matlabbatch{2}.spm.spatial.coreg.estimate.ref = cellstr(spm_file(f{1}, 'prefix', 'mean', 'number', 1));
matlabbatch{2}.spm.spatial.coreg.estimate.source = cellstr(a);

% Segment
%------------------------------------------------------------------
% ------------------------------------------------------------------
matlabbatch{3}.spm.spatial.preproc.channel.vols = cellstr(a);
matlabbatch{3}.spm.spatial.preproc.channel.write = [0 1];
matlabbatch{3}.spm.spatial.preproc.warp.write = [0 1];

% Normalise: Write
%------------------------------------------------------------------
matlabbatch{4}.spm.spatial.normalise.write.subj.def = cellstr(spm_file(a,'prefix','y_','ext','nii'));
% ------------------------------------------------------------------
matlabbatch{4}.spm.spatial.normalise.write.subj.def = cellstr(spm_file(a, 'prefix', 'y_', 'ext', 'nii'));
matlabbatch{4}.spm.spatial.normalise.write.subj.resample = cellstr(f);
matlabbatch{4}.spm.spatial.normalise.write.woptions.vox = vox_func;

matlabbatch{5}.spm.spatial.normalise.write.subj.def = cellstr(spm_file(a,'prefix','y_','ext','nii'));
matlabbatch{5}.spm.spatial.normalise.write.subj.resample = cellstr(spm_file(a,'prefix','m','ext','nii'));
matlabbatch{5}.spm.spatial.normalise.write.subj.def = cellstr(spm_file(a, 'prefix', 'y_', 'ext', 'nii'));
matlabbatch{5}.spm.spatial.normalise.write.subj.resample = cellstr(spm_file(a, 'prefix', 'm', 'ext', 'nii'));
matlabbatch{5}.spm.spatial.normalise.write.woptions.vox = vox_anat;

% Smooth
%------------------------------------------------------------------
matlabbatch{6}.spm.spatial.smooth.data = cellstr(spm_file(f,'prefix','w'));
% ------------------------------------------------------------------
matlabbatch{6}.spm.spatial.smooth.data = cellstr(spm_file(f, 'prefix', 'w'));
matlabbatch{6}.spm.spatial.smooth.fwhm = FWHM;

[~,prov] = spm_jobman('run',matlabbatch);
[~, prov] = spm_jobman('run', matlabbatch);


%==========================================================================
%-First Level fMRI
%==========================================================================
%fprintf('Nothing to do at fMRI first level.\n');
% ==========================================================================
% -First Level fMRI
% ==========================================================================
% fprintf('Nothing to do at fMRI first level.\n');
Loading