From 0ca7fd882e5542cb3be737af92bc0251540c2f9a Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Tue, 18 Aug 2020 19:41:29 +0200 Subject: [PATCH 01/36] add some initialization for eyetracking --- src/checkCFG.m | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/checkCFG.m b/src/checkCFG.m index 8f6f64ab..b300edd5 100644 --- a/src/checkCFG.m +++ b/src/checkCFG.m @@ -29,11 +29,9 @@ fieldsToSet.testingDevice = 'pc'; - fieldsToSet.eyeTracker = struct(); + fieldsToSet = eyetrackerDefaults(fieldsToSet); - fieldsToSet.eyeTracker.do = false; - - fieldsToSet = mriDefaults(fieldsToSet); + fieldsToSet = setSuffixes(fieldsToSet); %% BIDS @@ -51,7 +49,7 @@ end -function fieldsToSet = mriDefaults(fieldsToSet) +function fieldsToSet = setSuffixes(fieldsToSet) % for file naming and JSON fieldsToSet.suffix.contrastEnhancement = []; @@ -244,3 +242,21 @@ fieldsToSet.bids.ieeg = orderfields(fieldsToSet.bids.beh); end + +function fieldsToSet = eyetrackerDefaults(fieldsToSet) + + fieldsToSet.eyeTracker.do = false; + fieldsToSet.eyeTracker.SamplingFrequency = []; + fieldsToSet.eyeTracker.PupilPositionType = ''; + fieldsToSet.eyeTracker.RawSamples = []; + fieldsToSet.eyeTracker.Manufacturer = ''; + fieldsToSet.eyeTracker.ManufacturersModelName = ''; + fieldsToSet.eyeTracker.SoftwareVersions = ''; + fieldsToSet.eyeTracker.CalibrationType = ''; + fieldsToSet.eyeTracker.CalibrationPosition = ''; + fieldsToSet.eyeTracker.CalibrationDistance = ''; + fieldsToSet.eyeTracker.MaximalCalibrationError = []; + fieldsToSet.eyeTracker.AverageCalibrationError = []; + fieldsToSet.eyeTracker.RawDataFilters = {}; + +end \ No newline at end of file From 8e7aace7cdbc003cbfccbb350233b39208f31741 Mon Sep 17 00:00:00 2001 From: Ceren Date: Wed, 16 Sep 2020 12:13:31 +0200 Subject: [PATCH 02/36] juptyer notebook installation suggestion --- notebooks/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/notebooks/README.md b/notebooks/README.md index 9ec8cd6d..22358af7 100644 --- a/notebooks/README.md +++ b/notebooks/README.md @@ -1,9 +1,11 @@ # README -1. Make sure that you have Octave installed. +1. Make sure that you have Octave installed. 2. If you have Conda/Jupyter/pip installed, go to step 4. +Check is Conda installed properly by `conda list` typing into your terminal 3. Download the [Anaconda Installer](https://www.anaconda.com/products/individual) and install it. -4. Install [Octave kernel](https://pypi.org/project/octave-kernel/): +If using miniconda, run `conda install jupyter` to download and install the Jupyter Notebook package. +4. Install [Octave kernel](https://pypi.org/project/octave-kernel/): ``` pip install octave_kernel ``` From 88f62e726ab8a8e3f43515e60c4f2fecde668682 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 17 Sep 2020 21:12:51 +0200 Subject: [PATCH 03/36] add copyright --- lib/bids-matlab | 2 +- miss_hit.cfg | 2 +- src/checkCFG.m | 2 ++ src/convertSourceToRaw.m | 2 ++ src/createDataDictionary.m | 2 ++ src/createDatasetDescription.m | 2 ++ src/createFilename.m | 2 ++ src/createJson.m | 2 ++ src/miss_hit.cfg | 2 +- src/saveEventsFile.m | 2 ++ src/subfun/askForGroupAndOrSession.m | 2 ++ src/subfun/askUserCli.m | 2 ++ src/subfun/askUserGui.m | 2 ++ src/subfun/checkCppBidsDependencies.m | 2 ++ src/subfun/createQuestionList.m | 2 ++ src/subfun/createValidName.m | 2 ++ src/subfun/getIsQuestionToAsk.m | 2 ++ src/subfun/initializeExtraColumns.m | 2 ++ src/subfun/isPositiveInteger.m | 2 ++ src/subfun/printCreditsCppBids.m | 2 ++ src/subfun/removeAllDateSuffix.m | 2 ++ src/subfun/removeDateSuffix.m | 2 ++ src/subfun/returnHeaderName.m | 2 ++ src/subfun/returnNamesExtraColumns.m | 2 ++ src/subfun/returnNbColumns.m | 2 ++ src/subfun/setDefaultFields.m | 2 ++ src/subfun/setDefaultResponses.m | 2 ++ src/subfun/transferInfoToBids.m | 2 ++ src/userInputs.m | 2 ++ 29 files changed, 55 insertions(+), 3 deletions(-) diff --git a/lib/bids-matlab b/lib/bids-matlab index 71257b51..dd04a370 160000 --- a/lib/bids-matlab +++ b/lib/bids-matlab @@ -1 +1 @@ -Subproject commit 71257b51986f5075bb903eb090fe28b9b6dc3ebf +Subproject commit dd04a3709dcbfd04255cd43ef1caced94872ddc8 diff --git a/miss_hit.cfg b/miss_hit.cfg index f784081c..60976e52 100644 --- a/miss_hit.cfg +++ b/miss_hit.cfg @@ -1,8 +1,8 @@ # style guide (https://florianschanda.github.io/miss_hit/style_checker.html) line_length: 100 regex_function_name: "[a-z]+(([A-Z]){1}[A-Za-z]+)*" -suppress_rule: "copyright_notice" exclude_dir: "lib" +copyright_entity: "CPP_BIDS developers" # metrics limit for the code quality (https://florianschanda.github.io/miss_hit/metrics.html) metric "cnest": limit 4 diff --git a/src/checkCFG.m b/src/checkCFG.m index b6666647..3c3f0a05 100644 --- a/src/checkCFG.m +++ b/src/checkCFG.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function cfg = checkCFG(cfg) % cfg = checkCFG(cfg) % diff --git a/src/convertSourceToRaw.m b/src/convertSourceToRaw.m index bfc846ba..69caca0e 100644 --- a/src/convertSourceToRaw.m +++ b/src/convertSourceToRaw.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function convertSourceToRaw(cfg) % convertSourceToRaw(cfg) % diff --git a/src/createDataDictionary.m b/src/createDataDictionary.m index f424dfc4..f635f833 100644 --- a/src/createDataDictionary.m +++ b/src/createDataDictionary.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function createDataDictionary(cfg, logFile) % createDataDictionary(cfg, logFile) % diff --git a/src/createDatasetDescription.m b/src/createDatasetDescription.m index 4240d5ec..a65959d9 100644 --- a/src/createDatasetDescription.m +++ b/src/createDatasetDescription.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function createDatasetDescription(cfg) % createDatasetDescription(cfg) % diff --git a/src/createFilename.m b/src/createFilename.m index cf4e350f..1baa3511 100644 --- a/src/createFilename.m +++ b/src/createFilename.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function cfg = createFilename(cfg) % cfg = createFilename(cfg) % diff --git a/src/createJson.m b/src/createJson.m index 15bbbe1e..0f57b39b 100644 --- a/src/createJson.m +++ b/src/createJson.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function createJson(varargin) % createBoldJson(cfg, varargin) % diff --git a/src/miss_hit.cfg b/src/miss_hit.cfg index 25cb5611..ef3d7017 100644 --- a/src/miss_hit.cfg +++ b/src/miss_hit.cfg @@ -1,7 +1,7 @@ # style guide (https://florianschanda.github.io/miss_hit/style_checker.html) line_length: 100 regex_function_name: "[a-z]+(([A-Z]){1}[A-Za-z]+)*" -suppress_rule: "copyright_notice" +copyright_entity: "CPP_BIDS developers" # metrics limit for the code quality (https://florianschanda.github.io/miss_hit/metrics.html) metric "cnest": limit 4 diff --git a/src/saveEventsFile.m b/src/saveEventsFile.m index 949161ff..e0b10873 100644 --- a/src/saveEventsFile.m +++ b/src/saveEventsFile.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function [logFile] = saveEventsFile(action, cfg, logFile) % [logFile] = saveEventsFile(action, cfg, logFile) % diff --git a/src/subfun/askForGroupAndOrSession.m b/src/subfun/askForGroupAndOrSession.m index faad823c..bac91022 100644 --- a/src/subfun/askForGroupAndOrSession.m +++ b/src/subfun/askForGroupAndOrSession.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function cfg = askForGroupAndOrSession(cfg) askGrpSess = [true true]; diff --git a/src/subfun/askUserCli.m b/src/subfun/askUserCli.m index a2222eef..46491136 100644 --- a/src/subfun/askUserCli.m +++ b/src/subfun/askUserCli.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function responses = askUserCli(questions, responses) % response = askUserCli(questions) % diff --git a/src/subfun/askUserGui.m b/src/subfun/askUserGui.m index ddf42103..b563cfa4 100644 --- a/src/subfun/askUserGui.m +++ b/src/subfun/askUserGui.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function responses = askUserGui(questions, responses) % boolean for which question should be asked diff --git a/src/subfun/checkCppBidsDependencies.m b/src/subfun/checkCppBidsDependencies.m index dc752114..43d01ecc 100644 --- a/src/subfun/checkCppBidsDependencies.m +++ b/src/subfun/checkCppBidsDependencies.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function checkCppBidsDependencies(cfg) % checkCppBidsDependencies() % diff --git a/src/subfun/createQuestionList.m b/src/subfun/createQuestionList.m index 8d3b55c9..fc2c43b0 100644 --- a/src/subfun/createQuestionList.m +++ b/src/subfun/createQuestionList.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function questions = createQuestionList(cfg) cfg = askForGroupAndOrSession(cfg); diff --git a/src/subfun/createValidName.m b/src/subfun/createValidName.m index ef216ef1..57b905d4 100644 --- a/src/subfun/createValidName.m +++ b/src/subfun/createValidName.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function [name, nameValid] = createValidName(name) % [taskName, taskNameValid] = createTaskName(taskName) % diff --git a/src/subfun/getIsQuestionToAsk.m b/src/subfun/getIsQuestionToAsk.m index 8da55b03..a8446235 100644 --- a/src/subfun/getIsQuestionToAsk.m +++ b/src/subfun/getIsQuestionToAsk.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function isQuestionToAsk = getIsQuestionToAsk(questions, responses) isQuestionToAsk = cell2mat(questions.questionsToAsk(:, 2)); diff --git a/src/subfun/initializeExtraColumns.m b/src/subfun/initializeExtraColumns.m index cfbb1c34..2797b937 100644 --- a/src/subfun/initializeExtraColumns.m +++ b/src/subfun/initializeExtraColumns.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function logFile = initializeExtraColumns(logFile) % logFile = initializeExtraColumns(logFile) % initialize the fields for the extra columns diff --git a/src/subfun/isPositiveInteger.m b/src/subfun/isPositiveInteger.m index f44bc872..6178b16b 100644 --- a/src/subfun/isPositiveInteger.m +++ b/src/subfun/isPositiveInteger.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function trueOrFalse = isPositiveInteger(input2check) % trueOrFalse = isPositiveInteger(input2check) % diff --git a/src/subfun/printCreditsCppBids.m b/src/subfun/printCreditsCppBids.m index e9ff763a..172ab9b3 100644 --- a/src/subfun/printCreditsCppBids.m +++ b/src/subfun/printCreditsCppBids.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function printCreditsCppBids(cfg) try diff --git a/src/subfun/removeAllDateSuffix.m b/src/subfun/removeAllDateSuffix.m index 1f0bf0c3..7c64ab64 100644 --- a/src/subfun/removeAllDateSuffix.m +++ b/src/subfun/removeAllDateSuffix.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function removeAllDateSuffix(rawDir, subjName, sesName) % removeAllDateSuffix(rawDir, subjName, sesName) % diff --git a/src/subfun/removeDateSuffix.m b/src/subfun/removeDateSuffix.m index d06af305..eb8ca73e 100644 --- a/src/subfun/removeDateSuffix.m +++ b/src/subfun/removeDateSuffix.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function removeDateSuffix(filenames, subjectPath) % removeDateSuffix(filenames, subjectPath) % diff --git a/src/subfun/returnHeaderName.m b/src/subfun/returnHeaderName.m index e78865f1..fe59cbc3 100644 --- a/src/subfun/returnHeaderName.m +++ b/src/subfun/returnHeaderName.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function headerName = returnHeaderName(columnName, nbCol, iCol) % headerName = returnHeaderName(columnName, nbCol, iCol) % diff --git a/src/subfun/returnNamesExtraColumns.m b/src/subfun/returnNamesExtraColumns.m index ada0791c..39b17629 100644 --- a/src/subfun/returnNamesExtraColumns.m +++ b/src/subfun/returnNamesExtraColumns.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function [namesExtraColumns, logFile] = returnNamesExtraColumns(logFile) % [namesExtraColumns, logFile] = returnNamesExtraColumns(logFile) % diff --git a/src/subfun/returnNbColumns.m b/src/subfun/returnNbColumns.m index 1a603bb4..18234a7d 100644 --- a/src/subfun/returnNbColumns.m +++ b/src/subfun/returnNbColumns.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function nbCol = returnNbColumns(logFile, nameExtraColumn) % nbCol = returnNbColumns(logFile, nameExtraColumn) % diff --git a/src/subfun/setDefaultFields.m b/src/subfun/setDefaultFields.m index e54f805f..490b7cbd 100644 --- a/src/subfun/setDefaultFields.m +++ b/src/subfun/setDefaultFields.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function structure = setDefaultFields(structure, fieldsToSet) % structure = setDefaultFields(structure, fieldsToSet) % diff --git a/src/subfun/setDefaultResponses.m b/src/subfun/setDefaultResponses.m index 1d8074ea..d9814c45 100644 --- a/src/subfun/setDefaultResponses.m +++ b/src/subfun/setDefaultResponses.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function [cfg, responses] = setDefaultResponses(cfg) if nargin < 1 diff --git a/src/subfun/transferInfoToBids.m b/src/subfun/transferInfoToBids.m index c2267e41..f21950fd 100644 --- a/src/subfun/transferInfoToBids.m +++ b/src/subfun/transferInfoToBids.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function fieldsToSet = transferInfoToBids(fieldsToSet, cfg) % fieldsToSet = transferInfoToBids(fieldsToSet, cfg) % diff --git a/src/userInputs.m b/src/userInputs.m index 1d9c3481..9264bf8b 100644 --- a/src/userInputs.m +++ b/src/userInputs.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_BIDS developers + function cfg = userInputs(cfg) % cfg = userInputs(cfg) % From 270e750b672950c06b400f34c4b900060fcb088e Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 17 Sep 2020 21:15:46 +0200 Subject: [PATCH 04/36] rm extra mh cfg file --- src/miss_hit.cfg | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 src/miss_hit.cfg diff --git a/src/miss_hit.cfg b/src/miss_hit.cfg deleted file mode 100644 index ef3d7017..00000000 --- a/src/miss_hit.cfg +++ /dev/null @@ -1,10 +0,0 @@ -# style guide (https://florianschanda.github.io/miss_hit/style_checker.html) -line_length: 100 -regex_function_name: "[a-z]+(([A-Z]){1}[A-Za-z]+)*" -copyright_entity: "CPP_BIDS developers" - -# metrics limit for the code quality (https://florianschanda.github.io/miss_hit/metrics.html) -metric "cnest": limit 4 -metric "file_length": limit 500 -metric "cyc": limit 15 -metric "parameters": limit 6 \ No newline at end of file From 82fcbe9ae76ed56916d8ab39d23d53a785d21f63 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Tue, 18 Aug 2020 19:41:29 +0200 Subject: [PATCH 05/36] add some initialization for eyetracking --- src/checkCFG.m | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/checkCFG.m b/src/checkCFG.m index b6666647..c7fc81a5 100644 --- a/src/checkCFG.m +++ b/src/checkCFG.m @@ -31,11 +31,9 @@ fieldsToSet.testingDevice = 'pc'; - fieldsToSet.eyeTracker = struct(); + fieldsToSet = eyetrackerDefaults(fieldsToSet); - fieldsToSet.eyeTracker.do = false; - - fieldsToSet = mriDefaults(fieldsToSet); + fieldsToSet = setSuffixes(fieldsToSet); %% BIDS @@ -53,7 +51,7 @@ end -function fieldsToSet = mriDefaults(fieldsToSet) +function fieldsToSet = setSuffixes(fieldsToSet) % for file naming and JSON fieldsToSet.suffix.contrastEnhancement = []; @@ -246,3 +244,21 @@ fieldsToSet.bids.ieeg = orderfields(fieldsToSet.bids.beh); end + +function fieldsToSet = eyetrackerDefaults(fieldsToSet) + + fieldsToSet.eyeTracker.do = false; + fieldsToSet.eyeTracker.SamplingFrequency = []; + fieldsToSet.eyeTracker.PupilPositionType = ''; + fieldsToSet.eyeTracker.RawSamples = []; + fieldsToSet.eyeTracker.Manufacturer = ''; + fieldsToSet.eyeTracker.ManufacturersModelName = ''; + fieldsToSet.eyeTracker.SoftwareVersions = ''; + fieldsToSet.eyeTracker.CalibrationType = ''; + fieldsToSet.eyeTracker.CalibrationPosition = ''; + fieldsToSet.eyeTracker.CalibrationDistance = ''; + fieldsToSet.eyeTracker.MaximalCalibrationError = []; + fieldsToSet.eyeTracker.AverageCalibrationError = []; + fieldsToSet.eyeTracker.RawDataFilters = {}; + +end \ No newline at end of file From 5a964cf93a13d4375b0d10fcdc498cb9efd99bf9 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 23 Sep 2020 14:27:46 +0200 Subject: [PATCH 06/36] fix wrong stim.json save --- src/createDataDictionary.m | 2 +- tests/test_saveEventsFileOpen.m | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/createDataDictionary.m b/src/createDataDictionary.m index f635f833..30c86430 100644 --- a/src/createDataDictionary.m +++ b/src/createDataDictionary.m @@ -9,7 +9,7 @@ function createDataDictionary(cfg, logFile) opts.Indent = ' '; - fileName = strrep(cfg.fileName.events, '.tsv', '.json'); + fileName = strrep(logFile.filename, '.tsv', '.json'); fileName = fullfile( ... cfg.dir.outputSubject, ... diff --git a/tests/test_saveEventsFileOpen.m b/tests/test_saveEventsFileOpen.m index d04b2874..993d0688 100644 --- a/tests/test_saveEventsFileOpen.m +++ b/tests/test_saveEventsFileOpen.m @@ -38,6 +38,7 @@ function test_saveEventsFileOpenBasic() % check that the file has the right path and name assert(exist(fullfile(funcDir, eventFilename), 'file') == 2); + assert(exist(fullfile(funcDir, strrep(eventFilename, '.tsv', '.json')), 'file') == 2); FID = fopen(fullfile(funcDir, eventFilename), 'r'); C = textscan(FID, repmat('%s', 1, 3), 'Delimiter', '\t', 'EndOfLine', '\n'); @@ -82,6 +83,7 @@ function test_saveEventsFileOpenStimfile() % check that the file has the right path and name assert(exist(fullfile(funcDir, eventFilename), 'file') == 2); + assert(exist(fullfile(funcDir, strrep(eventFilename, '.tsv', '.json')), 'file') == 2); FID = fopen(fullfile(funcDir, eventFilename), 'r'); C = textscan(FID, repmat('%s', 1, 3), 'Delimiter', '\t', 'EndOfLine', '\n'); From 942a08a11301a1c4e970d86bee3a0eedd887e022 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 23 Sep 2020 14:34:13 +0200 Subject: [PATCH 07/36] mh fix --- manualTests/test_createDataDictionary.m | 4 +- manualTests/test_createJson.m | 8 ++-- manualTests/test_makeRawDataset.m | 28 +++++------ src/checkCFG.m | 6 +-- src/convertSourceToRaw.m | 12 ++--- src/createDataDictionary.m | 26 +++++------ src/createDatasetDescription.m | 4 +- src/createFilename.m | 62 ++++++++++++------------- src/createJson.m | 12 ++--- src/saveEventsFile.m | 28 +++++------ src/subfun/askUserGui.m | 14 +++--- src/subfun/checkCppBidsDependencies.m | 4 +- src/subfun/initializeExtraColumns.m | 6 +-- src/subfun/isPositiveInteger.m | 10 ++-- src/subfun/printCreditsCppBids.m | 8 ++-- src/subfun/removeAllDateSuffix.m | 8 ++-- src/subfun/removeDateSuffix.m | 2 +- src/subfun/setDefaultFields.m | 6 +-- tests/test_createFilename.m | 48 +++++++++---------- tests/test_createJson.m | 10 ++-- tests/test_createQuestionList.m | 8 ++-- tests/test_getIsQuestionToAsk.m | 20 ++++---- tests/test_removeDateSuffix.m | 16 +++---- tests/test_saveEventsFileOpen.m | 4 +- tests/test_saveEventsFileSave.m | 6 +-- 25 files changed, 180 insertions(+), 180 deletions(-) diff --git a/manualTests/test_createDataDictionary.m b/manualTests/test_createDataDictionary.m index d1f71138..48611447 100644 --- a/manualTests/test_createDataDictionary.m +++ b/manualTests/test_createDataDictionary.m @@ -37,7 +37,7 @@ function test_createDataDictionaryBasic() funcDir = fullfile(outputDir, 'source', 'sub-001', 'ses-001', 'func'); jsonFilename = ['sub-001_ses-001_task-testtask_run-001_events_date-' ... - cfg.fileName.date '.json']; + cfg.fileName.date '.json']; % test assertTrue(exist(fullfile(funcDir, jsonFilename), 'file') == 2); @@ -47,7 +47,7 @@ function test_createDataDictionaryBasic() % data to test against expectedStruct = bids.util.jsondecode( ... - fullfile(pwd, 'testData', 'eventsDataDictionary.json')); + fullfile(pwd, 'testData', 'eventsDataDictionary.json')); % test assertTrue(isequal(expectedStruct, actualStruct)); diff --git a/manualTests/test_createJson.m b/manualTests/test_createJson.m index c2fd031f..47fbd6ad 100644 --- a/manualTests/test_createJson.m +++ b/manualTests/test_createJson.m @@ -36,13 +36,13 @@ function test_createJsonExtra() fileName = strrep(fileName, '.tsv', '.json'); actualStruct = bids.util.jsondecode(fullfile( ... - cfg.dir.outputSubject, ... - cfg.fileName.modality, ... - fileName)); + cfg.dir.outputSubject, ... + cfg.fileName.modality, ... + fileName)); % data to test against expectedStruct = bids.util.jsondecode( ... - fullfile(pwd, 'testData', 'extra_bold.json')); + fullfile(pwd, 'testData', 'extra_bold.json')); % test assertEqual(expectedStruct, actualStruct); diff --git a/manualTests/test_makeRawDataset.m b/manualTests/test_makeRawDataset.m index 896b9caf..485a912d 100644 --- a/manualTests/test_makeRawDataset.m +++ b/manualTests/test_makeRawDataset.m @@ -205,16 +205,16 @@ function test_makeRawDataset() boldFilename = 'sub-001_ses-001_task-testtask_run-001_bold.nii.gz'; copyfile( ... - fullfile('dummyData', 'dummyData.nii.gz'), ... - fullfile(funcDir, boldFilename)); + fullfile('dummyData', 'dummyData.nii.gz'), ... + fullfile(funcDir, boldFilename)); boldFilename = ['sub-001_ses-001_task-rest', ... - '_acq-newTYpe_ce-test_dir-yPos_rec-fastRecon', ... - '_run-001_echo-1_bold.nii.gz']; + '_acq-newTYpe_ce-test_dir-yPos_rec-fastRecon', ... + '_run-001_echo-1_bold.nii.gz']; copyfile( ... - fullfile('dummyData', 'dummyData.nii.gz'), ... - fullfile(funcDir, boldFilename)); + fullfile('dummyData', 'dummyData.nii.gz'), ... + fullfile(funcDir, boldFilename)); eegDir = fullfile(subjectDir, 'eeg'); megDir = fullfile(subjectDir, 'meg'); @@ -227,20 +227,20 @@ function test_makeRawDataset() behFilename = 'sub-001_ses-001_task-easyTargetPractice_run-001_beh.tsv'; copyfile( ... - fullfile('dummyData', 'dummyData.nii.gz'), ... - fullfile(eegDir, eegFilename)); + fullfile('dummyData', 'dummyData.nii.gz'), ... + fullfile(eegDir, eegFilename)); copyfile( ... - fullfile('dummyData', 'dummyData.nii.gz'), ... - fullfile(megDir, megFilename)); + fullfile('dummyData', 'dummyData.nii.gz'), ... + fullfile(megDir, megFilename)); copyfile( ... - fullfile('dummyData', 'dummyData.nii.gz'), ... - fullfile(ieegDir, ieegFilename)); + fullfile('dummyData', 'dummyData.nii.gz'), ... + fullfile(ieegDir, ieegFilename)); copyfile( ... - fullfile('dummyData', 'dummyData.nii.gz'), ... - fullfile(behDir, behFilename)); + fullfile('dummyData', 'dummyData.nii.gz'), ... + fullfile(behDir, behFilename)); %% actually do the conversion of the source data thus created clear; diff --git a/src/checkCFG.m b/src/checkCFG.m index 3c3f0a05..bde96564 100644 --- a/src/checkCFG.m +++ b/src/checkCFG.m @@ -23,9 +23,9 @@ fieldsToSet.fileName.dateFormat = 'yyyymmddHHMM'; fieldsToSet.dir.output = fullfile( ... - fileparts(mfilename('fullpath')), ... - '..', ... - 'output'); + fileparts(mfilename('fullpath')), ... + '..', ... + 'output'); fieldsToSet.subject.askGrpSess = [true true]; fieldsToSet.subject.sessionNb = 1; % in case no session was provided diff --git a/src/convertSourceToRaw.m b/src/convertSourceToRaw.m index 69caca0e..28153cad 100644 --- a/src/convertSourceToRaw.m +++ b/src/convertSourceToRaw.m @@ -16,14 +16,14 @@ function convertSourceToRaw(cfg) % add dummy README and CHANGE file copyfile(fullfile( ... - fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', 'README'), ... - sourceDir); + fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', 'README'), ... + sourceDir); copyfile(fullfile( ... - fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', 'CHANGES'), ... - sourceDir); + fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', 'CHANGES'), ... + sourceDir); copyfile(fullfile( ... - fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', '.bidsignore'), ... - sourceDir); + fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', '.bidsignore'), ... + sourceDir); copyfile(sourceDir, rawDir); diff --git a/src/createDataDictionary.m b/src/createDataDictionary.m index 30c86430..6a123a64 100644 --- a/src/createDataDictionary.m +++ b/src/createDataDictionary.m @@ -12,21 +12,21 @@ function createDataDictionary(cfg, logFile) fileName = strrep(logFile.filename, '.tsv', '.json'); fileName = fullfile( ... - cfg.dir.outputSubject, ... - cfg.fileName.modality, ... - fileName); + cfg.dir.outputSubject, ... + cfg.fileName.modality, ... + fileName); jsonContent = struct( ... - 'onset', struct( ... - 'Description', 'time elapsed since experiment start', ... - 'Unit', 's'), ... - 'trial_type', struct( ... - 'Description', 'types of trial', ... - 'Levels', ''), ... - 'duration', struct( ... - 'Description', 'duration of the event or the block', ... - 'Unit', 's') ... - ); + 'onset', struct( ... + 'Description', 'time elapsed since experiment start', ... + 'Unit', 's'), ... + 'trial_type', struct( ... + 'Description', 'types of trial', ... + 'Levels', ''), ... + 'duration', struct( ... + 'Description', 'duration of the event or the block', ... + 'Unit', 's') ... + ); % transfer content of extra fields to json content namesExtraColumns = returnNamesExtraColumns(logFile); diff --git a/src/createDatasetDescription.m b/src/createDatasetDescription.m index a65959d9..38e44fa2 100644 --- a/src/createDatasetDescription.m +++ b/src/createDatasetDescription.m @@ -9,8 +9,8 @@ function createDatasetDescription(cfg) opts.Indent = ' '; fileName = fullfile( ... - cfg.dir.output, 'source', ... - 'dataset_description.json'); + cfg.dir.output, 'source', ... + 'dataset_description.json'); jsonContent = cfg.bids.datasetDescription; diff --git a/src/createFilename.m b/src/createFilename.m index 1baa3511..4f6addb7 100644 --- a/src/createFilename.m +++ b/src/createFilename.m @@ -84,10 +84,10 @@ % output dir cfg.dir.outputSubject = fullfile ( ... - cfg.dir.output, ... - 'source', ... - ['sub-' subjectGrp, sprintf(pattern, subjectNb)], ... - ['ses-', sprintf(pattern, sessionNb)]); + cfg.dir.output, ... + 'source', ... + ['sub-' subjectGrp, sprintf(pattern, subjectNb)], ... + ['ses-', sprintf(pattern, sessionNb)]); [~, ~, ~] = mkdir(cfg.dir.output); [~, ~, ~] = mkdir(cfg.dir.outputSubject); @@ -102,22 +102,22 @@ %% MRI % set values for the suffixes for the different fields in the BIDS name fields2Check = { ... - 'acquisition', ... - 'contrastEnhancement', ... - 'echo', ... - 'phaseEncodingDirection', ... - 'reconstruction', ... - 'recording' ... - }; + 'acquisition', ... + 'contrastEnhancement', ... + 'echo', ... + 'phaseEncodingDirection', ... + 'reconstruction', ... + 'recording' ... + }; targetFields = { ... - 'acq', ... - 'ce', ... - 'echo', ... - 'dir', ... - 'rec', ... - 'recording' ... - }; + 'acq', ... + 'ce', ... + 'echo', ... + 'dir', ... + 'rec', ... + 'recording' ... + }; for iField = 1:numel(fields2Check) @@ -158,14 +158,14 @@ thisDate = cfg.fileName.date; cfg.fileName.datasetDescription = fullfile ( ... - cfg.dir.output, ... - 'dataset_description.json'); + cfg.dir.output, ... + 'dataset_description.json'); % create base fileName fileNameBase = ... ['sub-', subjectGrp, sprintf(pattern, subjectNb), ... - '_ses-', sprintf(pattern, sessionNb), ... - '_task-', taskName]; + '_ses-', sprintf(pattern, sessionNb), ... + '_task-', taskName]; cfg.fileName.base = fileNameBase; switch modality @@ -173,16 +173,16 @@ case 'func' basename = [fileNameBase, ... - acqSuffix, ceSuffix, ... - dirSuffix, recSuffix, ... - runSuffix, echoSuffix]; + acqSuffix, ceSuffix, ... + dirSuffix, recSuffix, ... + runSuffix, echoSuffix]; case 'beh' basename = ... [fileNameBase, ... - acqSuffix, ... - runSuffix]; + acqSuffix, ... + runSuffix]; otherwise @@ -206,18 +206,18 @@ function talkToMe(cfg) if cfg.verbose > 0 fprintf(1, '\nData will be saved in this directory:\n\t%s\n', ... - fullfile(cfg.dir.outputSubject, cfg.fileName.modality)); + fullfile(cfg.dir.outputSubject, cfg.fileName.modality)); fprintf(1, '\nData will be saved in this file:\n\t%s\n', ... - cfg.fileName.events); + 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')); + fullfile(cfg.dir.outputSubject, 'eyetracker')); fprintf(1, '\nEyetracking data will be saved in this file:\n\t%s\n', ... - cfg.fileName.eyetracker); + cfg.fileName.eyetracker); end diff --git a/src/createJson.m b/src/createJson.m index 0f57b39b..cff29ede 100644 --- a/src/createJson.m +++ b/src/createJson.m @@ -39,9 +39,9 @@ function createJson(varargin) fileName = strrep(fileName, '.tsv', '.json'); fileName = fullfile( ... - cfg.dir.outputSubject, ... - modality, ... - fileName); + cfg.dir.outputSubject, ... + modality, ... + fileName); %% add content of extraInfo to the JSON content @@ -115,11 +115,11 @@ function errorCreateJson(identifier, varargin) case 'wrongInputType' errorStruct.message = ['The second input must be a string (modality)' ... - 'or a structure (extraInfo)']; + 'or a structure (extraInfo)']; case 'wrongModalityInput' errorStruct.message = sprintf(['The given modality is not valid: %s.\n', ... - 'Only the following string are accepted: beh, func, eeg, ieeg, meg'], ... - varargin{1}); + 'Only the following string are accepted: beh, func, eeg, ieeg, meg'], ... + varargin{1}); end diff --git a/src/saveEventsFile.m b/src/saveEventsFile.m index e0b10873..42976359 100644 --- a/src/saveEventsFile.m +++ b/src/saveEventsFile.m @@ -154,11 +154,11 @@ % Initialize txt logfiles and empty fields for the standard BIDS % event file logFile(1).fileID = fopen( ... - fullfile( ... - cfg.dir.outputSubject, ... - cfg.fileName.modality, ... - logFile.filename), ... - 'w'); + fullfile( ... + cfg.dir.outputSubject, ... + cfg.fileName.modality, ... + logFile.filename), ... + 'w'); % print the basic BIDS columns fprintf(logFile(1).fileID, '%s\t%s\t%s', 'onset', 'duration', 'trial_type'); @@ -219,7 +219,7 @@ function printHeaderExtraColumns(logFile) if ~ischar(data) && any(isnan(data)) warning('saveEventsFile:missingData', ... - 'Missing some %s data for this event.', namesExtraColumns{iExtraColumn}); + 'Missing some %s data for this event.', namesExtraColumns{iExtraColumn}); if cfg.verbose > 1 disp(logFile(iEvent)); @@ -269,7 +269,7 @@ function printHeaderExtraColumns(logFile) data(end + 1:end + padding) = nan(1, padding); elseif ~isempty(expectedLength) && isnumeric(data) && max(size(data)) > expectedLength warning('saveEventsFile:arrayTooLong', ... - 'A field for this event is longer than expected. Truncating the extra values.'); + 'A field for this event is longer than expected. Truncating the extra values.'); data = data(1:expectedLength); end @@ -293,9 +293,9 @@ function printHeaderExtraColumns(logFile) any(isempty({onset duration})) warning('saveEventsFile:emptyEvent', ... - '\nSkipping saving this event.\n onset: %s \n duration: %s\n', ... - onset, ... - duration); + '\nSkipping saving this event.\n onset: %s \n duration: %s\n', ... + onset, ... + duration); else @@ -395,10 +395,10 @@ function talkToMe(cfg, logFile) if cfg.verbose > 0 fprintf(1, '\nData were saved in this file:\n\n%s\n\n', ... - fullfile( ... - cfg.dir.outputSubject, ... - cfg.fileName.modality, ... - logFile.filename)); + fullfile( ... + cfg.dir.outputSubject, ... + cfg.fileName.modality, ... + logFile.filename)); end diff --git a/src/subfun/askUserGui.m b/src/subfun/askUserGui.m index b563cfa4..a141c637 100644 --- a/src/subfun/askUserGui.m +++ b/src/subfun/askUserGui.m @@ -12,9 +12,9 @@ % keep asking the question till we get a positive integer value for each for iQuestion = 1:size(questions.questionsToAsk) questions.questionsToAsk{iQuestion} = sprintf('%s %s\n %s', ... - '\color{red}', ... - questions.questionsToAsk{iQuestion}, ... - questions.mustBePositiveInteger); + '\color{red}', ... + questions.questionsToAsk{iQuestion}, ... + questions.mustBePositiveInteger); end while 1 @@ -34,10 +34,10 @@ fieldDim = repmat([1 50], sum(isQuestionToAsk), 1); currentResp = inputdlg(quest.questionsToAsk(isQuestionToAsk, 1), ... - 'Subject info', ... - fieldDim, ... - resp(isQuestionToAsk), ... - opts); + 'Subject info', ... + fieldDim, ... + resp(isQuestionToAsk), ... + opts); resp(isQuestionToAsk) = currentResp; diff --git a/src/subfun/checkCppBidsDependencies.m b/src/subfun/checkCppBidsDependencies.m index 43d01ecc..c0d794ff 100644 --- a/src/subfun/checkCppBidsDependencies.m +++ b/src/subfun/checkCppBidsDependencies.m @@ -33,8 +33,8 @@ function checkSubmodule(pth) % 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 ']); + 'Try this in your terminal:', ... + ' git submodule update --recursive ']); else addpath(pth); end diff --git a/src/subfun/initializeExtraColumns.m b/src/subfun/initializeExtraColumns.m index 2797b937..ef1dad32 100644 --- a/src/subfun/initializeExtraColumns.m +++ b/src/subfun/initializeExtraColumns.m @@ -22,7 +22,7 @@ for iExtraColumn = 1:nbExtraColumns extraColumnName = logFile(1).extraColumns{iExtraColumn}; tmp.(extraColumnName) = struct( ... - 'length', 1); + 'length', 1); tmp.(extraColumnName) = setDefaultFields(tmp.(extraColumnName), fieldsToSet); end @@ -35,8 +35,8 @@ logFile(1).extraColumns.(namesExtraColumns{iExtraColumn}) = ... setDefaultFields( ... - logFile(1).extraColumns.(namesExtraColumns{iExtraColumn}), ... - fieldsToSet); + logFile(1).extraColumns.(namesExtraColumns{iExtraColumn}), ... + fieldsToSet); end diff --git a/src/subfun/isPositiveInteger.m b/src/subfun/isPositiveInteger.m index 6178b16b..e3598544 100644 --- a/src/subfun/isPositiveInteger.m +++ b/src/subfun/isPositiveInteger.m @@ -7,10 +7,10 @@ % trueOrFalse = ~any([ ... - ~isnumeric(input2check), ... - isnan(input2check), ... - fix(input2check) ~= input2check, ... - input2check < 0 ... - ]); + ~isnumeric(input2check), ... + isnan(input2check), ... + fix(input2check) ~= input2check, ... + input2check < 0 ... + ]); end diff --git a/src/subfun/printCreditsCppBids.m b/src/subfun/printCreditsCppBids.m index 172ab9b3..03947463 100644 --- a/src/subfun/printCreditsCppBids.m +++ b/src/subfun/printCreditsCppBids.m @@ -4,7 +4,7 @@ function printCreditsCppBids(cfg) try version = fileread(fullfile(fileparts(mfilename('fullpath')), ... - '..', '..', 'version.txt')); + '..', '..', 'version.txt')); catch version = 'v1.0.0'; end @@ -17,9 +17,9 @@ function printCreditsCppBids(cfg) if verbose > 1 contributors = { ... - 'Rémi Gau', ... - 'Marco Barilari', ... - 'Ceren Battal'}; + 'Rémi Gau', ... + 'Marco Barilari', ... + 'Ceren Battal'}; DOI_URL = 'https://doi.org/10.5281/zenodo.4007674'; diff --git a/src/subfun/removeAllDateSuffix.m b/src/subfun/removeAllDateSuffix.m index 7c64ab64..b9b5dcbb 100644 --- a/src/subfun/removeAllDateSuffix.m +++ b/src/subfun/removeAllDateSuffix.m @@ -14,23 +14,23 @@ function removeAllDateSuffix(rawDir, subjName, sesName) % do events filenames = file_utils('List', subjectPath, ... - sprintf('^%s.*_task-.*_events_date-.*$', subjName)); + sprintf('^%s.*_task-.*_events_date-.*$', subjName)); removeDateSuffix(filenames, subjectPath); for iLabel = 1:numel(labels) filenames = file_utils('List', subjectPath, ... - sprintf('^%s.*_task-.*_%s_date-.*$', subjName, labels{iLabel})); + sprintf('^%s.*_task-.*_%s_date-.*$', subjName, labels{iLabel})); removeDateSuffix(filenames, subjectPath); end % do stim filenames = file_utils('List', subjectPath, ... - sprintf('^%s.*_task-.*_stim_date-.*tsv$', subjName)); + sprintf('^%s.*_task-.*_stim_date-.*tsv$', subjName)); compressFiles(filenames, subjectPath); filenames = file_utils('List', subjectPath, ... - sprintf('^%s.*_task-.*_stim_date-.*tsv.gz$', subjName)); + sprintf('^%s.*_task-.*_stim_date-.*tsv.gz$', subjName)); removeDateSuffix(filenames, subjectPath); end diff --git a/src/subfun/removeDateSuffix.m b/src/subfun/removeDateSuffix.m index eb8ca73e..ab04cbb2 100644 --- a/src/subfun/removeDateSuffix.m +++ b/src/subfun/removeDateSuffix.m @@ -25,7 +25,7 @@ function removeDateSuffix(filenames, subjectPath) % remove suffix file if there was one if ~strcmp(filenames{i}, [parts{1} ext]) movefile(fullfile(subjectPath, filenames{i}), ... - fullfile(subjectPath, [parts{1} ext])); + fullfile(subjectPath, [parts{1} ext])); end end diff --git a/src/subfun/setDefaultFields.m b/src/subfun/setDefaultFields.m index 490b7cbd..6cfad781 100644 --- a/src/subfun/setDefaultFields.m +++ b/src/subfun/setDefaultFields.m @@ -22,9 +22,9 @@ else structure = setFieldToIfNotPresent( ... - structure, ... - names{i}, ... - thisField); + structure, ... + names{i}, ... + thisField); end end diff --git a/tests/test_createFilename.m b/tests/test_createFilename.m index 336eef0c..a1d0c622 100644 --- a/tests/test_createFilename.m +++ b/tests/test_createFilename.m @@ -18,10 +18,10 @@ function test_createFilenameBasic() behDir = fullfile(cfg.dir.output, 'source', 'sub-001', 'ses-001', 'beh'); eventFilename = ['sub-001_ses-001_task-testTask_run-001_events_date-'... - cfg.fileName.date '.tsv']; + cfg.fileName.date '.tsv']; stimFilename = ['sub-001_ses-001_task-testTask_run-001_stim_date-'... - cfg.fileName.date '.tsv']; + cfg.fileName.date '.tsv']; %% test @@ -56,11 +56,11 @@ function test_createFilenameMriEyetracker() baseFilename = 'sub-001_ses-001_task-testTask'; eventFilename = ['sub-001_ses-001_task-testTask_run-001_events_date-' ... - cfg.fileName.date '.tsv']; + cfg.fileName.date '.tsv']; eyetrackerFilename = [ ... - 'sub-001_ses-001_task-testTask_run-001_recording-eyetracking_physio_date-' ... - cfg.fileName.date '.edf']; + 'sub-001_ses-001_task-testTask_run-001_recording-eyetracking_physio_date-' ... + cfg.fileName.date '.edf']; %% tests % make sure the func dir is created @@ -100,14 +100,14 @@ function test_createFilenameMriSuffix() baseFilename = 'sub-001_ses-001_task-testTask'; eventFilename = ['sub-001_ses-001_task-testTask', ... - '_acq-newTYpe_ce-test_dir-yPos_rec-fastRecon', ... - '_run-001_echo-1_events_date-' ... - cfg.fileName.date '.tsv']; + '_acq-newTYpe_ce-test_dir-yPos_rec-fastRecon', ... + '_run-001_echo-1_events_date-' ... + cfg.fileName.date '.tsv']; stimFilename = ['sub-001_ses-001_task-testTask', ... - '_acq-newTYpe_ce-test_dir-yPos_rec-fastRecon', ... - '_run-001_echo-1_recording-respiPulse_stim_date-' ... - cfg.fileName.date '.tsv']; + '_acq-newTYpe_ce-test_dir-yPos_rec-fastRecon', ... + '_run-001_echo-1_recording-respiPulse_stim_date-' ... + cfg.fileName.date '.tsv']; %% tests % make sure the func dir is created @@ -144,14 +144,14 @@ function test_createFilenameBehSuffix() baseFilename = 'sub-001_ses-001_task-testTask'; eventFilename = ['sub-001_ses-001_task-testTask', ... - '_acq-newTYpe', ... - '_run-001_events_date-' ... - cfg.fileName.date '.tsv']; + '_acq-newTYpe', ... + '_run-001_events_date-' ... + cfg.fileName.date '.tsv']; stimFilename = ['sub-001_ses-001_task-testTask', ... - '_acq-newTYpe', ... - '_run-001_recording-respiPulse_stim_date-' ... - cfg.fileName.date '.tsv']; + '_acq-newTYpe', ... + '_run-001_recording-respiPulse_stim_date-' ... + cfg.fileName.date '.tsv']; %% tests % make sure the func dir is created @@ -188,12 +188,12 @@ function test_createFilenameEegSuffix() baseFilename = 'sub-001_ses-001_task-testTask'; eventFilename = ['sub-001_ses-001_task-testTask', ... - '_run-001_events_date-' ... - cfg.fileName.date '.tsv']; + '_run-001_events_date-' ... + cfg.fileName.date '.tsv']; stimFilename = ['sub-001_ses-001_task-testTask', ... - '_run-001_recording-respiPulse_stim_date-' ... - cfg.fileName.date '.tsv']; + '_run-001_recording-respiPulse_stim_date-' ... + cfg.fileName.date '.tsv']; %% tests % make sure the func dir is created @@ -220,7 +220,7 @@ function test_createFilenameEeg() eegDir = fullfile(cfg.dir.output, 'source', 'sub-001', 'ses-001', 'eeg'); eventFilename = ['sub-001_ses-001_task-testTask_run-001_events_date-'... - cfg.fileName.date '.tsv']; + cfg.fileName.date '.tsv']; %% test % make sure the func dir is created @@ -249,7 +249,7 @@ function test_createFilenameIeeg() assertTrue(exist(ieegDir, 'dir') == 7); eventFilename = ['sub-001_ses-001_task-testTask_run-001_events_date-'... - cfg.fileName.date '.tsv']; + cfg.fileName.date '.tsv']; end @@ -271,7 +271,7 @@ function test_createFilenameMeg() assertTrue(exist(megDir, 'dir') == 7); eventFilename = ['sub-001_ses-001_task-testTask_run-001_events_date-'... - cfg.fileName.date '.tsv']; + cfg.fileName.date '.tsv']; end diff --git a/tests/test_createJson.m b/tests/test_createJson.m index aace3715..e4f67b2b 100644 --- a/tests/test_createJson.m +++ b/tests/test_createJson.m @@ -23,7 +23,7 @@ function test_createJsonFunc() funcDir = fullfile(cfg.dir.output, 'source', 'sub-001', 'ses-001', 'func'); eventFilename = ['sub-001_ses-001_task-testtask_run-001_bold_date-' ... - cfg.fileName.date '.json']; + cfg.fileName.date '.json']; %% test assertTrue(exist(fullfile(funcDir, eventFilename), 'file') == 2); @@ -47,7 +47,7 @@ function test_createJsonBeh() funcDir = fullfile(cfg.dir.output, 'source', 'sub-001', 'ses-001', 'beh'); eventFilename = ['sub-001_ses-001_task-testtask_run-001_beh_date-' ... - cfg.fileName.date '.json']; + cfg.fileName.date '.json']; %% test assertTrue(exist(fullfile(funcDir, eventFilename), 'file') == 2); @@ -71,7 +71,7 @@ function test_createJsonEeg() funcDir = fullfile(cfg.dir.output, 'source', 'sub-001', 'ses-001', 'eeg'); eventFilename = ['sub-001_ses-001_task-testtask_run-001_eeg_date-' ... - cfg.fileName.date '.json']; + cfg.fileName.date '.json']; %% test assertTrue(exist(fullfile(funcDir, eventFilename), 'file') == 2); @@ -95,7 +95,7 @@ function test_createJsonMeg() funcDir = fullfile(cfg.dir.output, 'source', 'sub-001', 'ses-001', 'meg'); eventFilename = ['sub-001_ses-001_task-testtask_run-001_meg_date-' ... - cfg.fileName.date '.json']; + cfg.fileName.date '.json']; %% test assertTrue(exist(fullfile(funcDir, eventFilename), 'file') == 2); @@ -119,7 +119,7 @@ function test_createJsonIeeg() funcDir = fullfile(cfg.dir.output, 'source', 'sub-001', 'ses-001', 'ieeg'); eventFilename = ['sub-001_ses-001_task-testtask_run-001_ieeg_date-' ... - cfg.fileName.date '.json']; + cfg.fileName.date '.json']; %% test assertTrue(exist(fullfile(funcDir, eventFilename), 'file') == 2); diff --git a/tests/test_createQuestionList.m b/tests/test_createQuestionList.m index 999110ee..88a9e08c 100644 --- a/tests/test_createQuestionList.m +++ b/tests/test_createQuestionList.m @@ -14,10 +14,10 @@ function test_createQuestionListBasic() questions = createQuestionList(cfg); expectedCell = { ... - 'Enter subject group (leave empty if none): ', false; - 'Enter subject number (1-999): ', true; - 'Enter the session number (i.e day ; 1-999): ', true; - 'Enter the run number (1-999): ', true}; + 'Enter subject group (leave empty if none): ', false + 'Enter subject number (1-999): ', true + 'Enter the session number (i.e day ; 1-999): ', true + 'Enter the run number (1-999): ', true}; assertEqual(expectedCell(3, 1), questions.questionsToAsk(3, 1)); diff --git a/tests/test_getIsQuestionToAsk.m b/tests/test_getIsQuestionToAsk.m index 632668c6..a53b0892 100644 --- a/tests/test_getIsQuestionToAsk.m +++ b/tests/test_getIsQuestionToAsk.m @@ -9,18 +9,18 @@ function test_isPositiveIntegerBasic() questions.questionsToAsk = { ... - [], 1; ... - [], 0; ... - [], 1; ... - [], 0; ... - }; + [], 1; ... + [], 0; ... + [], 1; ... + [], 0 ... + }; responses = { ... - '1'; - '1'; - '-1'; - '-1'; - }; + '1' + '1' + '-1' + '-1' + }; isQuestionToAsk = getIsQuestionToAsk(questions, responses); diff --git a/tests/test_removeDateSuffix.m b/tests/test_removeDateSuffix.m index 67aa2a43..e1d85d6b 100644 --- a/tests/test_removeDateSuffix.m +++ b/tests/test_removeDateSuffix.m @@ -23,14 +23,14 @@ function test_removeDateSuffixBasic() stimNameZipped = 'test2_stim_date-202008050730.tsv.gz'; filesToProcess = { ... - boldName; - boldName2; - boldName3; - jsonName; - eventsName; - stimName; - stimNameZipped; - }; + boldName + boldName2 + boldName3 + jsonName + eventsName + stimName + stimNameZipped + }; % create new files for new tests for iFile = 1:numel(filesToProcess) diff --git a/tests/test_saveEventsFileOpen.m b/tests/test_saveEventsFileOpen.m index 993d0688..d09d9aaa 100644 --- a/tests/test_saveEventsFileOpen.m +++ b/tests/test_saveEventsFileOpen.m @@ -34,7 +34,7 @@ function test_saveEventsFileOpenBasic() %% data to test against funcDir = fullfile(outputDir, 'source', 'sub-001', 'ses-001', 'func'); eventFilename = ['sub-001_ses-001_task-testtask_run-001_events_date-' ... - cfg.fileName.date '.tsv']; + cfg.fileName.date '.tsv']; % check that the file has the right path and name assert(exist(fullfile(funcDir, eventFilename), 'file') == 2); @@ -79,7 +79,7 @@ function test_saveEventsFileOpenStimfile() %% data to test against funcDir = fullfile(outputDir, 'source', 'sub-001', 'ses-001', 'func'); eventFilename = ['sub-001_ses-001_task-testtask_run-001_stim_date-' ... - cfg.fileName.date '.tsv']; + cfg.fileName.date '.tsv']; % check that the file has the right path and name assert(exist(fullfile(funcDir, eventFilename), 'file') == 2); diff --git a/tests/test_saveEventsFileSave.m b/tests/test_saveEventsFileSave.m index 251df236..1a800178 100644 --- a/tests/test_saveEventsFileSave.m +++ b/tests/test_saveEventsFileSave.m @@ -187,10 +187,10 @@ function test_saveEventsFileSaveErrors() logFile = struct(); assertExceptionThrown(@()saveEventsFile('error', cfg, logFile), ... - 'saveEventsFile:unknownActionType'); + 'saveEventsFile:unknownActionType'); assertExceptionThrown(@()saveEventsFile('save', cfg, logFile), ... - 'saveEventsFile:missingFileID'); + 'saveEventsFile:missingFileID'); [cfg, logFile] = setUp(); @@ -203,7 +203,7 @@ function test_saveEventsFileSaveErrors() logFile(end, end).LHL24 = rand(1, 10); assertExceptionThrown(@()saveEventsFile('save', cfg, logFile), ... - 'saveEventsFile:wrongLogSize'); + 'saveEventsFile:wrongLogSize'); end From 1cf568da1227414797d0d8a7215f4892716625ca Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 24 Sep 2020 20:04:15 +0200 Subject: [PATCH 08/36] add remark and check_links --- .github/workflows/check_md_links.yml | 12 ++++++++++++ .prettierrc | 13 +++++++++++++ .remarkrc | 11 +++++++++++ npm-requirements.txt | 6 ++++++ 4 files changed, 42 insertions(+) create mode 100644 .github/workflows/check_md_links.yml create mode 100644 .prettierrc create mode 100644 .remarkrc create mode 100644 npm-requirements.txt diff --git a/.github/workflows/check_md_links.yml b/.github/workflows/check_md_links.yml new file mode 100644 index 00000000..3d461992 --- /dev/null +++ b/.github/workflows/check_md_links.yml @@ -0,0 +1,12 @@ +name: Check Markdown links + +# checking for any dead links in markdown files + +on: push + +jobs: + markdown-link-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: gaurav-nelson/github-action-markdown-link-check@v1 \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..6e0d1ce8 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,13 @@ +{ + "parser": "markdown", + "proseWrap": "always", + "tabWidth": 2, + "overrides": [ + { + "files": "*.md", + "options": { + "tabWidth": 4 + } + } + ] +} diff --git a/.remarkrc b/.remarkrc new file mode 100644 index 00000000..201ce70e --- /dev/null +++ b/.remarkrc @@ -0,0 +1,11 @@ +{ + "plugins": [ + "preset-lint-consistent", + "preset-lint-markdown-style-guide", + "preset-lint-recommended", + ["lint-no-duplicate-headings", false], + ["lint-list-item-indent", "tab-size"], + ["lint-maximum-line-length", true], + ["lint-maximum-heading-length", false] + ] +} diff --git a/npm-requirements.txt b/npm-requirements.txt new file mode 100644 index 00000000..061f9ade --- /dev/null +++ b/npm-requirements.txt @@ -0,0 +1,6 @@ +remark-cli@5.0.0 +remark-lint@6.0.2 +remark-preset-lint-recommended@3.0.2 +remark-preset-lint-markdown-style-guide@2.1.2 +remark-preset-lint-consistent + From fc3215079d4c74eb7f3ad7ea3c1d845aba8d48a8 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 24 Sep 2020 20:33:26 +0200 Subject: [PATCH 09/36] mh fix --- src/convertSourceToRaw.m | 9 ++++++--- src/createDataDictionary.m | 2 +- src/createJson.m | 3 ++- src/subfun/removeAllDateSuffix.m | 3 ++- tests/test_createFilename.m | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/convertSourceToRaw.m b/src/convertSourceToRaw.m index 28153cad..f4b4ea4f 100644 --- a/src/convertSourceToRaw.m +++ b/src/convertSourceToRaw.m @@ -16,13 +16,16 @@ function convertSourceToRaw(cfg) % add dummy README and CHANGE file copyfile(fullfile( ... - fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', 'README'), ... + fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', ... + 'README'), ... sourceDir); copyfile(fullfile( ... - fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', 'CHANGES'), ... + fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', ... + 'CHANGES'), ... sourceDir); copyfile(fullfile( ... - fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', '.bidsignore'), ... + fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', ... + '.bidsignore'), ... sourceDir); copyfile(sourceDir, rawDir); diff --git a/src/createDataDictionary.m b/src/createDataDictionary.m index 6a123a64..62639f0d 100644 --- a/src/createDataDictionary.m +++ b/src/createDataDictionary.m @@ -9,7 +9,7 @@ function createDataDictionary(cfg, logFile) opts.Indent = ' '; - fileName = strrep(logFile.filename, '.tsv', '.json'); + fileName = strrep(logFile(1).filename, '.tsv', '.json'); fileName = fullfile( ... cfg.dir.outputSubject, ... diff --git a/src/createJson.m b/src/createJson.m index cff29ede..fdc42a35 100644 --- a/src/createJson.m +++ b/src/createJson.m @@ -118,7 +118,8 @@ function errorCreateJson(identifier, varargin) 'or a structure (extraInfo)']; case 'wrongModalityInput' errorStruct.message = sprintf(['The given modality is not valid: %s.\n', ... - 'Only the following string are accepted: beh, func, eeg, ieeg, meg'], ... + 'Only the following string are accepted: ' ... + 'beh, func, eeg, ieeg, meg'], ... varargin{1}); end diff --git a/src/subfun/removeAllDateSuffix.m b/src/subfun/removeAllDateSuffix.m index b9b5dcbb..be90478a 100644 --- a/src/subfun/removeAllDateSuffix.m +++ b/src/subfun/removeAllDateSuffix.m @@ -20,7 +20,8 @@ function removeAllDateSuffix(rawDir, subjName, sesName) for iLabel = 1:numel(labels) filenames = file_utils('List', subjectPath, ... - sprintf('^%s.*_task-.*_%s_date-.*$', subjName, labels{iLabel})); + sprintf('^%s.*_task-.*_%s_date-.*$', ... + subjName, labels{iLabel})); removeDateSuffix(filenames, subjectPath); end diff --git a/tests/test_createFilename.m b/tests/test_createFilename.m index a1d0c622..36f5b546 100644 --- a/tests/test_createFilename.m +++ b/tests/test_createFilename.m @@ -55,11 +55,11 @@ function test_createFilenameMriEyetracker() baseFilename = 'sub-001_ses-001_task-testTask'; - eventFilename = ['sub-001_ses-001_task-testTask_run-001_events_date-' ... + eventFilename = [baseFilename '_run-001_events_date-' ... cfg.fileName.date '.tsv']; eyetrackerFilename = [ ... - 'sub-001_ses-001_task-testTask_run-001_recording-eyetracking_physio_date-' ... + baseFilename '_run-001_recording-eyetracking_physio_date-' ... cfg.fileName.date '.edf']; %% tests From 2210b07f4f951d92179881111ed3b43c0cbf6807 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 24 Sep 2020 20:39:53 +0200 Subject: [PATCH 10/36] update CI --- .github/workflows/check_md_links.yml | 8 +++++++- .travis.yml | 28 ++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check_md_links.yml b/.github/workflows/check_md_links.yml index 3d461992..c54aac1c 100644 --- a/.github/workflows/check_md_links.yml +++ b/.github/workflows/check_md_links.yml @@ -2,7 +2,13 @@ name: Check Markdown links # checking for any dead links in markdown files -on: push +on: + push: + branches: + - master + - dev + pull_request: + branches: '*' jobs: markdown-link-check: diff --git a/.travis.yml b/.travis.yml index 73839af7..5d0027eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,13 @@ python: cache: apt: true # only works with Pro version + directories: + - node_modules # NPM packages for the remark markdown linter + +branches: + only: # only run the CI for those branches + - master + - dev env: global: # Define environment variables for bash @@ -43,9 +50,26 @@ before_script: jobs: include: - - name: "BIDS validator: create and check dataset" + # BIDS validation + - stage: "BIDS validator" + name: "BIDS validator: create and check dataset" script: octave $OCTFLAGS --eval "test_makeRawDataset" && bids-validator `pwd`/output/raw/ --ignoreNiftiHeaders - - name: "miss_hit: checking code quality" + + # naming the Tests stage + - stage: "miss_hit" + name: "miss_hit: checking code quality" script: mh_metric . --ci + - name: "miss_hit: checking code style" script: mh_style . + + # naming the Linter stage + - stage: Markdown linter + name: "Check markdown" + language: node_js + node_js: + - "10" + before_script: + - npm install `cat npm-requirements.txt` + script: + - remark . --frail From 8af2db0d567b692b08c2ffbbabcabe1f224c26e7 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 24 Sep 2020 20:43:31 +0200 Subject: [PATCH 11/36] fix markdown --- README.md | 80 +++++++++++++++++++++-------------- docs/functions_description.md | 79 +++++++++++++++++++++------------- docs/installation.md | 39 ++++++++++------- 3 files changed, 121 insertions(+), 77 deletions(-) diff --git a/README.md b/README.md index 4db24351..a54cff20 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ **Unit tests and coverage** [![](https://img.shields.io/badge/Octave-CI-blue?logo=Octave&logoColor=white)](https://github.com/cpp-lln-lab/CPP_BIDS/actions) -![](https://github.com/cpp-lln-lab/CPP_BIDS/workflows/CI/badge.svg) +![](https://github.com/cpp-lln-lab/CPP_BIDS/workflows/CI/badge.svg) [![codecov](https://codecov.io/gh/cpp-lln-lab/CPP_BIDS/branch/master/graph/badge.svg)](https://codecov.io/gh/cpp-lln-lab/CPP_BIDS) @@ -15,20 +15,21 @@ **Contributors** -[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-) --- - + # CPP_BIDS -* 1. [Output format](#Outputformat) - * 1.1. [Modality agnostic aspect](#Modalityagnosticaspect) -* 2. [Documentation](#Documentation) -* 3. [Contributing](#Contributing) - * 3.1. [Guidestyle](#Guidestyle) - * 3.2. [BIDS naming convention](#BIDSnamingconvention) - * 3.3. [Contributors ✨](#Contributors) + +- 1. [Output format](#Outputformat) + - 1.1. [Modality agnostic aspect](#Modalityagnosticaspect) +- 2. [Documentation](#Documentation) +- 3. [Contributing](#Contributing) + - 3.1. [Guidestyle](#Guidestyle) + - 3.2. [BIDS naming convention](#BIDSnamingconvention) + - 3.3. [Contributors ✨](#Contributors) -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. +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. -## 1. Output format +## 1. Output format -### 1.1. Modality agnostic aspect +### 1.1. Modality agnostic aspect -Subjects, session and run number labels will be numbers with zero padding up to 3 values (e.g subject 1 will become `sub-001`). +Subjects, session and run number labels will be numbers with zero padding up to +3 values (e.g subject 1 will become `sub-001`). -A session folder will ALWAYS be created even if not requested (default will be `ses-001`). +A session folder will ALWAYS be created even if not requested (default will be +`ses-001`). Task labels will be printed in camelCase in the filenames. -Time stamps are added directly in the filename by adding a suffix `_date-YYYYMMDDHHMM` which makes the file name non-BIDS compliant. This was added to prevent overwriting files in case a certain run needs to be done a second time because of a crash (Some of us are paranoid about keeping even cancelled runs during my experiments). This suffix should be removed to make the data set BIDS compliant. See `convertSourceToRaw.m` for more details. +Time stamps are added directly in the filename by adding a suffix +`_date-YYYYMMDDHHMM` which makes the file name non-BIDS compliant. This was +added to prevent overwriting files in case a certain run needs to be done a +second time because of a crash (Some of us are paranoid about keeping even +cancelled runs during my experiments). This suffix should be removed to make the +data set BIDS compliant. See `convertSourceToRaw.m` for more details. For example: @@ -56,23 +67,27 @@ For example: sub-090/ses-003/sub-090_ses-003_task-auditoryTask_run-023_events_date-202007291536.tsv ``` -## 2. Documentation +## 2. Documentation -- [Installation](./docs/installation.md) -- [How to use it: jupyter notebooks](./notebooks) -- [Functions description](./docs/functions_description.md) +- [Installation](./docs/installation.md) +- [How to use it: jupyter notebooks](./notebooks) +- [Functions description](./docs/functions_description.md) -## 3. Contributing +## 3. Contributing Feel free to open issues to report a bug and ask for improvements. -### 3.1. Guidestyle +### 3.1. Guidestyle - We use camelCase. -- We keep the McCabe complexity as reported by the [check_my_code function](https://github.com/Remi-Gau/check_my_code) below 15. -- We use the [MISS_HIT linter](https://florianschanda.github.io/miss_hit/style_checker.html) to automatically fix some linting issues. +- We keep the McCabe complexity as reported by the + [check_my_code function](https://github.com/Remi-Gau/check_my_code) + below 15. +- We use the + [MISS_HIT linter](https://florianschanda.github.io/miss_hit/style_checker.html) + to automatically fix some linting issues. -### 3.2. BIDS naming convention +### 3.2. BIDS naming convention Here are the naming templates used. @@ -104,16 +119,13 @@ The format used by the MATLAB toolbox EEGLAB (Each recording consisting of a .se Biosemi data format (Each recording consisting of a .bdf file) --> - - - MEG ??? - Eyetracker -current format -`_recording-eyetracking_physio.tsv.gz` +current format `_recording-eyetracking_physio.tsv.gz` future BEP format in a dedicated eyetracker folder `sub-[_ses-