Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Bump bids matlab #495

Merged
merged 5 commits into from
Jan 28, 2022
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
6 changes: 4 additions & 2 deletions demos/MoAE/moae_03_create_roi_extract_data.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@
% rename mask image:
% add a description and remove a whole bunch of entities
% from the original name
newname.entities.desc = 'right auditory cortex';
newname.entities.hemi = 'R';
newname.entities.desc = 'auditory cortex';
newname.entities.task = '';
newname.entities.label = '';
newname.entities.p = '';
newname.entities.k = '';
newname.entities.MC = '';
newname.entity_order = {'sub', 'hemi', 'space', 'desc'};
rightRoiFile = renameFile(roiFile, newname);

%% same but with left hemisphere
Expand All @@ -61,7 +63,7 @@
'mask2', sphere);

[~, roiFile] = createRoi('expand', specification, conImage, output_dir, saveROI);
newname.entities.desc = 'left auditory cortex';
newname.entities.hemi = 'L';
leftRoiFile = renameFile(roiFile, newname);

%%
Expand Down
2 changes: 1 addition & 1 deletion lib/bids-matlab
Submodule bids-matlab updated 91 files
+3 −0 +bids/+internal/download_moae_ds.m
+0 −0 +bids/+internal/is_octave.m
+1 −1 +bids/+internal/keep_file_for_query.m
+1 −1 +bids/+internal/root_dir.m
+30 −0 +bids/+util/tsvread.m
+5 −5 +bids/+util/tsvwrite.m
+309 −253 +bids/File.m
+24 −0 +bids/bids_matlab_version.m
+50 −66 +bids/copy_to_derivative.m
+13 −6 +bids/derivatives_json.m
+32 −19 +bids/functionSignatures.json
+17 −12 +bids/init.m
+67 −60 +bids/layout.m
+78 −14 +bids/query.m
+1 −1 +bids/report.m
+9 −0 .all-contributorsrc
+1 −1 .github/workflows/miss_hit_code_quality.yml
+2 −1 .github/workflows/miss_hit_code_style.yml
+1 −2 .github/workflows/run_tests_matlab.yml
+5 −5 .github/workflows/run_tests_octave.yml
+1 −1 .github/workflows/update_schema.yml
+2 −0 .gitignore
+58 −0 CITATION.cff
+30 −12 CONTRIBUTING.md
+12 −0 Makefile
+19 −14 README.md
+1 −1 binder/postBuild
+0 −3 docs/Makefile
+5 −0 docs/create_manual.sh
+2 −2 docs/source/conf.py
+180 −45 examples/01_BIDS-Matlab_basics.ipynb
+68 −135 examples/02_BIDS-Matlab_derivatives.ipynb
+142 −155 examples/03_BIDS-Matlab_filenames_and_metadata.ipynb
+294 −20 examples/04_BIDS-Matlab_new_datasets.ipynb
+123 −8 examples/05_BIDS-Matlab_report.ipynb
+1,785 −48 examples/06_BIDS-Matlab_tsv_json.ipynb
+1 −1 examples/Makefile
+2 −1 miss_hit.cfg
+16 −6 run_tests.m
+4 −0 schema/objects/datatypes.json
+14 −0 schema/objects/entities.json
+191 −2 schema/objects/metadata.json
+4 −0 schema/objects/modalities.json
+69 −1 schema/objects/suffixes.json
+4 −0 schema/objects/top_level_files.json
+55 −0 schema/rules/datatypes/micr.json
+2 −0 schema/rules/entities.json
+5 −0 schema/rules/modalities.json
+1 −0 tests/.gitignore
+7 −2 tests/Makefile
+142 −0 tests/create_dummy_data_set.sh
+1 −1 tests/data/SurfaceData/sub-06_hemi-R_space-individual_den-native_midthickness.json
+1 −1 tests/data/SurfaceData/sub-06_hemi-R_space-individual_den-native_thickness.json
+1 −1 tests/data/SurfaceData/sub-06_space-individual_den-native_thickness.json
+0 −188 tests/layout_timing.m
+236 −298 tests/test_bids_file.m
+15 −10 tests/test_bids_init.m
+64 −50 tests/test_copy_to_derivative.m
+1 −2 tests/test_derivatives_json.m
+0 −18 tests/test_function_signatures.m
+8 −8 tests/test_report.m
+192 −0 tests/tests_layout/layout_timing.m
+4 −9 tests/tests_layout/test_bids_examples.m
+0 −0 tests/tests_layout/test_layout.m
+13 −43 tests/tests_layout/test_layout_derivatives.m
+31 −0 tests/tests_layout/test_layout_index_json.m
+3 −3 tests/tests_private/test_append_to_layout.m
+0 −0 tests/tests_private/test_error_handling.m
+13 −8 tests/tests_private/test_file_utils.m
+1 −12 tests/tests_private/test_get_metadata.m
+1 −1 tests/tests_private/test_get_metadata_suffixes.m
+0 −0 tests/tests_private/test_keep_file.m
+1 −1 tests/tests_private/test_parse_filename.m
+0 −0 tests/tests_private/test_replace_placeholders.m
+0 −0 tests/tests_private/test_return_file_index.m
+0 −0 tests/tests_private/test_return_subject_index.m
+27 −15 tests/tests_query/test_bids_query.m
+0 −0 tests/tests_query/test_bids_query_asl.m
+37 −0 tests/tests_query/test_bids_query_derivatives.m
+0 −0 tests/tests_query/test_bids_query_dwi.m
+0 −0 tests/tests_query/test_bids_query_eeg.m
+0 −0 tests/tests_query/test_bids_query_fmap.m
+0 −0 tests/tests_query/test_bids_query_func.m
+0 −0 tests/tests_query/test_bids_query_ieeg.m
+52 −0 tests/tests_query/test_bids_query_matlab_octave.m
+0 −0 tests/tests_query/test_bids_query_meg.m
+34 −0 tests/tests_query/test_bids_query_microscopy.m
+3 −3 tests/tests_utils/test_tsvread.m
+5 −3 tests/tests_utils/test_tsvwrite.m
+4 −0 tests/utils/set_test_cfg.m
+1 −0 version.txt
2 changes: 1 addition & 1 deletion src/IO/getData.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

validationInputFile(bidsDir, 'dataset_description.json');

BIDS = bids.layout(bidsDir, opt.useBidsSchema);
BIDS = bids.layout(bidsDir, 'use_schema', opt.useBidsSchema);

if strcmp(opt.pipeline.type, 'stats')
BIDS.raw = bids.layout(opt.dir.raw);
Expand Down
6 changes: 6 additions & 0 deletions src/batches/stats/setBatchResults.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
result.outputNameStructure.entities.k = num2str(result.Contrasts.k);
result.outputNameStructure.entities.MC = result.Contrasts.MC;

fields = fieldnames(result.outputNameStructure.entities);
for i = 1:numel(fields)
value = result.outputNameStructure.entities.(fields{i});
result.outputNameStructure.entities.(fields{i}) = bids.internal.camel_case(value);
end

fieldsToSet = returnDefaultResultsStructure();
result = setFields(result, fieldsToSet);
result.Contrasts = replaceEmptyFields(result.Contrasts, fieldsToSet.Contrasts);
Expand Down
3 changes: 1 addition & 2 deletions src/bids/getROIs.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
elseif strcmp(space, 'individual')

% we expect ROI files to have BIDS valid names
use_schema = false;
BIDS_ROI = bids.layout(opt.dir.roi, use_schema);
BIDS_ROI = bids.layout(opt.dir.roi, 'use_schema', false);

if strcmp(subLabel, '')
msg = sprintf('Provide a subject label amongst those:\n%s\n\n', ...
Expand Down
11 changes: 3 additions & 8 deletions src/bids/initBids.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,10 @@ function initBids(varargin)

if ~exist(descr_file, 'file') || p.Results.force

isDerivative = true;
bids.init(opt.dir.output, 'folders', struct(), 'is_derivative', true);

bids.init(opt.dir.output, struct(), isDerivative);

use_schema = false;
index_derivatives = false;
tolerant = true;
verbose = opt.verbosity > 0;
BIDS = bids.layout(opt.dir.output, use_schema, index_derivatives, tolerant, verbose);
BIDS = bids.layout(opt.dir.output, 'use_schema', false, ...
'index_derivatives', false, 'tolerant', true, 'verbose', opt.verbosity > 0);

pipeline = opt.pipeline.name;
if ~strcmp(opt.pipeline.type, '')
Expand Down
15 changes: 7 additions & 8 deletions src/subject_level/padCounfoundMatFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

isSpmSessStruct = @(x) isstruct(x) && isfield(x, 'counfoundMatFile');

p = inputParser;
addRequired(p, 'spmSess', isSpmSessStruct);
addRequired(p, 'opt', @isstruct);
parse(p, varargin{:});
args = inputParser;
addRequired(args, 'spmSess', isSpmSessStruct);
addRequired(args, 'opt', @isstruct);
parse(args, varargin{:});

spmSess = p.Results.spmSess;
opt = p.Results.opt;
spmSess = args.Results.spmSess;
opt = args.Results.opt;

spmSessOut = spmSess;

Expand Down Expand Up @@ -58,8 +58,7 @@
bf = bids.File(fileToLoad);
bf.entities.desc = 'confoundsPadded';
bf.suffix = 'regressors';
bf = bf.create_filename;
outputFilename = fullfile(bf.pth, bf.filename);
outputFilename = fullfile(fileparts(fileToLoad), bf.filename);

save(outputFilename, 'names', 'R');
spmSessOut(idxFilesToPad(i)).counfoundMatFile = outputFilename;
Expand Down
6 changes: 3 additions & 3 deletions src/workflows/bidsCopyInputFolder.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ function bidsCopyInputFolder(opt, unzip)
end

bids.copy_to_derivative(BIDS, ...
[opt.pipeline.name '-' opt.pipeline.type], ...
fullfile(opt.dir.output, '..'), ...
filter, ...
'pipeline_name', [opt.pipeline.name '-' opt.pipeline.type], ...
'out_path', fullfile(opt.dir.output, '..'), ...
'filter', filter, ...
'unzip', unzip, ...
'force', overwrite, ...
'skip_dep', skip_dependencies, ...
Expand Down
4 changes: 2 additions & 2 deletions tests/tests_unit/bids/test_getInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function test_getInfo_query_with_session_restriction()
end

function fileName = returnFullpathExpectedFilename(p)
bidsFile = bids.File(p, true);
bidsFile = bids.File(p, 'use_schema', true);
fileName = fullfile(getDummyDataDir(), 'derivatives', 'cpp_spm-preproc', ...
bidsFile.relative_pth, bidsFile.filename);
bidsFile.bids_path, bidsFile.filename);
end
8 changes: 6 additions & 2 deletions tests/tests_workflows/stats/test_bidsFFX.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,19 @@ function test_bidsFFX_fmriprep_no_smoothing()
opt.query.space = opt.space; % for bidsCopy only
opt.fwhm.func = 0;

opt.dir.stats = fullfile(opt.dir.derivatives, 'cpp_spm-stats');
opt.dir.output = opt.dir.stats;
opt.dir.preproc = fullfile(opt.dir.derivatives, 'cpp_spm-preproc');

opt = checkOptions(opt);

bidsCopyInputFolder(opt, false());

% No proper valid bids file in derivatives of bids-example

opt.dir.stats = fullfile(opt.dir.derivatives, 'cpp_spm-stats');
opt.dir.output = opt.dir.stats;

opt = checkOptions(opt);

% bidsFFX('specifyAndEstimate', opt);
% bidsFFX('contrasts', opt);
% bidsResults(opt);
Expand Down
4 changes: 4 additions & 0 deletions tests/tests_workflows/stats/test_bidsResults.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

function test_bidsResults_basic()

createDummyData();

%% GIVEN
opt = setOptions('vislocalizer', '', 'pipelineType', 'stats');

Expand Down Expand Up @@ -76,6 +78,8 @@ function test_bidsResults_basic()

function test_bidsResults_no_background_for_montage()

createDummyData();

%% GIVEN
opt = setOptions('vislocalizer', '', 'pipelineType', 'stats');

Expand Down
2 changes: 1 addition & 1 deletion tests/tests_workflows/test_bidsCopyInputFolder.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function test_bidsCopyInputFolder_fmriprep()

bidsCopyInputFolder(opt, false());

layoutDerivatives = bids.layout(fullfile(opt.dir.preproc), false());
layoutDerivatives = bids.layout(fullfile(opt.dir.preproc), 'use_schema', false);
data = bids.query(layoutDerivatives, 'data', 'extension', '.nii.gz');
assertEqual(size(data, 1), 16);

Expand Down
6 changes: 2 additions & 4 deletions tests/tests_workflows/test_bidsCreateROI.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ function test_bidsCreateROI_neuromorphometrics()

bidsCreateROI(opt);

use_schema = false;
BIDS = bids.layout(opt.dir.roi, use_schema);
BIDS = bids.layout(opt.dir.roi, 'use_schema', false);
roiImages = bids.query(BIDS, 'data', 'sub', '^01', 'suffix', 'mask');

assertEqual(size(roiImages, 1), 2);
Expand Down Expand Up @@ -58,8 +57,7 @@ function test_bidsCreateROI_wang()

bidsCreateROI(opt);

use_schema = false;
BIDS = bids.layout(opt.dir.roi, use_schema);
BIDS = bids.layout(opt.dir.roi, 'use_schema', false);
roiImages = bids.query(BIDS, 'data', 'sub', '^01', 'suffix', 'mask');

assertEqual(size(roiImages, 1), 4);
Expand Down