Skip to content

Commit

Permalink
Merge pull request #10 from cpp-lln-lab/update_bids_matlab
Browse files Browse the repository at this point in the history
[ENH] Update bids matlab
  • Loading branch information
Remi-Gau authored Jan 28, 2022
2 parents 39e65b6 + c44291b commit 78d38f6
Show file tree
Hide file tree
Showing 32 changed files with 557 additions and 190 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/miss_hit_code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip3 install -r requirements.txt
pip3 install -r requirements.txt
- name: MISS_HIT Metrics
run: |
mh_metric --ci
- name: MISS_HIT Bug finder
run: |
mh_lint
mh_lint
4 changes: 2 additions & 2 deletions .github/workflows/miss_hit_code_style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip3 install -r requirements.txt
pip3 install -r requirements.txt
- name: MISS_HIT Code style
run: |
mh_style --process-slx
mh_style --process-slx
58 changes: 27 additions & 31 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ on:
- master
- main
- dev
pull_request:
branches: '*'

env:
OCTFLAGS: --no-gui --no-window-system --silent
pull_request:
branches: ['*']

jobs:
build:

runs-on: ubuntu-20.04

steps:
Expand All @@ -24,37 +21,36 @@ jobs:
sudo apt-get -y -qq update
sudo apt-get -y install octave liboctave-dev
- name: Clone spm_2_bids
- name: Clone spm_2_bids
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 2

- name: Install SPM
run: |
git clone https://github.com/spm/spm12.git --depth 1
make -C spm12/src PLATFORM=octave distclean
make -C spm12/src PLATFORM=octave
make -C spm12/src PLATFORM=octave install
octave $OCTFLAGS --eval "addpath(fullfile(pwd, 'spm12')); savepath();"
- name: Install Moxunit and MOcov
- name: get bids-matlab and JSONio
run: |
git clone https://github.com/MOxUnit/MOxUnit.git --depth 1
make -C MOxUnit install
git clone https://github.com/MOcov/MOcov.git --depth 1
make -C MOcov install
- name: get bids-matlab and set up paths
run: |
make install_dev
octave $OCTFLAGS --eval "init_env; savepath();"
- name: Run tests
run: |
octave $OCTFLAGS --eval "run_tests"
cat test_report.log | grep 0
bash <(curl -s https://codecov.io/bash)
make install_dev_octave
- name: MOxUnit Action
uses: joergbrech/[email protected]
with:
tests: tests # files or directories containing the MOxUnit test cases
src: src # directories to be added to path before running the tests.
ext: tests/utils lib/bids-matlab lib/JSONio # External resources to add to the search put (excluded from coverage)
# data: # Directory for test data
with_coverage: true
cover_xml_file: coverage.xml

- name: Upload coverage
uses: actions/upload-artifact@v1
with:
name: coverage_file
path: coverage.xml

- name: Code coverage
uses: codecov/codecov-action@v1
with:
file: coverage.xml # optional
flags: unittests # optional
name: codecov-umbrella # optional
fail_ci_if_error: true # optional (default = false)
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
env/

lib/bids-matlab
lib/JSONio

coverage_html
coverage.xml
test_report.log

## MATLAB / OCTAVE gitignore template

Expand Down Expand Up @@ -44,5 +48,3 @@ codegen/

# Octave session info
octave-workspace


16 changes: 15 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,18 @@ repos:
entry: mh_lint
files: ^(.*\.(m|slx))$
language: python
additional_dependencies: [miss_hit]
additional_dependencies: [miss_hit]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: rst-backticks # Detect common mistake of using single backticks when writing rst
- id: rst-inline-touching-normal # Detect mistake of inline code touching normal text in rst
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
install_dev:
git clone https://github.com/bids-standard/bids-matlab.git lib/bids-matlab
cd lib/bids-matlab && git checkout dev
git clone https://github.com/gllmflndn/JSONio.git --depth 1 lib/JSONio

install_dev_octave:
git clone https://github.com/bids-standard/bids-matlab.git lib/bids-matlab
cd lib/bids-matlab && git checkout dev
git clone https://github.com/gllmflndn/JSONio.git --depth 1 lib/JSONio
cd lib/JSONio && mkoctfile --mex jsonread.c jsmn.c -DJSMN_PARENT_LINKS

clean:
rm -rf lib/bids-matlab
rm -rf lib/bids-matlab
rm -rf lib/JSONio
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ When you have set up your repo
[![Build Status](https://travis-ci.com/Remi-gau/template_matlab_analysis.svg?branch=master)](https://travis-ci.com/Remi-gau/template_matlab_analysis)
-->

# spm_2_bids

Small code base to help convert the MRI spm output to a valid bids derivatives.
Expand All @@ -26,4 +27,4 @@ Most of the renaming is based on the SPM prefixes combinations.
It is configurable to adapt to new set of prefixes.

- [Dependencies](./lib/README.md)
- [Documentation](https://spm-2-bids.readthedocs.io/en/latest/)
- [Documentation](https://spm-2-bids.readthedocs.io/en/latest/)
5 changes: 5 additions & 0 deletions binder/apt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
octave
liboctave-dev
gnuplot
ghostscript
tree
2 changes: 2 additions & 0 deletions binder/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
- octave_kernel
11 changes: 11 additions & 0 deletions binder/postBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cd ${HOME}

octave --no-gui --no-window-system --silent --eval "addpath (getenv (\"HOME\")); savepath ();"
octave --no-gui --no-window-system --silent --eval "addpath (fullfile (getenv (\"HOME\"), \"+bids\")); savepath ();"

git clone git://github.com/gllmflndn/JSONio.git --depth 1
cd JSONio; mkoctfile --mex jsonread.c jsmn.c -DJSMN_PARENT_LINKS; cd ..

octave --no-gui --no-window-system --silent --eval "addpath (fullfile (getenv (\"HOME\"), \"JSONio\")); savepath ();"

cd ${HOME}/examples
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
3 changes: 0 additions & 3 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,3 @@ help:
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

doc:
@$(SPHINXBUILD) -b html "$(SOURCEDIR)" "$(BUILDDIR)"
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
## Set up virtual environment

```bash
virtualenv -p python3 your_repo_name
source your_repo_name/bin/activate
virtualenv -p python3.8 env
source env/bin/activate

pip install -r requirements.txt
```
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Sphinx
sphinxcontrib-matlabdomain
sphinxcontrib-napoleon
sphinx_rtd_theme
sphinx_rtd_theme
15 changes: 8 additions & 7 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@

# -- Project information -----------------------------------------------------

project = 'your repo name'
copyright = 'you'
author = 'you'
project = 'spm_2_bids'
author = 'Rémi Gau'

# The full version, including alpha/beta/rc tags
release = 'v0.0.0'
release = 'v0.1.0'


# -- General configuration ---------------------------------------------------
Expand All @@ -31,7 +30,7 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinxcontrib.matlab',
'sphinxcontrib.matlab',
'sphinx.ext.autodoc']
matlab_src_dir = os.path.dirname(os.path.abspath('../../src'))
primary_domain = 'mat'
Expand All @@ -53,6 +52,8 @@
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

autodoc_member_order = 'bysource'


# -- Options for HTML output -------------------------------------------------

Expand All @@ -64,7 +65,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# html_static_path = ['_static']

# html_logo = '_static/logo.png'

Expand All @@ -82,4 +83,4 @@
'searchbox.html',
'donate.html',
]
}
}
11 changes: 9 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. cpp_bids documentation master file
Welcome to CPP BIDS documentation!
**********************************
Welcome to spm_2_bids documentation!
************************************

.. toctree::
:maxdepth: 2
Expand All @@ -12,11 +12,18 @@ Welcome to CPP BIDS documentation!
``spm_2_bids`` only provides names to use but does not actually rename the files.

.. automodule:: src

.. autofunction:: spm_2_bids

.. automodule:: src.defaults

.. autofunction:: check_cfg

.. autoclass:: Mapping
:members:




Indices and tables
==================
Expand Down
6 changes: 4 additions & 2 deletions init_env.m → init_spm_2_bids.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function init_env
function init_spm_2_bids
%
% 1 - Check if version requirements
% are satisfied and the packages are
Expand All @@ -18,10 +18,12 @@
OCTAVE_VER = '4.0.3';
MATLAB_VER = '8.6.0';

INSTALL_LIST = {'io', 'statistics', 'image'};
INSTALL_LIST = {};

if is_octave

more off;

% Exit if min version is not satisfied
if ~compare_versions(OCTAVE_VERSION, OCTAVE_VER, '>=')
error('Minimum required Octave version: %s', OCTAVE_VER);
Expand Down
6 changes: 1 addition & 5 deletions lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@ This code requires:

- SPM12 for some actions ???

- [BIDS-matlab](https://github.com/bids-standard/bids-matlab) from commi
[b7732b0cb](https://github.com/bids-standard/bids-matlab/commit/b7732b0cb2103ee0cfa095ee604bee4086844cad)
or later. In doubt use the `dev` branch of bids-matlab.


- [BIDS-matlab](https://github.com/bids-standard/bids-matlab) ; version 0.1.0
11 changes: 7 additions & 4 deletions miss_hit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ project_root
line_length: 100

regex_function_name: "[a-z]+(_[a-z0-9]+)*"
regex_script_name: "[a-z]+(_[a-z0-9]+)*"
regex_class_name: "[A-Z]{1}[a-z]+"
regex_script_name: "[a-z]+(_[a-z]+)*"

# suppress_rule: "naming_parameters"
# regex_parameter_name: "[a-z]+(_[a-z0-9]+)*"

exclude_dir: "lib"

copyright_entity: "spm_2_bids developers"

# metric for code quality
metric "cnest": limit 6
metric "cnest": limit 5
metric "file_length": limit 500
metric "cyc": limit 25
metric "parameters": limit 5
metric "cyc": limit 13
metric "parameters": limit 5
1 change: 1 addition & 0 deletions notebooks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.ipynb_checkpoints
Loading

0 comments on commit 78d38f6

Please sign in to comment.