From 3959b9790c32326951271f10a5413d050b64e830 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Sat, 31 Oct 2020 21:16:08 +0100 Subject: [PATCH] fix graphic windows set up when in command line mode --- demos/MoAE/MoAEpilot_run.m | 5 ++--- src/reports/copyGraphWindownOutput.m | 14 +++++++------- src/utils/setGraphicWindow.m | 16 +++++++++++++++- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/demos/MoAE/MoAEpilot_run.m b/demos/MoAE/MoAEpilot_run.m index f427d365..1d9a065f 100644 --- a/demos/MoAE/MoAEpilot_run.m +++ b/demos/MoAE/MoAEpilot_run.m @@ -19,9 +19,8 @@ WD = fileparts(mfilename('fullpath')); % we add all the subfunctions that are in the sub directories -addpath(fullfile(WD, '..')); -addpath(genpath(fullfile(WD, '..', 'src'))); -addpath(genpath(fullfile(WD, '..', 'lib'))); +addpath(genpath(fullfile(WD, '..', '..', 'src'))); +addpath(genpath(fullfile(WD, '..', '..', 'lib'))); %% Set options opt = MoAEpilot_getOption(); diff --git a/src/reports/copyGraphWindownOutput.m b/src/reports/copyGraphWindownOutput.m index 775d7ea3..af716fc9 100644 --- a/src/reports/copyGraphWindownOutput.m +++ b/src/reports/copyGraphWindownOutput.m @@ -24,15 +24,15 @@ % % 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 < 4 || isempty(imgNb) - imgNb = 1; - end + if nargin < 3 || isempty(action) + action = ''; + end - if nargin < 3 || isempty(action) - action = ''; - end + if ~spm('CmdLine') && ~isOctave figureDir = fullfile(opt.derivativesDir, ['sub-' subID], 'figures'); if ~exist(figureDir, 'dir') diff --git a/src/utils/setGraphicWindow.m b/src/utils/setGraphicWindow.m index 2c17ec0c..1aedfc36 100644 --- a/src/utils/setGraphicWindow.m +++ b/src/utils/setGraphicWindow.m @@ -1,5 +1,19 @@ % (C) Copyright 2019 CPP BIDS SPM-pipeline developpers function [interactiveWindow, graphWindow, cmdLine] = setGraphicWindow() - [interactiveWindow, graphWindow, cmdLine] = spm('FnUIsetup'); + + interactiveWindow = []; + graphWindow = []; + cmdLine = true; + + if ~spm('CmdLine') && ~isOctave + + try + [interactiveWindow, graphWindow, cmdLine] = spm('FnUIsetup'); + catch + warning('Could not open a graphic window. No figure will be created.'); + end + + end + end