diff --git a/demos/MoAE/MoAEpilot_run.m b/demos/MoAE/MoAEpilot_run.m index 59e7c9b6..f427d365 100644 --- a/demos/MoAE/MoAEpilot_run.m +++ b/demos/MoAE/MoAEpilot_run.m @@ -43,6 +43,7 @@ bidsCopyRawFolder(opt, 1); % In case you just want to run segmentation and skull stripping +% Skull stripping is also included in 'bidsSpatialPrepro' % bidsSegmentSkullStrip(opt); bidsSTC(opt); diff --git a/docs/source/method_section_boilerplate.rst b/docs/source/method_section_boilerplate.rst index aacb8fbc..bb50cd93 100644 --- a/docs/source/method_section_boilerplate.rst +++ b/docs/source/method_section_boilerplate.rst @@ -1,12 +1,6 @@ Boilerplate methods section *************************** -Use the report function to get a print out of the content of a dataset. - -.. automodule:: src.reports - -.. autofunction:: reportBIDS - Preprocessing ============= @@ -83,3 +77,13 @@ Friston KJ, Ashburner J, Frith CD, Poline J-B, Heather JD & Frackowiak RSJ Corbin, N., Todd, N., Friston, K. J. & Callaghan, M. F. Accurate modeling of temporal correlations in rapidly sampled fMRI time series. Hum. Brain Mapp. 39, 3884–3897 (2018). + + +--- + +Use the report function to get a print out of the content of a dataset. + +.. automodule:: src.reports + +.. autofunction:: reportBIDS +.. autofunction:: copyGraphWindownOutput \ No newline at end of file diff --git a/src/defaults/spm_my_defaults.m b/src/defaults/spm_my_defaults.m index c2cdf376..d9b1b94a 100644 --- a/src/defaults/spm_my_defaults.m +++ b/src/defaults/spm_my_defaults.m @@ -9,6 +9,10 @@ global defaults + % User Interface defaults + % ========================================================================== + defaults.ui.print = 'png'; + % File format specific % ========================================================================== defaults.mat.format = '-v7'; diff --git a/src/reports/copyGraphWindownOutput.m b/src/reports/copyGraphWindownOutput.m new file mode 100644 index 00000000..775d7ea3 --- /dev/null +++ b/src/reports/copyGraphWindownOutput.m @@ -0,0 +1,61 @@ +% (C) Copyright 2019 CPP BIDS SPM-pipeline developpers + +function imgNb = copyGraphWindownOutput(opt, subID, action, imgNb) + % + % Looks into the current directory for an ``spm_.*imgNb.png`` file and moves it into + % the output directory ``sub-label/figures``. + % The output name of the file is + % ``yyyymmddHHMM_sub-label_task-label_action.png`` + % + % USAGE:: + % + % imgNb = copyGraphWindownOutput(opt, subID, [action = '',] [imgNb = 1]) + % + % :param opt: options + % :type opt: structure + % :param subID: + % :type subID: string + % :param action: + % :type action: string + % :param imgNb: image number to look for. SPM increments them automatically. + % :type imgNb: integer + % + % :returns: - :imgNb: (integer) number of the next image to get. + % + % assumes that no file was generated if SPM is running in command line mode + + if ~spm('CmdLine') + + if nargin < 4 || isempty(imgNb) + imgNb = 1; + end + + if nargin < 3 || isempty(action) + action = ''; + end + + figureDir = fullfile(opt.derivativesDir, ['sub-' subID], 'figures'); + if ~exist(figureDir, 'dir') + mkdir(figureDir); + end + + file = spm_select('FPList', pwd, sprintf('^spm_.*%i.png$', imgNb)); + + if ~isempty(file) + + targetFile = [datestr(now, 'yyyymmddHHMM') ... + '_sub-', subID, ... + '_task-', opt.taskName, ... + '_' action '.png']; + + movefile( ... + file, ... + fullfile(figureDir, targetFile)); + + imgNb = imgNb + 1; + + end + + end + +end diff --git a/src/utils/setGraphicWindow.m b/src/utils/setGraphicWindow.m new file mode 100644 index 00000000..2c17ec0c --- /dev/null +++ b/src/utils/setGraphicWindow.m @@ -0,0 +1,5 @@ +% (C) Copyright 2019 CPP BIDS SPM-pipeline developpers + +function [interactiveWindow, graphWindow, cmdLine] = setGraphicWindow() + [interactiveWindow, graphWindow, cmdLine] = spm('FnUIsetup'); +end diff --git a/src/workflows/bidsSegmentSkullStrip.m b/src/workflows/bidsSegmentSkullStrip.m index 4ddbfe69..8ec44571 100644 --- a/src/workflows/bidsSegmentSkullStrip.m +++ b/src/workflows/bidsSegmentSkullStrip.m @@ -1,4 +1,4 @@ -% (C) Copyright 20120 CPP BIDS SPM-pipeline developpers +% (C) Copyright 2020 CPP BIDS SPM-pipeline developpers function bidsSegmentSkullStrip(opt) % diff --git a/src/workflows/bidsSpatialPrepro.m b/src/workflows/bidsSpatialPrepro.m index 2a100219..40026472 100644 --- a/src/workflows/bidsSpatialPrepro.m +++ b/src/workflows/bidsSpatialPrepro.m @@ -23,6 +23,8 @@ function bidsSpatialPrepro(opt) end opt = loadAndCheckOptions(opt); + setGraphicWindow(); + % load the subjects/Groups information and the task name [group, opt, BIDS] = getData(opt); @@ -43,14 +45,11 @@ function bidsSpatialPrepro(opt) printProcessingSubject(groupName, iSub, subID); - % identify sessions for this subject - sessions = getInfo(BIDS, subID, opt, 'Sessions'); - matlabbatch = setBatchSelectAnat(matlabbatch, BIDS, opt, subID); opt.orderBatches.selectAnat = 1; action = []; - if strcmp(opt.space, 'individual') + if strcmp(opt.space, 'individual') action = 'realignUnwarp'; end [matlabbatch, voxDim] = setBatchRealign(matlabbatch, BIDS, subID, opt, action); @@ -79,6 +78,12 @@ function bidsSpatialPrepro(opt) spm_jobman('run', matlabbatch); + imgNb = copyGraphWindownOutput(opt, subID, 'realign'); + if strcmp(opt.space, 'individual') + imgNb = copyGraphWindownOutput(opt, subID, 'unwarp', imgNb); + end + imgNb = copyGraphWindownOutput(opt, subID, 'func2anatCoreg', imgNb); + end end