aramis-lab / clinica

Software platform for clinical neuroimaging studies
http://www.clinica.run/
Other
224 stars 75 forks source link

Urgent Assistance Required for Runtime Error in Clinica Version 07.6 with MATLAB 2024a and SPM12 #1245

Open mtmmu88 opened 3 months ago

mtmmu88 commented 3 months ago

Dear Clinica Support Team, I am experiencing an issue while using Clinica version 07.6 with MATLAB version 2024a and SPM12. When I run the following command: clinica run statistics-volume /Users/mac/Desktop/test_clinica GROUPLABEL001 t1-volume /Users/mac/Desktop/test_001/test.tsv age I encounter the following error: Traceback (most recent call last): File "/Users/mac/miniconda3/envs/clinica/bin/clinica", line 8, in sys.exit(main()) File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/clinica/cmdline.py", line 92, in main cli() File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/click/core.py", line 1157, in call return self.main(args, kwargs) File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/click/core.py", line 783, in invoke return __callback(args, **kwargs) File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/clinica/pipelines/statistics_volume/statistics_volume_cli.py", line 160, in cli else pipeline.run() File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/clinica/pipelines/engine.py", line 353, in run raise e File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/clinica/pipelines/engine.py", line 334, in run exec_graph = Workflow.run(self, plugin, plugin_args, update_hash) File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/nipype/pipeline/engine/workflows.py", line 638, in run runner.run(execgraph, updatehash=updatehash, config=self.config) File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/nipype/pipeline/plugins/base.py", line 178, in run self._clean_queue(jobid, graph, result=result) File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/nipype/pipeline/plugins/base.py", line 256, in _clean_queue raise RuntimeError("".join(result["traceback"])) RuntimeError: Traceback (most recent call last): File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node result["result"] = node.run(updatehash=updatehash) File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run result = self._run_interface(execute=True) File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface return self._run_command(execute) File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/nipype/pipeline/engine/nodes.py", line 771, in _run_command raise NodeExecutionError(msg) nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node run_spm_model_creation.

Traceback: Traceback (most recent call last): File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/nipype/interfaces/base/core.py", line 397, in run runtime = self._run_interface(runtime) File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/nipype/interfaces/utility/wrappers.py", line 142, in _run_interface out = function_handle(**args) File "", line 37, in run_m_script File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/clinica/pipelines/statistics_volume/statistics_volume_utils.py", line 534, in _run_matlab_script_with_matlab matlab.run() File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/nipype/interfaces/base/core.py", line 397, in run runtime = self._run_interface(runtime) File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/nipype/interfaces/matlab.py", line 164, in _run_interface self.raise_exception(runtime) File "/Users/mac/miniconda3/envs/clinica/lib/python3.9/site-packages/nipype/interfaces/base/core.py", line 685, in raise_exception raise RuntimeError( RuntimeError: Command: /Applications/MATLAB_R2024a.app/bin/matlab -logfile /private/var/folders/47/g6mvtbc979x817gm8msmvl40000gn/T/tmpnajpkls/statistics-volume/run_spm_model_creation/matlab_output.log -nodesktop -nosplash -r "addpath('/private/var/folders/47/g6mvtbc979x817gm8msmvl40000gn/T/tmpnajpkls/statistics-volume/run_spm_model_creation');pyscript;exit" Standard error: MATLAB code threw an exception: No executable modules, but still unresolved dependencies or incomplete module inputs. File:/Users/mac/Desktop/spm12/spm_jobman.m Name:/Users/mac/Desktop/spm12/spm_jobman.m Line:47 File:private/var/folders/47/g6mvtbc979x817gm8msmvl40000gn/T/tmpnajpkls/statistics-volume/model_creation/current_model_creation.m Name:/private/var/folders/47/g6mvtbc979x817gm8msmvl40000gn/T/tmpnajpkls/statistics-volume/run_spm_model_creation/pyscript.m Line:102 File:ill_run_job Name:spm_jobman Line:99 File:urrent_model_creation Name:pyscript Line:472 File:÷ Name:" Line:8 2024-07-27 19:12:42.631 MATLAB_maci64[1338:21273] CoreText note: Client requested name ".SFNS-Regular", it will get TimesNewRomanPSMT rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:]. 2024-07-27 19:12:42.631 MATLAB_maci64[1338:21273] CoreText note: Set a breakpoint on CTFontLogSystemFontNameRequest to debug. 2024-07-27 19:12:42.635 MATLAB_maci64[1338:21273] CoreText note: Client requested name ".SFNS-Bold", it will get TimesNewRomanPSMT rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:]. 2024-07-27 19:12:42.641 MATLAB_maci64[1338:21273] CoreText note: Client requested name ".SFNS-Regular", it will get TimesNewRomanPSMT rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:]. 2024-07-27 19:12:42.641 MATLAB_maci64[1338:21273] CoreText note: Client requested name ".SFNS-Bold", it will get TimesNewRomanPSMT rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:]. Return code: 0 I have been struggling with this issue for over three days and have not found a solution. Could you please assist me in resolving this problem?

Thank you for your support.

Best regards

NicolasGensollen commented 3 months ago

Hi,

Thanks for reporting. In order to run this pipeline, you need to have either Matlab and SPM12 installed or SPM12standalone. By a quick look at your stack trace, I believe you are relying on the first option. Did you check that Matlab and SPM12 were correctly installed on your machine before trying to run the pipeline ? A first check would be to verify that the matlab executable is present in your PATH and that the SPM_HOME environment variable is set correctly. You should have something similar to this:

$ which matlab
/Applications/MATLAB_R2019b.app/bin/matlab
$ echo $SPM_HOME
/Users/ci-aramis-clinica/third_party/install/spm12/r7771

If this works, then you probably should try to open Matlab and run SPM12 commands. Are you able to do that without any error ?

Best

mtmmu88 commented 3 months ago

pypeline.log Hi,

Thank you for your previous response. Over the past few days, I have tried various methods to resolve the issue, including testing different versions of Clinica, Matlab, and SPM. Here is a summary of my attempts and current configuration: 1.Clinica Versions Tested: Clinica 0.76 Clinica 0.83 2.Matlab Versions Tested: Matlab 2021b Matlab 2024a 3.SPM Versions Tested: Corresponding SPM versions for the Matlab versions above 4.Machines Tested On: Multiple machines with the same issue. 5.Current System Configuration: Operating System: Linux Ubuntu 22.04 64-bit Current Clinica Version: 0.76 and 0.83 Current Matlab Version: 2021b Environment Variables: export MATLAB_HOME="/usr/local/MATLAB/R2021b/bin/" export PATH=${MATLAB_HOME}:${PATH} export MATLABCMD="${MATLAB_HOME}/matlab" export SPM_HOME="/home/mtmmu/spm12" export PATH=${SPM_HOME}:${PATH} 6.Issues Faced: With Clinica 0.76: The machine defaults to using SPM_HOME. If SPM_HOME is not set, it results in an error even if spm_standalone is used. After setting SPM_HOME, various other errors occur. With Clinica 0.83: It defaults to calling Matlab. However, after starting Matlab, it does not proceed further to execute subsequent steps involving SPM. I have attached the logs from my latest attempts for your reference. Below is an example of the command and the resulting log: clinica run statistics-volume 7.Directory Structure: My test directory is structured as follows: image Could you please provide clear guidance on the following points: 1.Correct setup and configuration of environment variables for Matlab and SPM. 2.Steps to ensure Clinica correctly recognizes and uses the specified Matlab and SPM installations. 3.Any additional configurations or steps required to resolve the current issues. Thank you for your assistance. Best regards, mtmmu88

NicolasGensollen commented 3 months ago

@mtmmu88 thanks for the information. In order to understand where things are breaking we need to verify that the assumptions of the clinica pipeline are correct. That is:

So, the first thing is to decide whether you want to rely on Matlab+SPM12 or on SPM12-standalone. You then need to install those and verify that they are working properly. This is a crucial point because if this isn't the case, then there is no way the clinica pipeline will run. I wasn't able to understand from your previous message whether you were able to have a working installation of SPM12 on your machine. Is it the case ?

If SPM12 is working, then I suggest that you use Clinica 0.8.3 which is the latest released version of Clinica. Some work has been done recently to clarify the different checks that Clinica is doing on the environment variables related to SPM and Matlab. The documentation of Clinica explains how to configure these depending on whether you chose to rely on Matlab+SPM or on SPM-standalone: https://aramislab.paris.inria.fr/clinica/docs/public/dev/Third-party/#spm12

At this point, you should be able to start the statistic-volume pipeline without getting an error related to the installation of SPM12 or Matlab.

Could you make sure that all these steps are working correctly ?

If they do and you still get an error (please copy it here then), then it probably means that there is something wrong with how the clinica pipeline interacts with your installation of SPM and we will need to investigate further to understand why.

mtmmu88 commented 3 months ago

Hi,

Thank you for your previous guidance. I have taken additional steps to verify the installation and configuration, but the issue persists. Here are the detailed steps and results:

Installation Choice: I have decided to use Matlab+SPM12 for the pipeline.

SPM12 Working Status: I have successfully installed Matlab 2022b and SPM12 on my machine. I can confirm that SPM12 is working properly with Matlab. Here are the steps and results of my verification: I set the environment variables: export MATLAB_HOME="/usr/local/MATLAB/R2022b/bin/" export PATH=${MATLAB_HOME}:${PATH} export MATLABCMD="${MATLAB_HOME}/matlab" export SPM_HOME="/home/mtmmu/spm12" export PATH=${SPM_HOME}:${PATH} I started Matlab and ran the following command: spm image The SPM12 GUI launched without any errors. Clinica Installation and Verification: I have installed Clinica versions 0.76 and 0.83. Running the Clinica pipeline, the screenshots are as follows: image Current Issue: Despite the above configurations, I am encountering issues when running the Clinica pipeline. Specifically: With Clinica 0.83, after running the following command, the process calls Matlab but then remains in the Matlab interface and does not proceed with subsequent steps: clinica run statistics-volume /home/mtmmu/Desktop/test_clinica GROUP01 t1-volume /home/mtmmu/Desktop/test_01.tsv group --n_procs 1 With Clinica 0.76, Matlab runs in the background and calls SPM, but then it encounters an error. The error log is as follows: clinica run statistics-volume /home/mtmmu/桌面/test_clinica GROUP01 t1-volume /home/mtmmu/桌面/test_01.tsv group --n_procs 1 2024-07-30 19:00:58,159:INFO:The pipeline will be run on the following 2 image(s): 2024-07-30 19:00:58,159:INFO: sub-ADNI002S4262 | ses-M060, 2024-07-30 19:00:58,159:INFO: sub-ADNI002S4270 | ses-M048, 2024-07-30 19:00:58,159:INFO:The pipeline will last a few minutes. Images generated by SPM will popup during the pipeline. 2024-07-30 19:00:58,159:INFO:Running pipeline for group-GROUP01 Traceback (most recent call last): File "/home/mtmmu/miniconda3/envs/clinica_0.7/bin/clinica", line 8, in sys.exit(main()) File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/clinica/cmdline.py", line 92, in main cli() File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/click/core.py", line 1157, in call return self.main(args, kwargs) File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/click/core.py", line 783, in invoke return __callback(args, **kwargs) File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/clinica/pipelines/statistics_volume/statistics_volume_cli.py", line 158, in cli pipeline.run(plugin="MultiProc", plugin_args={"n_procs": n_procs}) File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/clinica/pipelines/engine.py", line 353, in run raise e File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/clinica/pipelines/engine.py", line 334, in run exec_graph = Workflow.run(self, plugin, plugin_args, update_hash) File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/nipype/pipeline/engine/workflows.py", line 638, in run runner.run(execgraph, updatehash=updatehash, config=self.config) File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/nipype/pipeline/plugins/base.py", line 166, in run self._clean_queue(jobid, graph, result=result) File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/nipype/pipeline/plugins/base.py", line 244, in _clean_queue raise RuntimeError("".join(result["traceback"])) RuntimeError: Traceback (most recent call last): File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node result["result"] = node.run(updatehash=updatehash) File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 524, in run result = self._run_interface(execute=True) File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 642, in _run_interface return self._run_command(execute) File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 750, in _run_command raise NodeExecutionError( nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node run_spm_model_contrast.

Traceback (most recent call last): File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/nipype/interfaces/base/core.py", line 398, in run runtime = self._run_interface(runtime) File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/nipype/interfaces/utility/wrappers.py", line 142, in _run_interface out = function_handle(**args) File "", line 37, in run_m_script File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/clinica/pipelines/statistics_volume/statistics_volume_utils.py", line 534, in _run_matlab_script_with_matlab matlab.run() File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/nipype/interfaces/base/core.py", line 398, in run runtime = self._run_interface(runtime) File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/nipype/interfaces/matlab.py", line 164, in _run_interface self.raise_exception(runtime) File "/home/mtmmu/miniconda3/envs/clinica_0.7/lib/python3.10/site-packages/nipype/interfaces/base/core.py", line 686, in raise_exception raise RuntimeError( RuntimeError: Command: /usr/local/MATLAB/R2022b/bin/matlab -nosoftwareopengl -logfile /tmp/tmpye6t2bh5/statistics-volume/run_spm_model_contrast/matlab_output.log -nodesktop -nosplash -r "addpath('/tmp/tmpye6t2bh5/statistics-volume/run_spm_model_contrast');pyscript;exit" Standard output:

                        < M A T L A B (R) >
              Copyright 1984-2022 The MathWorks, Inc.
         R2022b Update 9 (9.13.0.2553342) 64-bit (glnxa64)
                           March 13, 2024

要开始,请键入 doc。 有关产品信息,请访问 www.mathworks.com。

Executing pyscript at 30-Jul-2024 19:01:47: Executing pyscript at 30-Jul-2024 19:01:47:

MATLAB 版本: 9.13.0.2553342 (R2022b) Update 9 MATLAB 许可证编号: 41183105 操作系统: Linux 6.5.0-44-generic #44~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Jun 18 14:36:16 UTC 2 x86_64 Java 版本: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode

MATLAB 版本 9.13 (R2022b) Statistical Parametric Mapping 版本 7771 (SPM12)


30-Jul-2024 19:01:51 - Running job #1

30-Jul-2024 19:01:51 - Running 'Contrast Manager'

SPM12: spm_contrasts.m 19:01:51 - 30/07/2024

Contrasts folder : ./2_sample_t_test Deleting contrasts : ...done -1 1 0 0 <- !invalid contrast 30-Jul-2024 19:01:51 - Failed 'Contrast Manager' 错误使用 spm_run_con Error in contrast specification In file "/home/mtmmu/spm12/config/spm_run_con.m" (v7738), function "spm_run_con" at line 254. The following modules did not run: Failed: Contrast Manager Standard error: MATLAB code threw an exception: Job execution failed. The full log of this run can be found in MATLAB command window, starting with the lines (look for the line showing the exact #job as displayed in this error message)


Running job #1

File: Name:MATLABbatch system Line:0 Return code: 0

While Matlab and SPM work independently without issues, the Clinica pipeline fails to run correctly. Could you please provide further guidance on resolving this issue? Specifically, why does Matlab not proceed with subsequent steps when using Clinica 0.83? Thank you for your assistance. Best regards, mtmmu88

mtmmu88 commented 3 months ago

Hello,

Thank you for the information provided earlier. I am experiencing difficulties with the Clinica pipeline and need assistance in verifying that all the necessary components are correctly installed and configured. Here are the steps I have taken so far and the issues I am encountering:

Installation Check:

I have attempted to use both Matlab+SPM12 and SPM12-standalone to ensure compatibility with Clinica. I have ensured that all environment variables required by Clinica are correctly set. SPM12 Installation:

Despite my efforts, I was unable to determine from my previous attempts whether SPM12 is correctly installed and functioning. Could you confirm the correct installation steps or provide guidance on verifying a successful SPM12 installation? Clinica Version:

I have installed Clinica version 0.8.3, as it is the latest release. However, upon running the statistic-volume pipeline with this version, Matlab opens but does not proceed with executing the subsequent commands. Older Version Attempt:

I also tried using Clinica version 0.7.6, but it continues to show the same error as mentioned in my previous message. System Reinstallation:

To eliminate the possibility of a system-related issue, I reinstalled my Linux operating system. After reinstalling various versions of Matlab and SPM, the problem persists. The detailed Clinica documentation on configuring environment variables based on Matlab+SPM or SPM-standalone has been followed: Clinica Documentation on SPM12.

At this point, I am still unable to run the Clinica pipeline without encountering errors related to SPM12 or Matlab installation. Could you please ensure that all these steps are correctly executed and guide me through resolving this issue? I appreciate your assistance in resolving this issue as it has been a major obstacle for my work.

Thank you very much.

Best regards, mtmmu88

NicolasGensollen commented 3 months ago

Hi @mtmmu88

I tried to reproduce your issue without any success so far. Unfortunately, it is really difficult to make a diagnostic without a reproducer. I suggest you try installing SPM standalone with the matlab MCR (described in the docs) and then run the pipeline with clinica 0.8.3.

Something different that you can also try is to grab the matlab scripts generated by the pipeline and try to run them on Matlab. These files should be located in the working directory of the pipeline. For example, the model creation script should be there:

<YOUR_WORKING_DIR>/StatisticsVolume/model_creation/current_model_creation.m
mtmmu88 commented 2 months ago

I previously reported an issue with running the Clinica pipeline using Clinica version 07.6 with MATLAB 2024a and SPM12. After extensive troubleshooting and guidance from the support team, I have successfully resolved the issue.

Resolution:

Clinica Version: Updated to Clinica 0.8.3. SPM12 Version: Switched to using SPM12 Standalone instead of the MATLAB-dependent version. Data Reorganization: Reviewed and restructured the data directory and ensured proper alignment with the pipeline requirements. Outcome:

With the Clinica 0.8.3 version and the SPM12 Standalone, the pipeline is now running successfully without errors. I appreciate the patience and detailed guidance provided by the support team throughout this process.

Acknowledgment:

Thank you for your continuous support and the detailed instructions which were crucial in resolving this issue.

Best regards, mtmmu88

NicolasGensollen commented 2 months ago

@mtmmu88 I'm glad to hear you were able to successfully run the pipeline with SPM-standalone. 👍

Best, Nicolas