From 3b6bbe528411a5ed5a839cd6c6bffc9592dd0967 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 24 Dec 2020 09:26:09 +0100 Subject: [PATCH 1/2] update miss hit config --- .github/workflows/miss_hit.yml | 14 +++++++++----- requirements.txt | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/miss_hit.yml b/.github/workflows/miss_hit.yml index 4603893a..caae9915 100644 --- a/.github/workflows/miss_hit.yml +++ b/.github/workflows/miss_hit.yml @@ -28,12 +28,16 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip setuptools - pip3 install miss_hit + pip3 install -r requirements.txt - - name: Miss_hit code quality + - name: MISS_HIT Code style run: | - mh_metric . --ci + mh_style --process-slx - - name: Miss_hit code style + - name: MISS_HIT Metrics run: | - mh_style . + mh_metric --ci + + - name: MISS_HIT Bug finder + run: | + mh_lint diff --git a/requirements.txt b/requirements.txt index 42ea70da..992d0ece 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,4 @@ Sphinx sphinxcontrib-matlabdomain sphinxcontrib-napoleon sphinx_rtd_theme -miss_hit \ No newline at end of file +miss_hit==0.9.15 \ No newline at end of file From 32c7283bdb716a7d4dae0d134d359a70300a5e5a Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 24 Dec 2020 09:30:14 +0100 Subject: [PATCH 2/2] mh autofix --- demos/sourceDataProcessing/batchSource.m | 2 +- demos/sourceDataProcessing/getOptionSource.m | 2 +- demos/spm_face_rep/face_rep_convert2BIDS.m | 6 ++--- demos/spm_face_rep/face_rep_run.m | 2 +- src/QA/anatomicalQA.m | 4 ++-- src/QA/functionalQA.m | 10 ++++----- src/batches/setBatchComputeVDM.m | 6 ++--- src/batches/setBatchReslice.m | 1 - .../setBatchSaveCoregistrationMatrix.m | 10 ++++----- src/batches/setBatchSmoothConImages.m | 12 +++++----- src/defaults/createDefaultModel.m | 2 +- src/defaults/createEmptyModel.m | 4 ++-- .../getMetadataFromIntendedForFunc.m | 12 +++++----- src/fieldmaps/getVdmFile.m | 16 +++++++------- src/getData.m | 10 ++++----- src/getInfo.m | 22 +++++++++---------- src/setDerivativesDir.m | 2 +- src/subject_level/convertOnsetTsvToMat.m | 6 ++--- src/utils/validationInputFile.m | 14 ++++++------ src/workflows/bidsFFX.m | 2 +- src/workflows/bidsGZipRawFolder.m | 9 ++++---- src/workflows/bidsSmoothing.m | 2 -- 22 files changed, 76 insertions(+), 80 deletions(-) diff --git a/demos/sourceDataProcessing/batchSource.m b/demos/sourceDataProcessing/batchSource.m index 0be72c84..7334115f 100644 --- a/demos/sourceDataProcessing/batchSource.m +++ b/demos/sourceDataProcessing/batchSource.m @@ -21,4 +21,4 @@ % defaceAnat(optSource); COMING SOON % GZip the volumes in a raw folder -bidsGZipRawFolder(optSource, 0) \ No newline at end of file +bidsGZipRawFolder(optSource, 0); diff --git a/demos/sourceDataProcessing/getOptionSource.m b/demos/sourceDataProcessing/getOptionSource.m index 0b064a65..27689884 100644 --- a/demos/sourceDataProcessing/getOptionSource.m +++ b/demos/sourceDataProcessing/getOptionSource.m @@ -17,7 +17,7 @@ % Set the folder where sequences folders exist optSource.sourceDir = '/Users/barilari/Desktop/DICOM_UCL_leuven/renamed/sub-pilot001/ses-002/MRI'; - + optSource.dataDir = '/Users/barilari/Desktop/DICOM_UCL_leuven/raw'; % List of the sequences that you want to skip (folder name pattern) diff --git a/demos/spm_face_rep/face_rep_convert2BIDS.m b/demos/spm_face_rep/face_rep_convert2BIDS.m index 8fdc07e7..fffea5da 100644 --- a/demos/spm_face_rep/face_rep_convert2BIDS.m +++ b/demos/spm_face_rep/face_rep_convert2BIDS.m @@ -53,7 +53,7 @@ function face_rep_convert2BIDS() ['sub-01_task-' strrep(task_name, ' ', '') '_bold.mat'])); %% And everything else - create_events_tsv_file(WD, task_name, repetition_time) + create_events_tsv_file(WD, task_name, repetition_time); create_readme(WD); create_changelog(WD); create_datasetdescription(WD, opt); @@ -62,7 +62,7 @@ function face_rep_convert2BIDS() end function create_events_tsv_file(WD, task_name, repetition_time) - + % TODO % add the lag between presentations of each item necessary for the parametric % analysis. @@ -86,7 +86,7 @@ function create_events_tsv_file(WD, task_name, repetition_time) [onset_column, idx] = sort(onset_column); duration_column = duration_column(idx); trial_type_column = trial_type_column(idx, :); - + onset_column = repetition_time * onset_column; tsv_content = struct( ... diff --git a/demos/spm_face_rep/face_rep_run.m b/demos/spm_face_rep/face_rep_run.m index 73628f00..5ea3695e 100644 --- a/demos/spm_face_rep/face_rep_run.m +++ b/demos/spm_face_rep/face_rep_run.m @@ -69,5 +69,5 @@ bidsFFX('specifyAndEstimate', opt, FWHM); bidsFFX('contrasts', opt, FWHM); -%TODO +% TODO bidsResults(opt, FWHM); diff --git a/src/QA/anatomicalQA.m b/src/QA/anatomicalQA.m index de30adc8..05819ce2 100644 --- a/src/QA/anatomicalQA.m +++ b/src/QA/anatomicalQA.m @@ -11,9 +11,9 @@ function anatomicalQA(opt) % :param opt: Options chosen for the analysis. See ``checkOptions()``. % :type opt: structure % - + if isOctave() - warning('\nanatomicalQA is not yet supported on Octave. This step will be skipped.') + warning('\nanatomicalQA is not yet supported on Octave. This step will be skipped.'); end % if input has no opt, load the opt.mat file diff --git a/src/QA/functionalQA.m b/src/QA/functionalQA.m index 98938f90..43f1f10a 100644 --- a/src/QA/functionalQA.m +++ b/src/QA/functionalQA.m @@ -25,9 +25,9 @@ function functionalQA(opt) % resliced to the dimension of the functional with ``bidsResliceTpmToFunc()`` if isOctave() - warning('\nfunctionalQA is not yet supported on Octave. This step will be skipped.') + warning('\nfunctionalQA is not yet supported on Octave. This step will be skipped.'); end - + % if input has no opt, load the opt.mat file if nargin < 1 opt = []; @@ -123,10 +123,10 @@ function functionalQA(opt) createDataDictionary(subFuncDataDir, fileName, size(confounds, 2)); % create carpet plot - - % horrible hack to prevent the "abrupt" way spmup_volumecorr crashes + + % horrible hack to prevent the "abrupt" way spmup_volumecorr crashes % if nansum is not there - if exist('nansum','file') == 2 + if exist('nansum', 'file') == 2 spmup_timeseriesplot(funcImage, TPMs(1, :), TPMs(2, :), TPMs(3, :), ... 'motion', 'on', ... 'nuisances', 'on', ... diff --git a/src/batches/setBatchComputeVDM.m b/src/batches/setBatchComputeVDM.m index 09947a1e..3a368e9a 100644 --- a/src/batches/setBatchComputeVDM.m +++ b/src/batches/setBatchComputeVDM.m @@ -10,10 +10,10 @@ % % :param matlabbatch: list of SPM batches % :type matlabbatch: structure - % :param fmapType: - % :type fmapType: + % :param fmapType: + % :type fmapType: % :param refImage: Reference image - % :type refImage: + % :type refImage: % % :returns: - :matlabbatch: (structure) The matlabbatch ready to run the spm job % diff --git a/src/batches/setBatchReslice.m b/src/batches/setBatchReslice.m index d4da93a5..72ef6ce0 100644 --- a/src/batches/setBatchReslice.m +++ b/src/batches/setBatchReslice.m @@ -19,7 +19,6 @@ % :returns: - :matlabbatch: (structure) The matlabbatch ready to run the spm job % - printBatchName('reslicing'); if ischar(referenceImg) diff --git a/src/batches/setBatchSaveCoregistrationMatrix.m b/src/batches/setBatchSaveCoregistrationMatrix.m index f65c5d4e..f427e7ac 100644 --- a/src/batches/setBatchSaveCoregistrationMatrix.m +++ b/src/batches/setBatchSaveCoregistrationMatrix.m @@ -8,16 +8,16 @@ % % matlabbatch = setBatchSaveCoregistrationMatrix(matlabbatch, BIDS, subID, opt) % - % :param matlabbatch: + % :param matlabbatch: % :type matlabbatch: structure % :param BIDS: BIDS layout returned by ``getData``. % :type BIDS: structure - % :param subID: + % :param subID: % :type subID: - % :param opt: + % :param opt: % :type opt: Options chosen for the analysis. See ``checkOptions()``. - % - % :returns: - :matlabbatch: + % + % :returns: - :matlabbatch: % printBatchName('saving coregistration matrix'); diff --git a/src/batches/setBatchSmoothConImages.m b/src/batches/setBatchSmoothConImages.m index d36df997..be0897d2 100644 --- a/src/batches/setBatchSmoothConImages.m +++ b/src/batches/setBatchSmoothConImages.m @@ -8,15 +8,15 @@ % % matlabbatch = setBatchSmoothConImages(group, funcFWHM, conFWHM, opt) % - % :param group: - % :type group: - % :param funcFWHM: + % :param group: + % :type group: + % :param funcFWHM: % :type funcFWHM: - % :param conFWHM: + % :param conFWHM: % :type conFWHM: % :param opt: Options chosen for the analysis. See ``checkOptions()``. - % :type opt: - % + % :type opt: + % % :returns: - :matlabbatch: % diff --git a/src/defaults/createDefaultModel.m b/src/defaults/createDefaultModel.m index 5a2d3c67..4936188d 100644 --- a/src/defaults/createDefaultModel.m +++ b/src/defaults/createDefaultModel.m @@ -46,7 +46,7 @@ % opt = checkOptions(opt); % % [~, opt, BIDS] = getData(opt); - % + % % createDefaultModel(BIDS, opt); % diff --git a/src/defaults/createEmptyModel.m b/src/defaults/createEmptyModel.m index 4ea71bf8..6847ba76 100644 --- a/src/defaults/createEmptyModel.m +++ b/src/defaults/createEmptyModel.m @@ -2,8 +2,8 @@ function content = createEmptyModel() % - % Creates the content of a basic model.json file for GLM analysis with - % some default options like high pass filter cut-off + % Creates the content of a basic model.json file for GLM analysis with + % some default options like high pass filter cut-off % and the type of autocorrelation correction. % % USAGE:: diff --git a/src/fieldmaps/getMetadataFromIntendedForFunc.m b/src/fieldmaps/getMetadataFromIntendedForFunc.m index e122fb74..9dd309d7 100644 --- a/src/fieldmaps/getMetadataFromIntendedForFunc.m +++ b/src/fieldmaps/getMetadataFromIntendedForFunc.m @@ -39,12 +39,12 @@ fragments = bids.internal.parse_filename(filename); funcMetadata = bids.query(BIDS, 'metadata', ... - 'modality', 'func', ... - 'type', fragments.type, ... - 'sub', fragments.sub, ... - 'ses', fragments.ses, ... - 'run', fragments.run, ... - 'acq', fragments.acq); + 'modality', 'func', ... + 'type', fragments.type, ... + 'sub', fragments.sub, ... + 'ses', fragments.ses, ... + 'run', fragments.run, ... + 'acq', fragments.acq); end diff --git a/src/fieldmaps/getVdmFile.m b/src/fieldmaps/getVdmFile.m index 364ec003..2c96416e 100644 --- a/src/fieldmaps/getVdmFile.m +++ b/src/fieldmaps/getVdmFile.m @@ -27,8 +27,8 @@ end modalities = bids.query(BIDS, 'modalities', ... - 'sub', fragments.sub, ... - 'ses', fragments.ses); + 'sub', fragments.sub, ... + 'ses', fragments.ses); if opt.useFieldmaps && any(ismember('fmap', modalities)) % We loop through the field maps and find the one that is intended for this @@ -37,14 +37,14 @@ % We break the loop when the file has been found fmapFiles = bids.query(BIDS, 'data', ... - 'modality', 'fmap', ... - 'sub', fragments.sub, ... - 'ses', fragments.ses); + 'modality', 'fmap', ... + 'sub', fragments.sub, ... + 'ses', fragments.ses); fmapMetadata = bids.query(BIDS, 'metadata', ... - 'modality', 'fmap', ... - 'sub', fragments.sub, ... - 'ses', fragments.ses); + 'modality', 'fmap', ... + 'sub', fragments.sub, ... + 'ses', fragments.ses); for iFile = 1:size(fmapFiles, 1) diff --git a/src/getData.m b/src/getData.m index 06cb12f9..b212bc33 100644 --- a/src/getData.m +++ b/src/getData.m @@ -135,13 +135,13 @@ switch type case 'bold' metadata = bids.query(BIDS, 'metadata', ... - 'task', opt.taskName, ... - 'sub', subjects{1}, ... - 'type', type); + 'task', opt.taskName, ... + 'sub', subjects{1}, ... + 'type', type); case 'T1w' metadata = bids.query(BIDS, 'metadata', ... - 'sub', subjects{1}, ... - 'type', type); + 'sub', subjects{1}, ... + 'type', type); end if iscell(metadata) diff --git a/src/getInfo.m b/src/getInfo.m index b8ca04cb..8e56ef5a 100644 --- a/src/getInfo.m +++ b/src/getInfo.m @@ -41,8 +41,8 @@ case 'sessions' sessions = bids.query(BIDS, 'sessions', ... - 'sub', subID, ... - 'task', opt.taskName); + 'sub', subID, ... + 'task', opt.taskName); nbSessions = size(sessions, 2); if nbSessions == 0 nbSessions = 1; @@ -56,10 +56,10 @@ session = varargin{1}; runs = bids.query(BIDS, 'runs', ... - 'sub', subID, ... - 'task', opt.taskName, ... - 'ses', session, ... - 'type', 'bold'); + 'sub', subID, ... + 'task', opt.taskName, ... + 'ses', session, ... + 'type', 'bold'); nbRuns = size(runs, 2); % Get the number of runs if nbRuns == 0 @@ -74,11 +74,11 @@ [session, run, type] = deal(varargin{:}); varargout = bids.query(BIDS, 'data', ... - 'sub', subID, ... - 'run', run, ... - 'ses', session, ... - 'task', opt.taskName, ... - 'type', type); + 'sub', subID, ... + 'run', run, ... + 'ses', session, ... + 'task', opt.taskName, ... + 'type', type); otherwise error('Not sure what info you want me to get.'); diff --git a/src/setDerivativesDir.m b/src/setDerivativesDir.m index 0ea21b27..e04b5e7a 100644 --- a/src/setDerivativesDir.m +++ b/src/setDerivativesDir.m @@ -13,7 +13,7 @@ % :param opt: Options chosen for the analysis. See ``checkOptions()``. % :type opt: structure % - % :returns: + % :returns: % - :opt: structure or json filename containing the options. See % ``checkOptions()`` and ``loadAndCheckOptions()``. % diff --git a/src/subject_level/convertOnsetTsvToMat.m b/src/subject_level/convertOnsetTsvToMat.m index 775a3d9c..c81cc80f 100644 --- a/src/subject_level/convertOnsetTsvToMat.m +++ b/src/subject_level/convertOnsetTsvToMat.m @@ -38,10 +38,10 @@ end % assign all the tsv information to a variable called conds. - conds = t.trial_type; + conds = t.trial_type; - % identify where the conditions to include that are specificed - % in the run step of the model file + % identify where the conditions to include that are specificed + % in the run step of the model file model = spm_jsonread(opt.model.file); for runIdx = 1:numel(model.Steps) diff --git a/src/utils/validationInputFile.m b/src/utils/validationInputFile.m index 724f3d68..03a9bd9f 100644 --- a/src/utils/validationInputFile.m +++ b/src/utils/validationInputFile.m @@ -18,8 +18,8 @@ % :param dir: Directory where the search will be conducted. % :type dir: string % :param fileName: file name pattern. Can be a regular expression except for - % the starting ``^`` and ending ``$``. For example: - % ``'sub-.*_ses-.*_task-.*_bold.nii'``. + % the starting ``^`` and ending ``$``. For example: + % ``'sub-.*_ses-.*_task-.*_bold.nii'``. % :type fileName: string % :param prefix: prefix to be added to the filename pattern. This can also be % a regular expression (ish). For example ,f looking for the files that @@ -27,20 +27,20 @@ % ``c[123]``. % :type prefix: string % - % :returns: + % :returns: % % :files: (string array) returns the fullpath file list of all the % files matching the required pattern. - % - % + % + % % See also: ``spm_select``. % % % Example: - % % + % % % % tissueProbaMaps = validationInputFile(anatDataDir, anatImage, 'c[12]'); % - % + % if nargin < 3 prefix = ''; diff --git a/src/workflows/bidsFFX.m b/src/workflows/bidsFFX.m index 63683932..f80db125 100644 --- a/src/workflows/bidsFFX.m +++ b/src/workflows/bidsFFX.m @@ -33,7 +33,7 @@ function bidsFFX(action, opt, funcFWHM) end [BIDS, opt, group] = setUpWorkflow(opt, 'subject level GLM'); - + if isempty(opt.model.file) opt = createDefaultModel(BIDS, opt); end diff --git a/src/workflows/bidsGZipRawFolder.m b/src/workflows/bidsGZipRawFolder.m index 490b710c..3e371fd4 100644 --- a/src/workflows/bidsGZipRawFolder.m +++ b/src/workflows/bidsGZipRawFolder.m @@ -17,7 +17,6 @@ function bidsGZipRawFolder(optSource, keepUnzippedNii) % :type keepUnzippedNii: boolean %% input variables default values - if nargin < 2 || isempty(keepUnzippedNii) % delete the original unzipped .nii @@ -25,15 +24,15 @@ function bidsGZipRawFolder(optSource, keepUnzippedNii) end tic; - + printWorklowName('GZip data'); - + rawDir = optSource.dataDir; unzippedNiifiles = cellstr(spm_select('FPListRec', rawDir, '^.*.nii$')); - + matlabbatch = setBatchGZip(unzippedNiifiles, keepUnzippedNii); spm_jobman('run', matlabbatch); - + toc; diff --git a/src/workflows/bidsSmoothing.m b/src/workflows/bidsSmoothing.m index 38135575..c48a85d7 100644 --- a/src/workflows/bidsSmoothing.m +++ b/src/workflows/bidsSmoothing.m @@ -16,8 +16,6 @@ function bidsSmoothing(funcFWHM, opt) % ``checkOptions()`` and ``loadAndCheckOptions()``. % :type opt: structure - - % if nargin < 2