Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions demos/MoAE/MoAEpilot_run.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 10 additions & 6 deletions docs/source/method_section_boilerplate.rst
Original file line number Diff line number Diff line change
@@ -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
=============

Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions src/defaults/spm_my_defaults.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

global defaults

% User Interface defaults
% ==========================================================================
defaults.ui.print = 'png';

% File format specific
% ==========================================================================
defaults.mat.format = '-v7';
Expand Down
61 changes: 61 additions & 0 deletions src/reports/copyGraphWindownOutput.m
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions src/utils/setGraphicWindow.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
% (C) Copyright 2019 CPP BIDS SPM-pipeline developpers

function [interactiveWindow, graphWindow, cmdLine] = setGraphicWindow()
[interactiveWindow, graphWindow, cmdLine] = spm('FnUIsetup');
end
2 changes: 1 addition & 1 deletion src/workflows/bidsSegmentSkullStrip.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% (C) Copyright 20120 CPP BIDS SPM-pipeline developpers
% (C) Copyright 2020 CPP BIDS SPM-pipeline developpers

function bidsSegmentSkullStrip(opt)
%
Expand Down
13 changes: 9 additions & 4 deletions src/workflows/bidsSpatialPrepro.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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

Expand Down