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
2 changes: 1 addition & 1 deletion .github/workflows/bids_validator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- name: Install BIDS validator
run: |
sudo npm install -g bids-validator@1.6.2
sudo npm install -g bids-validator@1.9.0

- name: Create dummy dataset and validate it
run: |
Expand Down
47 changes: 42 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# exclude mac file
*DS_Store

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

# exclude content of logfiles folders
*output*
*.mat

# exclude temp files from tests and coverage
*test_code_report.txt
test_report.log
*coverage*

*filteredBy*
Expand All @@ -23,20 +20,60 @@ tests/*.tsv*
check_my_code_report.txt

# jupyter notebook checkpoints
notebooks/.ipynb_checkpoints/*
notebooks/source/*
notebooks/output/*
notebooks/new_experiment/*

# ignore node js files
node_modules/*
package-lock.json
package.json

# visual studio code stuff
.vscode

# virtual env
cpp_bids/*
env/

# documentation
docs/build/*

# jupyter notebooks
.ipynb_checkpoints

## MATLAB / OCTAVE gitignore template

# From : https://github.com/github/gitignore/blob/master/Global/MATLAB.gitignore

# Windows default autosave extension
*.asv

# OSX / *nix default autosave extension
*.m~

# Compiled MEX binaries (all platforms)
*.mex*

# Packaged app and toolbox files
*.mlappinstall
*.mltbx

# Generated helpsearch folders
helpsearch*/

# Simulink code generation folders
slprj/
sccprj/

# Matlab code generation folders
codegen/

# Simulink autosave extension
*.autosave

# Simulink cache files
*.slxc

# Octave session info
octave-workspace
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cff-version: 1.2.0

title: "CPP BIDS"

version: 2.1.1dev
version: 2.1.2dev

abstract: A lightweight Octave/MATLAB toolbox to help create BIDS data sets from source.

Expand Down
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# TODO make more general to use the local matlab version
MATLAB = /usr/local/MATLAB/R2017a/bin/matlab
ARG = -nodisplay -nosplash -nodesktop

.PHONY: clean manual clean_demos fix_submodule
clean: clean_demos
rm -rf version.txt

fix_submodule:
git submodule update --init --recursive && git submodule update --recursive

lint:
mh_style --fix && mh_metric --ci && mh_lint

test:
$(MATLAB) $(ARG) -r "runTests; exit()"

version.txt: CITATION.cff
grep -w "^version" CITATION.cff | sed "s/version: /v/g" > version.txt

validate_cff: CITATION.cff
cffconvert --validate

manual:
cd docs && sh create_manual.sh
4 changes: 3 additions & 1 deletion checkCppBidsDependencies.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ function checkCppBidsDependencies(cfg)
CPP_BIDS_INITIALIZED = true();

else
fprintf(1, '\n\nCPP_BIDS already initialized\n\n');
if cfg.verbose
fprintf(1, '\n\nCPP_BIDS already initialized\n\n');
end

end

Expand Down
Binary file added docs/cpp_spm-manual.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions docs/create_manual.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

sphinx-build -M latexpdf source build

cp build/latex/cppbids.pdf cpp_spm-manual.pdf
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'the CPP BIDS dev team'

# The full version, including alpha/beta/rc tags
release = 'v1.0.0'
release = 'v2.1.2dev'


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 0 additions & 2 deletions docs/source/utilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ List of functions in the ``utils`` folder.
.. autofunction:: isPositiveInteger
.. autofunction:: nanPadding
.. autofunction:: printCreditsCppBids
.. autofunction:: removeAllDateSuffix
.. autofunction:: removeDateSuffix
.. autofunction:: returnHeaderName
.. autofunction:: returnNamesExtraColumns
.. autofunction:: returnNbColumns
Expand Down
2 changes: 1 addition & 1 deletion lib/bids-matlab
Submodule bids-matlab updated 46 files
+8 −0 +bids/+internal/error_handling.m
+34 −0 +bids/+internal/list_all_trial_types.m
+189 −0 +bids/+util/plot_events.m
+67 −4 +bids/File.m
+579 −0 +bids/Model.m
+8 −5 +bids/copy_to_derivative.m
+237 −0 +bids/diagnostic.m
+2 −2 +bids/functionSignatures.json
+1 −1 .github/workflows/update_schema.yml
+45 −7 .gitignore
+1 −1 .pre-commit-config.yaml
+6 −0 CITATION.cff
+1 −0 README.md
+15 −0 docs/source/function_description.rst
+ docs/source/images/MultisubjectMultimodalFaceProcessing.png
+ docs/source/images/MultisubjectMultimodalFaceProcessing_splitby-task.png
+101 −0 examples/07_BIDS-Matlab_diagnostic.ipynb
+2 −2 miss_hit.cfg
+20 −14 schema/objects/columns.json
+11 −11 schema/objects/entities.json
+87 −80 schema/objects/metadata.json
+1 −0 schema/rules/datatypes/anat.json
+19 −0 schema/rules/datatypes/dwi.json
+18 −0 schema/rules/datatypes/eeg.json
+18 −0 schema/rules/datatypes/ieeg.json
+19 −0 schema/rules/datatypes/meg.json
+19 −0 schema/rules/datatypes/perf.json
+19 −0 schema/rules/datatypes/pet.json
+1 −1 schema/rules/entities.json
+1 −2 tests/.gitignore
+0 −12 tests/data/SurfaceData/sub-06_hemi-R_space-individual_den-native_midthickness.json
+0 −0 tests/data/SurfaceData/sub-06_hemi-R_space-individual_den-native_midthickness.surf.gii
+0 −9 tests/data/SurfaceData/sub-06_hemi-R_space-individual_den-native_thickness.json
+0 −0 tests/data/SurfaceData/sub-06_hemi-R_space-individual_den-native_thickness.shape.gii
+0 −0 tests/data/SurfaceData/sub-06_space-individual_den-native_thickness.dscalar.nii
+0 −17 tests/data/SurfaceData/sub-06_space-individual_den-native_thickness.json
+65 −0 tests/data/model/model-empty_smdl.json
+193 −0 tests/data/model/model-narps_smdl.json
+181 −0 tests/data/model/model-rhymejudgement_smdl.json
+201 −0 tests/models/model-defaultVislocalizer_smdl.json
+107 −0 tests/test_bids_file.m
+141 −0 tests/test_bids_model.m
+9 −0 tests/test_copy_to_derivative.m
+29 −0 tests/test_diagnostic.m
+45 −0 tests/tests_utils/test_plot_events.m
+2 −0 tests/utils/get_test_data_dir.m
42 changes: 42 additions & 0 deletions runTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
function runTests()
%
% (C) Copyright 2022 CPP_BIDS developers

% Elapsed time is ??? seconds.

tic;

cd(fileparts(mfilename('fullpath')));

cfg.verbose = 0;
checkCppBidsDependencies(cfg);

if bids.internal.is_github_ci
fprintf(1, '\nThis is github CI\n');
else
fprintf(1, '\nThis is not github CI\n');
end

fprintf('\nHome is %s\n', getenv('HOME'));

warning('OFF');

folderToCover = fullfile(pwd, 'src');
testFolder = fullfile(pwd, 'tests');

success = moxunit_runtests( ...
testFolder, ...
'-verbose', '-recursive', '-with_coverage', ...
'-cover', folderToCover, ...
'-cover_xml_file', 'coverage.xml', ...
'-cover_html_dir', fullfile(pwd, 'coverage_html'));

if success
system('echo 0 > test_report.log');
else
system('echo 1 > test_report.log');
end

toc;

end
35 changes: 20 additions & 15 deletions src/convertSourceToRaw.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,31 @@ function convertSourceToRaw(cfg)

copyfile(sourceDir, rawDir);

% list subjects
subjects = cellstr(bids.internal.file_utils('List', rawDir, 'dir', '^sub-.*$'));
BIDS = bids.layout(rawDir, 'use_schema', false);

if isequal(subjects, {''})
error('No subjects found in BIDS directory.');
end
data = bids.query(BIDS, 'data');
metadata = bids.query(BIDS, 'metadata');

% go through the subject files and parses them to remove the date suffix
for su = 1:numel(subjects)
for i = 1:size(data, 1)
bf = bids.File(data{i});
if isfield(bf.entities, 'date')
% TODO probably JSON renaming should be passed to bids-matlab
sourceJson = fullfile(fileparts(bf.path), bf.json_filename);
bf.entities.date = '';
bf.rename('dry_run', false, 'force', true);
bids.util.jsonencode(fullfile(fileparts(bf.path), bf.json_filename), metadata{i});
delete(sourceJson);
end
end

sess = cellstr(bids.internal.file_utils('List', ...
fullfile(rawDir, ...
subjects{su}), ...
'dir', ...
'^ses-.*$'));
BIDS = bids.layout(rawDir, 'use_schema', false);
data = bids.query(BIDS, 'data', 'suffix', {'stim', 'physio' }, 'ext', '.tsv');

for se = 1:numel(sess)
removeAllDateSuffix(rawDir, subjects{su}, sess{se});
for i = 1:size(data, 1)
gzip(data{i});
if exist(data{i}, 'file')
delete(data{i});
end

end

end
2 changes: 2 additions & 0 deletions src/saveEventsFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
% ``'init'``, ``'init_stim'``, ``'open'``, ``'save'`` or ``'close'``.
% For more information on each case see below.
% :type action: string
%
% :param cfg: Configuration variable. See ``checkCFG()``.
% :type cfg: structure
%
% :param logFile: (n x 1) The ``logFile`` variable that contains the n events
% you want to save must be a nx1 structure.
% :type logFile: structure
Expand Down
26 changes: 20 additions & 6 deletions src/utils/isPositiveInteger.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,25 @@
%
% (C) Copyright 2020 CPP_BIDS developers

trueOrFalse = ~any([ ...
~isnumeric(input2check), ...
isnan(input2check), ...
fix(input2check) ~= input2check, ...
input2check < 0 ...
]);
if ~isnumeric(input2check)
trueOrFalse = false;
return
end

if numel(size(input2check)) > 2 || all(size(input2check) > 1)
bids.internal.error_handling(mfilename(), ...
'sizeIssue', ...
'Input must be scalar or vector.', ...
false);
end

if size(input2check, 1) > 1
input2check = input2check';
end

trueOrFalse = any(~any([isnan(input2check); ...
fix(input2check) ~= input2check; ...
input2check < 0 ...
]));

end
81 changes: 0 additions & 81 deletions src/utils/removeAllDateSuffix.m

This file was deleted.

Loading