Skip to content

Commit 75c2459

Browse files
authored
Merge pull request #5 from Remi-Gau/master
Add README and implement travis CI
2 parents 3804278 + eb7d812 commit 75c2459

File tree

5 files changed

+116
-12
lines changed

5 files changed

+116
-12
lines changed

.travis.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Travis CI (https://travis-ci.org/)
2+
3+
language: c
4+
dist: bionic
5+
cache:
6+
apt: true # only works with Pro version
7+
8+
env:
9+
global:
10+
- OCTFLAGS="--no-gui --no-window-system --silent"
11+
12+
before_install:
13+
- travis_retry sudo apt-get -y -qq update
14+
- travis_retry sudo apt-get -y install octave
15+
- travis_retry sudo apt-get -y install liboctave-dev
16+
- travis_retry sudo apt-get -y install nodejs
17+
- travis_retry sudo apt-get -y install npm
18+
19+
install:
20+
# Install JSONio
21+
#- travis_retry git clone git://github.com/gllmflndn/JSONio.git --depth 1
22+
#- cd JSONio; mkoctfile --mex jsonread.c jsmn.c -DJSMN_PARENT_LINKS; cd ..
23+
#- octave $OCTFLAGS --eval "addpath (fullfile (pwd, 'JSONio')); savepath ();"
24+
# Install BIDS-MATLAB
25+
- octave $OCTFLAGS --eval "addpath (pwd); savepath ();"
26+
# Install BIDS-Validator
27+
#- sudo npm install -g bids-validator
28+
29+
before_script:
30+
# Change current directory
31+
- cd tests
32+
33+
script:
34+
- octave $OCTFLAGS --eval "results = runtests; assert(all(~[results.Failed]))"

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# CPP_BIDS
2+
3+
A set of function for matlab and octave to create [BIDS-compatible](https://bids-specification.readthedocs.io/en/stable/) folder structure and filenames for the output of behavioral, EEG, fMRI, eyetracking studies.
4+
5+
6+
## Contributing
7+
8+
Feel free to open issues to report a bug and ask for improvements.
9+
10+
### Guidestyle
11+
12+
- We use camelCase.
13+
- We keep the McCabe complexity as reported by the [check_my_code function](https://github.com/Remi-Gau/matlab_checkcode) below 15.
14+
15+
16+
## Functions descriptions
17+
18+
19+
### userInputs
20+
21+
22+
### createFilename
23+
24+
25+
### saveEventsFile
26+
27+
28+
### checkCFG

tests/runtests.m

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
function results = runtests(pth)
2+
% Run tests
3+
% List all the 'test_*.m' files located in the same directory as this
4+
% function, run them and keep track of how many passed, failed or are
5+
% incomplete.
6+
%__________________________________________________________________________
7+
8+
% Copyright (C) 2019, Guillaume Flandin, Wellcome Centre for Human Neuroimaging
9+
% Copyright (C) 2020--, CPP_BIDS developers
10+
11+
%-Get the path of where this file is located
12+
if ~nargin, pth = fileparts(mfilename('fullpath')); end
13+
14+
%-List all the 'test_*.m' files located in the same directory as this
15+
% function
16+
d = dir(pth);
17+
d([d.isdir]) = [];
18+
d(arrayfun(@(x) isempty(regexp(x.name,'^test_.*\.m$','once')),d)) = [];
19+
20+
results = struct('Passed',{},'Failed',{},'Incomplete',{},'Duration',{});
21+
for i=1:numel(d)
22+
23+
results(i).Failed = false;
24+
results(i).Passed = false;
25+
results(i).Incomplete = false;
26+
27+
tstart = tic;
28+
29+
%-Run each test file and catch error message in case of failure
30+
try
31+
32+
fprintf('%s',d(i).name(1:end-2));
33+
feval(d(i).name(1:end-2));
34+
results(i).Passed = true;
35+
36+
catch err
37+
results(i).Failed = true;
38+
fprintf('\n%s',err.message);
39+
end
40+
41+
results(i).Duration = toc(tstart);
42+
43+
fprintf('\n');
44+
45+
end
46+
47+
if ~nargout
48+
fprintf(['Totals (%d tests):\n\t%d Passed, %d Failed, %d Incomplete.\n' ...
49+
'\t%f seconds testing time.\n\n'],numel(results),nnz([results.Passed]),...
50+
nnz([results.Failed]),nnz([results.Incomplete]),sum([results.Duration]));
51+
end
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
% test for filename creation and their directories
2-
3-
% add parent folder to the parth
4-
addpath(genpath(fullfile(fileparts(mfilename), '..')))
1+
function test_createFilename()
52

3+
% test for filename creation and their directories
64

75
%% check directory and filename creation (PC and eyetracker)
86

9-
clear
10-
117
expParameters.subjectGrp = '';
128
expParameters.subjectNb = 1;
139
expParameters.sessionNb = 1;
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1+
function test_saveEventsFile()
12
% test for events.tsv file creation
23

3-
% add parent folder to the parth
4-
addpath(genpath(fullfile(fileparts(mfilename), '..')))
5-
6-
74
%% set up
85

9-
clear
10-
116
expParameters.subjectGrp = '';
127
expParameters.subjectNb = 1;
138
expParameters.sessionNb = 1;

0 commit comments

Comments
 (0)