Skip to content

Commit 4deda58

Browse files
authored
Merge pull request #119 from Remi-Gau/remi-graph_window
[ENH] launch graphic windows and save output to func directory
2 parents 84ca082 + c062bdf commit 4deda58

File tree

7 files changed

+91
-11
lines changed

7 files changed

+91
-11
lines changed

demos/MoAE/MoAEpilot_run.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
bidsCopyRawFolder(opt, 1);
4444

4545
% In case you just want to run segmentation and skull stripping
46+
% Skull stripping is also included in 'bidsSpatialPrepro'
4647
% bidsSegmentSkullStrip(opt);
4748

4849
bidsSTC(opt);

docs/source/method_section_boilerplate.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
Boilerplate methods section
22
***************************
33

4-
Use the report function to get a print out of the content of a dataset.
5-
6-
.. automodule:: src.reports
7-
8-
.. autofunction:: reportBIDS
9-
104
Preprocessing
115
=============
126

@@ -83,3 +77,13 @@ Friston KJ, Ashburner J, Frith CD, Poline J-B, Heather JD & Frackowiak RSJ
8377
Corbin, N., Todd, N., Friston, K. J. & Callaghan, M. F. Accurate modeling of
8478
temporal correlations in rapidly sampled fMRI time series. Hum. Brain Mapp. 39,
8579
3884–3897 (2018).
80+
81+
82+
---
83+
84+
Use the report function to get a print out of the content of a dataset.
85+
86+
.. automodule:: src.reports
87+
88+
.. autofunction:: reportBIDS
89+
.. autofunction:: copyGraphWindownOutput

src/defaults/spm_my_defaults.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
global defaults
1111

12+
% User Interface defaults
13+
% ==========================================================================
14+
defaults.ui.print = 'png';
15+
1216
% File format specific
1317
% ==========================================================================
1418
defaults.mat.format = '-v7';
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
% (C) Copyright 2019 CPP BIDS SPM-pipeline developpers
2+
3+
function imgNb = copyGraphWindownOutput(opt, subID, action, imgNb)
4+
%
5+
% Looks into the current directory for an ``spm_.*imgNb.png`` file and moves it into
6+
% the output directory ``sub-label/figures``.
7+
% The output name of the file is
8+
% ``yyyymmddHHMM_sub-label_task-label_action.png``
9+
%
10+
% USAGE::
11+
%
12+
% imgNb = copyGraphWindownOutput(opt, subID, [action = '',] [imgNb = 1])
13+
%
14+
% :param opt: options
15+
% :type opt: structure
16+
% :param subID:
17+
% :type subID: string
18+
% :param action:
19+
% :type action: string
20+
% :param imgNb: image number to look for. SPM increments them automatically.
21+
% :type imgNb: integer
22+
%
23+
% :returns: - :imgNb: (integer) number of the next image to get.
24+
%
25+
% assumes that no file was generated if SPM is running in command line mode
26+
27+
if ~spm('CmdLine')
28+
29+
if nargin < 4 || isempty(imgNb)
30+
imgNb = 1;
31+
end
32+
33+
if nargin < 3 || isempty(action)
34+
action = '';
35+
end
36+
37+
figureDir = fullfile(opt.derivativesDir, ['sub-' subID], 'figures');
38+
if ~exist(figureDir, 'dir')
39+
mkdir(figureDir);
40+
end
41+
42+
file = spm_select('FPList', pwd, sprintf('^spm_.*%i.png$', imgNb));
43+
44+
if ~isempty(file)
45+
46+
targetFile = [datestr(now, 'yyyymmddHHMM') ...
47+
'_sub-', subID, ...
48+
'_task-', opt.taskName, ...
49+
'_' action '.png'];
50+
51+
movefile( ...
52+
file, ...
53+
fullfile(figureDir, targetFile));
54+
55+
imgNb = imgNb + 1;
56+
57+
end
58+
59+
end
60+
61+
end

src/utils/setGraphicWindow.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
% (C) Copyright 2019 CPP BIDS SPM-pipeline developpers
2+
3+
function [interactiveWindow, graphWindow, cmdLine] = setGraphicWindow()
4+
[interactiveWindow, graphWindow, cmdLine] = spm('FnUIsetup');
5+
end

src/workflows/bidsSegmentSkullStrip.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
% (C) Copyright 20120 CPP BIDS SPM-pipeline developpers
1+
% (C) Copyright 2020 CPP BIDS SPM-pipeline developpers
22

33
function bidsSegmentSkullStrip(opt)
44
%

src/workflows/bidsSpatialPrepro.m

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ function bidsSpatialPrepro(opt)
2323
end
2424
opt = loadAndCheckOptions(opt);
2525

26+
setGraphicWindow();
27+
2628
% load the subjects/Groups information and the task name
2729
[group, opt, BIDS] = getData(opt);
2830

@@ -43,14 +45,11 @@ function bidsSpatialPrepro(opt)
4345

4446
printProcessingSubject(groupName, iSub, subID);
4547

46-
% identify sessions for this subject
47-
sessions = getInfo(BIDS, subID, opt, 'Sessions');
48-
4948
matlabbatch = setBatchSelectAnat(matlabbatch, BIDS, opt, subID);
5049
opt.orderBatches.selectAnat = 1;
5150

5251
action = [];
53-
if strcmp(opt.space, 'individual')
52+
if strcmp(opt.space, 'individual')
5453
action = 'realignUnwarp';
5554
end
5655
[matlabbatch, voxDim] = setBatchRealign(matlabbatch, BIDS, subID, opt, action);
@@ -79,6 +78,12 @@ function bidsSpatialPrepro(opt)
7978

8079
spm_jobman('run', matlabbatch);
8180

81+
imgNb = copyGraphWindownOutput(opt, subID, 'realign');
82+
if strcmp(opt.space, 'individual')
83+
imgNb = copyGraphWindownOutput(opt, subID, 'unwarp', imgNb);
84+
end
85+
imgNb = copyGraphWindownOutput(opt, subID, 'func2anatCoreg', imgNb);
86+
8287
end
8388
end
8489

0 commit comments

Comments
 (0)