Skip to content
Merged
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
32 changes: 32 additions & 0 deletions .github/workflows/moxunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches: '*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 1
- name: MOxUnit Action
uses: joergbrech/moxunit-action@v1.1
with:
tests: tests
src: src
with_coverage: true
cover_xml_file: coverage.xml
- name: Code coverage
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
file: coverage.xml # optional
flags: unittests # optional
name: codecov-umbrella # optional
fail_ci_if_error: true # optional (default = false)
17 changes: 14 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@

# exclude mac file
*DS_Store

# exclude matlab autosaves and octave workspace info
*.m~
*octave-workspace

# exclude content of logfiles folders
tests/output/*
manualTests/output/*
output/*
*.tsv
*.mat

check_my_code_report.txt
# exclude temp files from tests and coverage
tests/coverage*
tests/test_code_report.txt
test_code_report.txt

output/**
# exclude report from check_my_code
check_my_code_report.txt




12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@ install:
- sudo npm install -g bids-validator

before_script:
# Add to src functions to path
- octave $OCTFLAGS --eval "addpath(genpath(fullfile(pwd, 'src'))); savepath ();"
# Change current directory
- cd tests
- cd manualTests

jobs:
include:
- stage: "Tests"
name: "Unit and integration Tests"
script: octave $OCTFLAGS --eval "results = runTests; assert(all(~[results.Failed]))"
# - stage: "Tests"
# name: "Unit and integration Tests"
# script: octave $OCTFLAGS --eval "results = runTests; assert(all(~[results.Failed]))"
- stage: "BIDS validator"
name: "Create and check dataset"
script: cd manualTests && octave $OCTFLAGS --eval "test_makeRawDataset" && bids-validator `pwd`/output/rawdata/ --ignoreNiftiHeaders
script: octave $OCTFLAGS --eval "test_makeRawDataset" && bids-validator `pwd`/output/rawdata/ --ignoreNiftiHeaders
- stage: "Linter"
name: "miss_hit"
script: cd .. && mh_style `pwd`
Expand Down
27 changes: 0 additions & 27 deletions checkCppBidsDependencies.m

This file was deleted.

File renamed without changes.
55 changes: 55 additions & 0 deletions manualTests/test_createDataDictionary.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
function test_suite = test_createDataDictionary %#ok<*STOUT>
try % assignment of 'localfunctions' is necessary in Matlab >= 2016
test_functions = localfunctions(); %#ok<*NASGU>
catch % no problem; early Matlab versions can use initTestSuite fine
end
initTestSuite;
end

function test_createDataDictionaryBasic()

outputDir = fullfile(fileparts(mfilename('fullpath')), '..', 'output');

%% set up

cfg.verbose = false;

cfg.subject.subjectNb = 1;
cfg.subject.runNb = 1;

cfg.task.name = 'testtask';

cfg.dir.output = outputDir;

cfg.testingDevice = 'mri';

cfg = createFilename(cfg);

logFile.extraColumns.Speed.length = 1;
logFile.extraColumns.LHL24.length = 3;
logFile = saveEventsFile('init', cfg, logFile);

createDataDictionary(cfg, logFile);

%% check that the file has the right path and name

% data to test against
funcDir = fullfile(outputDir, 'source', 'sub-001', 'ses-001', 'func');

jsonFilename = ['sub-001_ses-001_task-testtask_run-001_events_date-' ...
cfg.fileName.date '.json'];

% test
assertTrue(exist(fullfile(funcDir, jsonFilename), 'file') == 2);

%% check content
actualStruct = bids.util.jsondecode(fullfile(funcDir, jsonFilename));

% data to test against
expectedStruct = bids.util.jsondecode( ...
fullfile(pwd, 'testData', 'eventsDataDictionary.json'));

% test
assertTrue(isequal(expectedStruct, actualStruct));

end
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
function test_makeRawDataset()

fprintf('\n\n--------------------------------------------------------------------\n\n');

clear;

outputDir = fullfile(fileparts(mfilename('fullpath')), 'output');

if isdir(outputDir)
Expand All @@ -16,7 +12,9 @@ function test_makeRawDataset()

cfg.subject.subjectNb = 1;
cfg.subject.runNb = 1;

cfg.task.name = 'testtask';

cfg.dir.output = outputDir;

cfg.bids.datasetDescription.Name = 'dummy';
Expand Down Expand Up @@ -77,7 +75,7 @@ function test_makeRawDataset()
funcDir = fullfile(cfg.dir.output, 'source', 'sub-001', 'ses-001', 'func');
boldFilename = 'sub-001_ses-001_task-testtask_run-001_bold.nii.gz';
copyfile( ...
fullfile('..', '..', 'dummyData', 'dummyData.nii.gz'), ...
fullfile('..', 'dummyData', 'dummyData.nii.gz'), ...
fullfile(funcDir, boldFilename));

%%
Expand Down
File renamed without changes.
44 changes: 0 additions & 44 deletions printCreditsCppBids.m

This file was deleted.

7 changes: 4 additions & 3 deletions checkCFG.m → src/checkCFG.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
% check that we have all the fields that we need in the experiment parameters
% reuses a lot of code from the BIDS starter kit

checkCppBidsDependencies();

if nargin < 1 || isempty(cfg)
cfg = struct();
end

%% set the cfg defaults
checkCppBidsDependencies(cfg);

%% list the defaults to set

fieldsToSet.verbose = false;

Expand Down Expand Up @@ -43,6 +43,7 @@

fieldsToSet = transferInfoToBids(fieldsToSet, cfg);

%% Set defaults
cfg = setDefaultFields(cfg, fieldsToSet);

end
Expand Down
39 changes: 39 additions & 0 deletions src/checkCppBidsDependencies.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
function checkCppBidsDependencies(cfg)
% checkCppBidsDependencies()
%

GITHUB_WORKSPACE = getenv('GITHUB_WORKSPACE');

if strcmp(GITHUB_WORKSPACE, '/github/workspace')

pth = GITHUB_WORKSPACE;
addpath(fullfile(pth, 'lib', 'JSONio'));
addpath(fullfile(pth, 'lib', 'bids-matlab'));

elseif isempty(GITHUB_WORKSPACE) % local

pth = fullfile(fileparts(mfilename('fullpath')), '..');
checkSubmodule(fullfile(pth, 'lib', 'JSONio'));
checkSubmodule(fullfile(pth, 'lib', 'bids-matlab'));

addpath(fullfile(pth, 'src', 'subfun'));

end

addpath(fullfile(pth, 'lib', 'utils'));

printCreditsCppBids(cfg);

end

function checkSubmodule(pth)
% If external dir is empty throw an exception
% and ask user to update submodules.
if numel(dir(pth)) <= 2 % Means that the external is empty
error(['Git submodules are not cloned!', ...
'Try this in your terminal:', ...
' git submodule update --recursive ']);
else
addpath(pth);
end
end
6 changes: 3 additions & 3 deletions convertSourceToRaw.m → src/convertSourceToRaw.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ function convertSourceToRaw(cfg)
% - creates dummy README and CHANGE file
% - copy source dir to raw dir
% - remove the date suffix (_date-YYYYMMDDHHMM) from the files where it is present
%
%

sourceDir = fullfile(cfg.dir.output, 'source');
rawDir = fullfile(cfg.dir.output, 'rawdata');

% add dummy readme and change file
copyfile(fullfile( ...
fileparts(mfilename('fullpath')), 'dummyData', 'README'), ...
fileparts(mfilename('fullpath')), '..', 'dummyData', 'README'), ...
sourceDir);
copyfile(fullfile( ...
fileparts(mfilename('fullpath')), 'dummyData', 'CHANGES'), ...
fileparts(mfilename('fullpath')), '..', 'dummyData', 'CHANGES'), ...
sourceDir);

copyfile(sourceDir, rawDir);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 13 additions & 9 deletions createFilename.m → src/createFilename.m
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,23 @@

function talkToMe(cfg)

fprintf(1, '\nData will be saved in this directory:\n\t%s\n', ...
fullfile(cfg.dir.outputSubject, cfg.fileName.modality));
if cfg.verbose

fprintf(1, '\nData will be saved in this file:\n\t%s\n', ...
cfg.fileName.events);
fprintf(1, '\nData will be saved in this directory:\n\t%s\n', ...
fullfile(cfg.dir.outputSubject, cfg.fileName.modality));

if cfg.eyeTracker.do
fprintf(1, '\nData will be saved in this file:\n\t%s\n', ...
cfg.fileName.events);

if cfg.eyeTracker.do

fprintf(1, '\nEyetracking data will be saved in this directory:\n\t%s\n', ...
fullfile(cfg.dir.outputSubject, 'eyetracker'));
fprintf(1, '\nEyetracking data will be saved in this directory:\n\t%s\n', ...
fullfile(cfg.dir.outputSubject, 'eyetracker'));

fprintf(1, '\nEyetracking data will be saved in this file:\n\t%s\n', ...
cfg.fileName.eyetracker);
fprintf(1, '\nEyetracking data will be saved in this file:\n\t%s\n', ...
cfg.fileName.eyetracker);

end

end

Expand Down
3 changes: 3 additions & 0 deletions src/miss_hit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
line_length: 100
regex_function_name: "[a-z]+(([A-Z]){1}[A-Za-z]+)*"
suppress_rule: "copyright_notice"
Loading