M40V / populse_mia

Multiparametric Image Analysis
Other
0 stars 0 forks source link

Mia crashes when running a pipeline and 'use SPM' is not checked #93

Open M40V opened 5 years ago

M40V commented 5 years ago

Issue by BlancaNietoPetinal Tuesday Jun 18, 2019 at 10:43 GMT _Originally opened as https://github.com/populse/populse_mia/issues/93_


Describe the bug MIA tries to run pipelines even if Matlab and SPM are not configured in the preferences. However, when doing so, MIA crashes.

An unconfigured SPM in the preferences can occur, when unchecking the "Use Matlab" checkbox after enabling SPM. In this case, the "Use SPM" checkbox is disabled, and not re-enabled automatically if Matlab is enabled again.

Generated error

________________________________________________________________________________
[Process] Calling nipype.interfaces.spm.preprocess.Smooth...
nipype.interfaces.spm.preprocess.Smooth(output_directory=/home/nietob/Data/mia/projects/test/scripts, synchronize=0, fwhm=[3.0, 3.0, 3.0], in_files=['/home/nietob/Data/mia/projects/test/data/raw_data/MAP-VS-704-599566309-2019-04-05_09-39-09-00-3D_pCASL_singleshot-3D_pCASL_singleshot-.nii'], matlab_cmd=/usr/local/MATLAB/R2019a/bin/matlab, mfile=True, out_prefix=s, use_mcr=False, use_v8struct=True)

Exception hooking in progress ...

Clean up before closing mia done ...

Traceback (most recent call last):
  File "/home/nietob/Code/Populse_mia/populse_mia/python/populse_mia/user_interface/pipeline_manager/pipeline_manager_tab.py", line 1465, in run
    study_config.run(pipeline, verbose=1)
  File "/home/nietob/.local/lib/python3.6/site-packages/capsul/study_config/study_config.py", line 414, in run
    verbose)
  File "/home/nietob/.local/lib/python3.6/site-packages/capsul/study_config/study_config.py", line 471, in _run
    **kwargs)
  File "/home/nietob/.local/lib/python3.6/site-packages/capsul/study_config/run.py", line 102, in run_process
    returncode = process_instance._run_process()
  File "/home/nietob/.local/lib/python3.6/site-packages/capsul/process/process.py", line 1240, in _run_process
    results = self._nipype_interface.run()
  File "/home/nietob/.local/lib/python3.6/site-packages/nipype/interfaces/base/core.py", line 375, in run
    runtime = self._run_interface(runtime)
  File "/home/nietob/.local/lib/python3.6/site-packages/nipype/interfaces/spm/base.py", line 376, in _run_interface
    results = self.mlab.run()
  File "/home/nietob/.local/lib/python3.6/site-packages/nipype/interfaces/base/core.py", line 375, in run
    runtime = self._run_interface(runtime)
  File "/home/nietob/.local/lib/python3.6/site-packages/nipype/interfaces/matlab.py", line 170, in _run_interface
    self.raise_exception(runtime)
  File "/home/nietob/.local/lib/python3.6/site-packages/nipype/interfaces/base/core.py", line 695, in raise_exception
    ).format(**runtime.dictcopy()))
RuntimeError: Command:
/usr/local/MATLAB/R2019a/bin/matlab -nodesktop -nosplash -singleCompThread -r "addpath('/home/nietob/Data/mia/projects/test/scripts');pyscript_smooth;exit"
Standard output:

                                                                              < M A T L A B (R) >
                                                                    Copyright 1984-2019 The MathWorks, Inc.
                                                               R2019a Update 2 (9.6.0.1114505) 64-bit (glnxa64)
                                                                                  May 1, 2019

To get started, type doc.
For product information, visit www.mathworks.com.

The Window Command log is currently saved in ~/Documents/MATLAB/diaryWindowCommand file. Purge sometimes the diaryWindowCommand file in MATLAB directory.
- diary off: suspends the diary.
- diary on: resumes diary mode.

By default at start up a debugging option is launched producing a breakpoint and pause execution if a run-time error occurs.
- For stop this option: dbclear all.
- For start this option: dbstop if error.
- For known the current option: dbstatus.
Executing pyscript_smooth at 18-Jun-2019 12:15:32:
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.6.0.1114505 (R2019a) Update 2
MATLAB License Number: 100877
Operating System: Linux 4.15.0-51-generic #55-Ubuntu SMP Wed May 15 14:27:21 UTC 2019 x86_64
Java Version: Java 1.8.0_181-b13 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB                                                Version 9.6         (R2019a)
Deep Learning Toolbox                                 Version 12.1        (R2019a)
Image Processing Toolbox                              Version 10.4        (R2019a)
MATLAB Compiler                                       Version 7.0.1       (R2019a)
MATLAB Compiler SDK                                   Version 6.6.1       (R2019a)
Optimization Toolbox                                  Version 8.3         (R2019a)
Parallel Computing Toolbox                            Version 7.0         (R2019a)
Signal Processing Toolbox                             Version 8.2         (R2019a)
Statistical Parametric Mapping                        Version 7487        (SPM12) 
Statistics and Machine Learning Toolbox               Version 11.5        (R2019a)

Standard error:
MATLAB code threw an exception:
Cannot CD to /home/nietob/Data/mia/projects/test/scripts/<undefined> (Name is nonexistent or not a directory).
File:/home/nietob/Data/mia/projects/test/scripts/pyscript_smooth.m
Name:pyscript_smooth
Line:4
Return code: 0
QObject::~QObject: Timers cannot be stopped from another thread
Segmentation fault (core dumped)

Notice that the option "paths=['/home/nietob/spm12']" is missing from the call to nipype.interfaces.spm.preprocess.Smooth.

To Reproduce Steps to reproduce the behavior:

  1. Open a project
  2. In Preferences > Pipeline uncheck "Use Matlab" and check it again. The "Use SPM" checkbox got disabled in the process.
  3. Click on "OK".
  4. Configure a simple pipeline with an SPM module like smooth. Initialize and run it.
  5. MIA crashes.

Expected behavior MIA should open an error dialog, informing the user that SPM and/or Matlab needs to be enabled in the preferences. In the preferences dialog, maybe SPM should not be automatically disabled when disabling Matlab (or it should be automatically re-enabled when it was automatically disabled before).

Desktop (please complete the following information):

M40V commented 5 years ago

Comment by M40V Tuesday Jun 18, 2019 at 19:48 GMT


This functionnality will be fully incorporated when we will shift to the capsul engine. Processes will have requirements and it will be mandatory to have these requirements enabled to initialize and run the pipeline.

Currently we are checking during the initialization if the processes are from nipype (pipeline_manager_tab.py), we could add a condition to stop the initialization if SPM is not correctly defined in the config.yml. It will resolve this issue before the shift to the capsul engine.

M40V commented 5 years ago

Comment by servoz Tuesday Jun 25, 2019 at 15:42 GMT


It is very desirable that the mia version in production never crashes.

We don't know yet when the capsul_engine will definitely be used in mia and I confess that the scope of action stay a little bit confuse (the capsul engine is still in the process of being written by the capsul team).

So, I think we need to make a little change ASAP to fix this possibility of a crash of mia

M40V commented 5 years ago

Comment by M40V Thursday Jun 27, 2019 at 16:10 GMT


The verification will occur during the initialization of the pipeline. This verification can occur at different points, depending on whether MIA should always run with SPM or if SPM should be configured only when specific processes require it. We can then inform the user that the pipeline wasn't initialized with the statusbar and an alert. Currently nothing forbids an user to run a pipeline, even if it wasn't initialized correctly, should we add a verification to avoid these behaviors ?

M40V commented 5 years ago

Comment by servoz Friday Jun 28, 2019 at 08:31 GMT


As we have seen, it may be considered to merge the initialisation and the launch of the pipeline run (currently, users must click on an Initialise button and a Run button), which would solve the problem of a launch without having initialised. On the other hand, it might be very desirable for the user to know before the actual start of all processes, if everything goes well (which can be crucial in the case of iteration, that can take a long time). A complete initialisation of the entire pipeline through all iterated tags could therefore be a real improvement.

M40V commented 5 years ago

Comment by M40V Wednesday Jul 31, 2019 at 15:02 GMT


There is two parts to this issue. The first part is about the configuration of Matlab and SPM in Mia preferences and the second part is during the initialization if SPM or Matlab are used by the brick (check if Nipype is used or if user bricks use spm/matlab).