Skip to content

Commit 15e21bf

Browse files
authored
Merge pull request #36 from cpp-lln-lab/add_child_protection
[ENH] Add input checks to several functions
2 parents ba39937 + 0e24e40 commit 15e21bf

25 files changed

+542
-238
lines changed

.github/workflows/run_tests_matlab.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on:
55
branches:
66
- dev
77
- main
8-
- master
98
pull_request:
109
branches: ['*']
1110
schedule:
@@ -41,8 +40,7 @@ jobs:
4140
git clone https://github.com/MOcov/MOcov.git --depth 1
4241
4342
- name: Add bids-matlab
44-
run: |
45-
git clone https://github.com/bids-standard/bids-matlab.git --depth 1
43+
run: make install_dev
4644

4745
- name: Run commands
4846
uses: matlab-actions/[email protected]

.gitignore

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
.DS_Store
22

33
*.nii
4+
*.json
45
*.xml
56
*.log
6-
*.asv
7-
*.m~
87
*.mat
9-
108
*.html
119

12-
# files in the demo folder related to running the demo analysis
13-
# demos/roi
14-
15-
atlas/visual_topography_probability_atlas/
16-
17-
# test folder and dummy data
18-
1910
# ignore content of the build folder of the doc
2011
docs/build/*
2112

@@ -25,8 +16,49 @@ envs/*
2516
# visual studio code stuff
2617
.vscode
2718

28-
demos/*/*.json
29-
demos/*/*/*.json
19+
atlas/visual_topography_probability_atlas/
20+
3021
demos/*/derivatives
3122

32-
atlas/*.json
23+
24+
#for testing
25+
coveragage_html
26+
lib/bids-matlab
27+
28+
29+
## MATLAB / OCTAVE gitignore template
30+
31+
# From : https://github.com/github/gitignore/blob/master/Global/MATLAB.gitignore
32+
33+
34+
# Windows default autosave extension
35+
*.asv
36+
37+
# OSX / *nix default autosave extension
38+
*.m~
39+
40+
# Compiled MEX binaries (all platforms)
41+
*.mex*
42+
43+
# Packaged app and toolbox files
44+
*.mlappinstall
45+
*.mltbx
46+
47+
# Generated helpsearch folders
48+
helpsearch*/
49+
50+
# Simulink code generation folders
51+
slprj/
52+
sccprj/
53+
54+
# Matlab code generation folders
55+
codegen/
56+
57+
# Simulink autosave extension
58+
*.autosave
59+
60+
# Simulink cache files
61+
*.slxc
62+
63+
# Octave session info
64+
octave-workspace

.readthedocs copy.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# .readthedocs.yml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Build documentation in the docs/ directory with Sphinx
9+
sphinx:
10+
configuration: docs/source/conf.py
11+
builder: html
12+
fail_on_warning: true
13+
14+
# Build documentation with MkDocs
15+
#mkdocs:
16+
# configuration: mkdocs.yml
17+
18+
# Optionally build your docs in additional formats such as PDF
19+
formats:
20+
- pdf
21+
22+
# Optionally set the version of Python and requirements required to build your docs
23+
python:
24+
version: 3.7
25+
install:
26+
- requirements: requirements.txt

CITATION.cff

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
cff-version: 1.2.0
2+
3+
title: "CPP ROI"
4+
5+
version: v0.2.0dev
6+
7+
abstract: Set of Octave and Matlab functions, demos and scripts to help manage ROIs and to play nice with BIDS datasets.
8+
9+
message: "If you use this software, please cite it as below."
10+
11+
repository-code: "https://github.com/cpp-lln-lab/CPP_ROI"
12+
13+
contact:
14+
- affiliation: "Université catholique de Louvain"
15+
16+
family-names: Gau
17+
given-names: Rémi
18+
19+
authors:
20+
- family-names: "Gau"
21+
given-names: "Rémi"
22+
orcid: "https://orcid.org/0000-0002-1535-9767"
23+
affiliation: "Université catholique de Louvain"
24+
25+
- family-names: "Barilari"
26+
given-names: "Marco"
27+
orcid: "https://orcid.org/0000-0002-3313-3120"
28+
affiliation: "Université catholique de Louvain"
29+
30+
- family-names: "Battal"
31+
given-names: "Ceren"
32+
orcid: "https://orcid.org/0000-0002-9844-7630"
33+
affiliation: "Université catholique de Louvain"
34+
35+
- family-names: "Falagiarda"
36+
given-names: "Federica"
37+
orcid: "https://orcid.org/0000-0001-7844-1605"
38+
affiliation: "Université catholique de Louvain"
39+
40+
license: GPL-3.0
41+
42+
keywords:
43+
- BIDS
44+
- brain imaging data structure
45+
- neuroimaging
46+
- MRI
47+
- MATLAB
48+
- Octave
49+
- SPM
50+
- ROI
51+
- region of interest

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.PHONY: clean install_dev
2+
3+
clean:
4+
rm -rf coverage*
5+
rm version.txt
6+
install_dev:
7+
git clone https://github.com/bids-standard/bids-matlab.git --branch dev --depth 1 lib/bids-matlab
8+
9+
version.txt: CITATION.cff
10+
grep -w "^version" CITATION.cff | sed "s/version: /v/g" > version.txt
11+
12+
validate_cff: CITATION.cff
13+
cffconvert --validate

README.md

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
# CPP ROI
2-
3-
---
4-
5-
## :warning:
1+
[![miss_hit_style](https://github.com/cpp-lln-lab/CPP_ROI/actions/workflows/miss_hit_style.yml/badge.svg)](https://github.com/cpp-lln-lab/CPP_ROI/actions/workflows/miss_hit_style.yml)
2+
[![miss_hit_quality](https://github.com/cpp-lln-lab/CPP_ROI/actions/workflows/miss_hit_quality.yml/badge.svg)](https://github.com/cpp-lln-lab/CPP_ROI/actions/workflows/miss_hit_quality.yml)
3+
[![tests and coverage with matlab](https://github.com/cpp-lln-lab/CPP_ROI/actions/workflows/run_tests_matlab.yml/badge.svg)](https://github.com/cpp-lln-lab/CPP_ROI/actions/workflows/run_tests_matlab.yml)
4+
[![codecov](https://codecov.io/gh/cpp-lln-lab/CPP_ROI/branch/main/graph/badge.svg?token=8IoRQtbFUV)](https://codecov.io/gh/cpp-lln-lab/CPP_ROI)
65

7-
**This code is fairly unstable and might still change.**
8-
9-
So make sure you "pin" which version or commit you are using for a given
10-
project, if you don't want your code to break in the future.
11-
12-
---
6+
# CPP ROI
137

148
Set of Octave and Matlab functions, demos and scripts to help manage ROIs and to
159
play nice with BIDS datasets.
@@ -33,41 +27,33 @@ git clone https://github.com/cpp-lln-lab/CPP_ROI.git
3327
Fire up Octave or Matlab and type
3428

3529
```matlab
36-
3730
cd CPP_ROI
3831
3932
% Th following adds the relevant folders to your path.
4033
% This needs to be done once per session (your path will not be saved)
4134
4235
initCppRoi
43-
4436
```
4537

4638
If you are using CPP_SPM, you got nothing to do as CPP_ROI is already installed
4739
as a submodule, and intitialized when running `initCppSpm`.
4840

4941
### Dependencies
5042

51-
======= TODO
52-
53-
| Dependencies | Used version |
54-
| ---------------------------------------------------------- | ------------ |
55-
| [Matlab](https://www.mathworks.com/products/matlab.html) | 20??? |
56-
| or [octave](https://www.gnu.org/software/octave/) | 4.? |
57-
| [SPM12](https://www.fil.ion.ucl.ac.uk/spm/software/spm12/) | v7487 |
58-
59-
- bids-matlab (INSERT URL)
60-
61-
- currently still needs some CPP_SPM function but ultimately should be
62-
standalone: this will most likely happen when some functions are passed to
63-
bids-matlab
43+
| Dependencies | Used version |
44+
| --------------------------------------------------------------- | ------------ |
45+
| [Matlab](https://www.mathworks.com/products/matlab.html) | 20??? |
46+
| or [octave](https://www.gnu.org/software/octave/) | 4.? |
47+
| [SPM12](https://www.fil.ion.ucl.ac.uk/spm/software/spm12/) | v7487 |
48+
| [bids-matlab](https://github.com/bids-standard/bids-matlab.git) | >=0.1.0 |
6449

6550
- Other dependencies (MarsBar) are shipped with CPP_ROI in the `lib` folder.
6651

6752
## Features
6853

6954
- create ROI from probability maps
70-
- create ROI filenames that "BIDS-ish"
55+
- create ROI from atlas (see below)
56+
- create ROI filenames that are "BIDS-ish"
7157
- extract ROI with a given numerical label
7258
- extract ROI from one hemisphere
7359
- breaks a cluster image into several ROIs with each their own label
@@ -88,4 +74,4 @@ as a submodule, and intitialized when running `initCppSpm`.
8874
Also includes:
8975

9076
- Yeo's 7 networks "atlas"
91-
<!-- add REF and URL -->
77+
<!-- add REF and URL -->

demos/roi/roi_script.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@
124124
sphere.radius = 1; % starting radius
125125
sphere.maxNbVoxels = 50;
126126

127-
specification = struct( ...
128-
'mask1', roiName, ...
127+
specification = struct('mask1', roiName, ...
129128
'mask2', sphere);
130129

131130
mask = createRoi('expand', specification, dataImage, opt.outputDir, opt.save.roi);
@@ -162,6 +161,6 @@
162161
% to keep only values above a certain threshold
163162
threshold = 10;
164163
roiName = thresholdToMask(zMap, threshold);
165-
roiName = removeSpmPrefix(roiName, spm_get_defaults('realign.write.prefix'));
164+
roiName = removePrefix(roiName, spm_get_defaults('realign.write.prefix'));
166165

167166
end

docs/README.md

Lines changed: 2 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,2 @@
1-
# Setting up sphinx to create a matlab doc
2-
3-
## Set up virtual environment
4-
5-
```bash
6-
virtualenv -p python3 cpp_spm
7-
source cpp_spm/bin/activate
8-
9-
pip install -r requirements.txt
10-
```
11-
12-
## Quick start on the doc
13-
14-
See the [sphinx doc](https://www.sphinx-doc.org/en/master/usage/quickstart.html)
15-
for more.
16-
17-
This
18-
[blog post](https://medium.com/@richdayandnight/a-simple-tutorial-on-how-to-document-your-python-project-using-sphinx-and-rinohtype-177c22a15b5b)
19-
is also useful.
20-
21-
```bash
22-
cd docs
23-
sphinx-quickstart # launch a basic interactive set up of sphinx
24-
```
25-
26-
Answer the questions on prompt.
27-
28-
## Setting up conf.py for matlab doc
29-
30-
Following the documentation from
31-
[matlabdomain for sphinx](https://github.com/sphinx-contrib/matlabdomain).
32-
33-
Specify the extensions you are using:
34-
35-
```python
36-
extensions = [
37-
'sphinxcontrib.matlab',
38-
'sphinx.ext.autodoc']
39-
```
40-
41-
`matlab_src_dir` in `docs/source/conf.py` should have the path (relative to
42-
`conf.py`) to the folder containing your matlab code:
43-
44-
```python
45-
matlab_src_dir = os.path.dirname(os.path.abspath('../../src'))
46-
```
47-
48-
## reStructured text markup
49-
50-
reStructured text mark up primers:
51-
52-
- on the [sphinx site](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html)
53-
54-
- more
55-
[python oriented](https://pythonhosted.org/an_example_pypi_project/sphinx.html)
56-
57-
- typical doc strings templates
58-
- [google way](https://www.sphinx-doc.org/en/master/usage/extensions/example_google.html)
59-
- [numpy](https://www.sphinx-doc.org/en/master/usage/extensions/example_numpy.html#example-numpy)
60-
61-
## "Templates"
62-
63-
The templates to use for the doc are in the `src/templates` folder.
64-
65-
You then just need to insert this in your `.rst` file for the documentation to
66-
be done automatically.
67-
68-
```rst
69-
70-
.. automodule:: src.folder_name .. <-- This is necessary for auto-documenting the rest
71-
72-
.. autofunction:: function to document
73-
74-
```
75-
76-
To get the filenames of all the functions in a folder:
77-
78-
``` bash
79-
ls -l src/*.m | cut -c42- | rev | cut -c 3- | rev
80-
```
81-
82-
Increase the `42` to crop more characters at the beginning.
83-
84-
Change the `3` to crop more characters at the end.
85-
86-
## Build the documentation locally
87-
88-
From the `docs` directory:
89-
90-
```bash
91-
sphinx-build -b html source build
92-
```
93-
94-
This will build an html version of the doc in the `build` folder.
95-
96-
## Build the documentation with Read the Docs
97-
98-
Add a [`.readthedocs.yml`](../.readthedocs.yml) file in the root of your repo.
99-
100-
See [HERE](https://docs.readthedocs.io/en/stable/config-file/v2.html) for
101-
details.
102-
103-
You can then trigger the build of the doc by going to the
104-
[read the docs website](https://readthedocs.org).
105-
106-
You might need to be added as a maintainer of the doc.
107-
108-
The doc can be built from any branch of a repo.
1+
Information on how to write and build the documentation can be found in our
2+
[CONTRIBUTING guidelines](https://github.com/cpp-lln-lab/.github/blob/main/CONTRIBUTING.md).

0 commit comments

Comments
 (0)