nipy / nipype

Workflows and interfaces for neuroimaging packages
https://nipype.readthedocs.org/en/latest/
Other
746 stars 529 forks source link

Interface Normalize failed to run. #1900

Open ankita940 opened 7 years ago

ankita940 commented 7 years ago

Hello, I am new to nipye, I am running a pipeline on fmri auditory dataset but its giving error on nomalization(using spm.Normalize()) .

thank you,

I am attaching the crash file produced -

File: crash-20170322-023831-ankita-normalize_struc.a0-074e2843-d6da-447a-b0ca-8b9b55c4527f.pklz
Node: level1.firstlevel.preproc.normalize_struc.a0
Working directory: /home/ankita/preprocess/spm_auditory_tutorial/workingdir/level1/firstlevel/preproc/_subject_id_M00223/normalize_struc

Node inputs:

DCT_period_cutoff = <undefined>
affine_regularization_type = <undefined>
apply_to_files = <undefined>
ignore_exception = False
jobtype = write
matlab_cmd = <undefined>
mfile = True
nonlinear_iterations = <undefined>
nonlinear_regularization = <undefined>
out_prefix = w
parameter_file = /home/ankita/preprocess/spm_auditory_tutorial/workingdir/level1/firstlevel/preproc/_subject_id_M00223/normalize_struc/sM00223_002_seg_sn.mat
paths = <undefined>
source = <undefined>
source_image_smoothing = <undefined>
source_weight = <undefined>
template = <undefined>
template_image_smoothing = <undefined>
template_weight = <undefined>
use_mcr = <undefined>
use_v8struct = True
write_bounding_box = <undefined>
write_interp = <undefined>
write_preserve = <undefined>
write_voxel_sizes = <undefined>
write_wrap = <undefined>

Traceback: 
Traceback (most recent call last):
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/pipeline/plugins/linear.py", line 43, in run
    node.run(updatehash=updatehash)
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 366, in run
    self._run_interface()
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 476, in _run_interface
    self._result = self._run_command(execute)
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 607, in _run_command
    result = self._interface.run()
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/interfaces/base.py", line 1085, in run
    runtime = self._run_wrapper(runtime)
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/interfaces/base.py", line 1033, in _run_wrapper
    runtime = self._run_interface(runtime)
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/interfaces/spm/base.py", line 323, in _run_interface
    results = self.mlab.run()
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/interfaces/base.py", line 1085, in run
    runtime = self._run_wrapper(runtime)
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/interfaces/base.py", line 1728, in _run_wrapper
    runtime = self._run_interface(runtime)
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/interfaces/matlab.py", line 152, in _run_interface
    self.raise_exception(runtime)
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/interfaces/base.py", line 1686, in raise_exception
    **runtime.dictcopy()))
RuntimeError: Command:
matlab -nodesktop -nosplash -nodesktop -nosplash -singleCompThread -r "addpath('/home/ankita/preprocess/spm_auditory_tutorial/workingdir/level1/firstlevel/preproc/_subject_id_M00223/normalize_struc');pyscript_normalize;exit"
Standard output:
MATLAB is selecting SOFTWARE OPENGL rendering.

                            < M A T L A B (R) >
                  Copyright 1984-2016 The MathWorks, Inc.
                   R2016b (9.1.0.441655) 64-bit (glnxa64)
                             September 7, 2016

To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.

Executing pyscript_normalize at 22-Mar-2017 02:38:17:
----------------------------------------------------------------------------------------------------
MATLAB Version: 9.1.0.441655 (R2016b)
MATLAB License Number: 40480989
Operating System: Linux 3.16.0-60-generic #80~14.04.1-Ubuntu SMP Wed Jan 20 13:37:48 UTC 2016 x86_64
Java Version: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
----------------------------------------------------------------------------------------------------
MATLAB                                                Version 9.1         (R2016b)
Simulink                                              Version 8.8         (R2016b)
Antenna Toolbox                                       Version 2.1         (R2016b)
Audio System Toolbox                                  Version 1.1         (R2016b)
Bioinformatics Toolbox                                Version 4.7         (R2016b)
Communications System Toolbox                         Version 6.3         (R2016b)
Computer Vision System Toolbox                        Version 7.2         (R2016b)
Control System Toolbox                                Version 10.1        (R2016b)
Curve Fitting Toolbox                                 Version 3.5.4       (R2016b)
DSP System Toolbox                                    Version 9.3         (R2016b)
Database Toolbox                                      Version 7.0         (R2016b)
Embedded Coder                                        Version 6.11        (R2016b)
Filter Design HDL Coder                               Version 3.1         (R2016b)
Fixed-Point Designer                                  Version 5.3         (R2016b)
Fuzzy Logic Toolbox                                   Version 2.2.24      (R2016b)
Global Optimization Toolbox                           Version 3.4.1       (R2016b)
HDL Coder                                             Version 3.9         (R2016b)
HDL Verifier                                          Version 5.1         (R2016b)
Image Acquisition Toolbox                             Version 5.1         (R2016b)
Image Processing Toolbox                              Version 9.5         (R2016b)
Instrument Control Toolbox                            Version 3.10        (R2016b)
LTE System Toolbox                                    Version 2.3         (R2016b)
MATLAB Coder                                          Version 3.2         (R2016b)
MATLAB Report Generator                               Version 5.1         (R2016b)
Mapping Toolbox                                       Version 4.4         (R2016b)
Model Predictive Control Toolbox                      Version 5.2.1       (R2016b)
Neural Network Toolbox                                Version 9.1         (R2016b)
Optimization Toolbox                                  Version 7.5         (R2016b)
Parallel Computing Toolbox                            Version 6.9         (R2016b)
Partial Differential Equation Toolbox                 Version 2.3         (R2016b)
Phased Array System Toolbox                           Version 3.3         (R2016b)
RF Toolbox                                            Version 3.1         (R2016b)
Robotics System Toolbox                               Version 1.3         (R2016b)
Robust Control Toolbox                                Version 6.2         (R2016b)
Signal Processing Toolbox                             Version 7.3         (R2016b)
SimRF                                                 Version 5.1         (R2016b)
Simscape                                              Version 4.1         (R2016b)
Simscape Driveline                                    Version 2.11        (R2016b)
Simscape Electronics                                  Version 2.10        (R2016b)
Simscape Multibody                                    Version 4.9         (R2016b)
Simulink 3D Animation                                 Version 7.6         (R2016b)
Simulink Control Design                               Version 4.4         (R2016b)
Stateflow                                             Version 8.8         (R2016b)
Statistical Parametric Mapping                        Version 6906        (SPM12) 
Statistics and Machine Learning Toolbox               Version 11.0        (R2016b)
Symbolic Math Toolbox                                 Version 7.1         (R2016b)
System Identification Toolbox                         Version 9.5         (R2016b)
WLAN System Toolbox                                   Version 1.2         (R2016b)
Wavelet Toolbox                                       Version 4.17        (R2016b)
SPM version: SPM12 Release: 6906
SPM path: /usr/local/MATLAB/R2016b/toolbox/spm12/spm.m
Conversion Normalise:Write -> Old Normalise:Write

Standard error:
MATLAB code threw an exception:
No executable modules, but still unresolved dependencies or incomplete module inputs.
File:/usr/local/MATLAB/R2016b/toolbox/spm12/spm_jobman.m
Name:/usr/local/MATLAB/R2016b/toolbox/spm12/spm_jobman.m
Line:47
File:home/ankita/preprocess/spm_auditory_tutorial/workingdir/level1/firstlevel/preproc/_subject_id_M00223/normalize_struc/pyscript_normalize.m
Name:fill_run_job
Line:115
File:pm_jobman
Name:pyscript_normalize
Line:461
File:\xc3\xb7
Name:
Line:
Return code: 0
Interface MatlabCommand failed to run. 
Interface Normalize failed to run. 
mgxd commented 7 years ago

I believe the script you're using is only compatible with SPM versions < 12. The workflow you are using is wrapping the old normalize function, while SPM12 is using a newer version of the function. @satra wdyt?

ankita940 commented 7 years ago

Hello, yeah I think its compatible with spm8 can you suggest changes which needs to be done in normalization in following script I am attaching.

#!/usr/bin/env python
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""
==========================
fMRI: SPM Auditory dataset
==========================

Introduction
============

The fmri_spm_auditory.py recreates the classical workflow described in the
`SPM8 manual <http://www.fil.ion.ucl.ac.uk/spm/doc/manual.pdf>`_ using auditory
dataset that can be downloaded from http://www.fil.ion.ucl.ac.uk/spm/data/auditory/::

    python fmri_spm_auditory.py

Import necessary modules from nipype."""

from builtins import range
from nipype.utils import NUMPY_MMAP
import nipype.interfaces.io as nio           # Data i/o
import nipype.interfaces.spm as spm          # spm
import nipype.interfaces.fsl as fsl          # fsl
import nipype.interfaces.matlab as mlab      # how to run matlab
import nipype.interfaces.fsl as fsl          # fsl
import nipype.interfaces.utility as util     # utility
import nipype.pipeline.engine as pe          # pypeline engine
import nipype.algorithms.modelgen as model   # model specification
import os                                    # system functions

"""

Preliminaries
-------------

"""

# Set the way matlab should be called
mlab.MatlabCommand.set_default_matlab_cmd("matlab -nodesktop -nosplash")
#mlab.MatlabCommand.set_default_paths('/home/ankita/spmsoft/spm12/spm.m')

"""
Setting up workflows
--------------------

In this tutorial we will be setting up a hierarchical workflow for spm
analysis. This will demonstrate how pre-defined workflows can be setup
and shared across users, projects and labs.

Setup preprocessing workflow
----------------------------

This is a generic preprocessing workflow that can be used by different analyses

"""

preproc = pe.Workflow(name='preproc')

"""We strongly encourage to use 4D files insteead of series of 3D for fMRI analyses
for many reasons (cleanness and saving and filesystem inodes are among them). However,
the the workflow presented in the SPM8 manual which this tutorial is based on
uses 3D files. Therefore we leave converting to 4D as an option. We are using `merge_to_4d`
variable, because switching between 3d and 4d requires some additional steps (explauned later on).
Use :class:`nipype.interfaces.fsl.Merge` to merge a series of 3D files along the time
dimension creating a 4d file.
"""

merge_to_4d =False

if merge_to_4d:
    merge = pe.Node(interface=fsl.Merge(), name="merge")
    merge.inputs.dimension = "t"

"""Use :class:`nipype.interfaces.spm.Realign` for motion correction
and register all images to the mean image.
"""

realign = pe.Node(interface=spm.Realign(), name="realign")

"""Use :class:`nipype.interfaces.spm.Coregister` to perform a rigid
body registration of the functional data to the structural data.
"""

coregister = pe.Node(interface=spm.Coregister(), name="coregister")
coregister.inputs.jobtype = 'estimate'

segment = pe.Node(interface=spm.Segment(), name="segment")

"""Uncomment the following line for faster execution
"""

# segment.inputs.gaussians_per_class = [1, 1, 1, 4]

"""Warp functional and structural data to SPM's T1 template using
:class:`nipype.interfaces.spm.Normalize`.  The tutorial data set
includes the template image, T1.nii.
"""

normalize_func = pe.Node(interface=spm.Normalize(), name="normalize_func")
normalize_func.inputs.jobtype = "write"

normalize_struc = pe.Node(interface=spm.Normalize(), name="normalize_struc")
normalize_struc.inputs.jobtype = "write"

"""Smooth the functional data using
:class:`nipype.interfaces.spm.Smooth`.
"""

smooth = pe.Node(interface=spm.Smooth(), name="smooth")

"""`write_voxel_sizes` is the input of the normalize interface that is recommended to be set to
the voxel sizes of the target volume. There is no need to set it manually since we van infer it from data
using the following function:
"""

def get_vox_dims(volume):
    import nibabel as nb
    from nipype.utils import NUMPY_MMAP
    if isinstance(volume, list):
        volume = volume[0]
    nii = nb.load(volume, mmap=NUMPY_MMAP)
    hdr = nii.header
    voxdims = hdr.get_zooms()
    return [float(voxdims[0]), float(voxdims[1]), float(voxdims[2])]

"""Here we are connecting all the nodes together. Notice that we add the merge node only if you choose
to use 4D. Also `get_vox_dims` function is passed along the input volume of normalise to set the optimal
voxel sizes.
"""

if merge_to_4d:
    preproc.connect([(merge, realign, [('merged_file', 'in_files')])])

preproc.connect([(realign, coregister, [('mean_image', 'target')]),
                 (coregister, segment, [('coregistered_source', 'data')]),
                 (segment, normalize_func, [('transformation_mat', 'parameter_file')]),
                 (segment, normalize_struc, [('transformation_mat', 'parameter_file'),
                                             ('modulated_input_image', 'apply_to_files'),
                                             (('modulated_input_image', get_vox_dims), 'write_voxel_sizes')]),
                 (realign, normalize_func, [('realigned_files', 'apply_to_files'),
                                            (('realigned_files', get_vox_dims), 'write_voxel_sizes')]),
                 (normalize_func, smooth, [('normalized_files', 'in_files')]),
                 ])

"""
Set up analysis workflow
------------------------

"""

l1analysis = pe.Workflow(name='analysis')

"""Generate SPM-specific design information using
:class:`nipype.interfaces.spm.SpecifyModel`.
"""

modelspec = pe.Node(interface=model.SpecifySPMModel(), name="modelspec")

"""Generate a first level SPM.mat file for analysis
:class:`nipype.interfaces.spm.Level1Design`.
"""

level1design = pe.Node(interface=spm.Level1Design(), name="level1design")
level1design.inputs.bases = {'hrf': {'derivs': [0, 0]}}

"""Use :class:`nipype.interfaces.spm.EstimateModel` to determine the
parameters of the model.
"""

level1estimate = pe.Node(interface=spm.EstimateModel(), name="level1estimate")
level1estimate.inputs.estimation_method = {'Classical': 1}

threshold = pe.Node(interface=spm.Threshold(), name="threshold")

"""Use :class:`nipype.interfaces.spm.EstimateContrast` to estimate the
first level contrasts specified in a few steps above.
"""

contrastestimate = pe.Node(interface=spm.EstimateContrast(), name="contrastestimate")

l1analysis.connect([(modelspec, level1design, [('session_info', 'session_info')]),
                    (level1design, level1estimate, [('spm_mat_file', 'spm_mat_file')]),
                    (level1estimate, contrastestimate, [('spm_mat_file', 'spm_mat_file'),
                                                        ('beta_images', 'beta_images'),
                                                        ('residual_image', 'residual_image')]),
                    (contrastestimate, threshold, [('spm_mat_file', 'spm_mat_file'),
                                                   ('spmT_images', 'stat_image')]),
                    ])

"""
Preproc + Analysis pipeline
---------------------------

"""

l1pipeline = pe.Workflow(name='firstlevel')
l1pipeline.connect([(preproc, l1analysis, [('realign.realignment_parameters',
                                            'modelspec.realignment_parameters')])])

"""Pluging in `functional_runs` is a bit more complicated, because model spec expects a list of `runs`.
Every run can be a 4D file or a list of 3D files. Therefore for 3D analysis we need a list of lists and
to make one we need a helper function.
"""

if merge_to_4d:
    l1pipeline.connect([(preproc, l1analysis, [('smooth.smoothed_files',
                                                'modelspec.functional_runs')])])
else:
    def makelist(item):
        return [item]
    l1pipeline.connect([(preproc, l1analysis, [(('smooth.smoothed_files', makelist),
                                                'modelspec.functional_runs')])])

"""
Data specific components
------------------------

In this tutorial there is only one subject `M00223`.

Below we set some variables to inform the ``datasource`` about the
layout of our data.  We specify the location of the data, the subject
sub-directories and a dictionary that maps each run to a mnemonic (or
field) for the run type (``struct`` or ``func``).  These fields become
the output fields of the ``datasource`` node in the pipeline.
"""

# Specify the location of the data downloaded from http://www.fil.ion.ucl.ac.uk/spm/data/auditory/
data_dir = os.path.abspath('/home/ankita/preprocess/MoAEpilot')
# Specify the subject directories
subject_list = ['M00223']
# Map field names to individual subject runs.
info = dict(func=[['f', 'subject_id', 'f', 'subject_id', list(range(16, 100))]],
            struct=[['s', 'subject_id', 's', 'subject_id', 2]])

infosource = pe.Node(interface=util.IdentityInterface(fields=['subject_id']), name="infosource")

"""Here we set up iteration over all the subjects. The following line
is a particular example of the flexibility of the system.  The
``datasource`` attribute ``iterables`` tells the pipeline engine that
it should repeat the analysis on each of the items in the
``subject_list``. In the current example, the entire first level
preprocessing and estimation will be repeated for each subject
contained in subject_list.
"""

infosource.iterables = ('subject_id', subject_list)

"""
Now we create a :class:`nipype.interfaces.io.DataGrabber` object and
fill in the information from above about the layout of our data.  The
:class:`nipype.pipeline.NodeWrapper` module wraps the interface object
and provides additional housekeeping and pipeline specific
functionality.
"""

datasource = pe.Node(interface=nio.DataGrabber(infields=['subject_id'],
                                               outfields=['func', 'struct']),
                     name='datasource')
datasource.inputs.base_directory = data_dir
datasource.inputs.template = '%s%s/%s%s_%03d.img'
datasource.inputs.template_args = info
datasource.inputs.sort_filelist = True

"""
Experimental paradigm specific components
-----------------------------------------

Here we create a structure that provides information
about the experimental paradigm. This is used by the
:class:`nipype.interfaces.spm.SpecifyModel` to create the information
necessary to generate an SPM design matrix.
"""

from nipype.interfaces.base import Bunch
subjectinfo = [Bunch(conditions=['Task'],
                     onsets=[list(range(6, 84, 12))],
                     durations=[[6]])]

"""Setup the contrast structure that needs to be evaluated. This is a
list of lists. The inner list specifies the contrasts and has the
following format - [Name,Stat,[list of condition names],[weights on
those conditions]. The condition names must match the `names` listed
in the `subjectinfo` function described above.
"""

cont1 = ('active > rest', 'T', ['Task'], [1])
contrasts = [cont1]

# set up node specific inputs
modelspecref = l1pipeline.inputs.analysis.modelspec
modelspecref.input_units = 'scans'
modelspecref.output_units = 'scans'
modelspecref.time_repetition = 7
modelspecref.high_pass_filter_cutoff = 120

l1designref = l1pipeline.inputs.analysis.level1design
l1designref.timing_units = modelspecref.output_units
l1designref.interscan_interval = modelspecref.time_repetition

l1pipeline.inputs.preproc.smooth.fwhm = [6, 6, 6]
l1pipeline.inputs.analysis.modelspec.subject_info = subjectinfo
l1pipeline.inputs.analysis.contrastestimate.contrasts = contrasts
l1pipeline.inputs.analysis.threshold.contrast_index = 1

"""
Setup the pipeline
------------------

The nodes created above do not describe the flow of data. They merely
describe the parameters used for each function. In this section we
setup the connections between the nodes such that appropriate outputs
from nodes are piped into appropriate inputs of other nodes.

Use the :class:`nipype.pipeline.engine.Pipeline` to create a
graph-based execution pipeline for first level analysis. The config
options tells the pipeline engine to use `workdir` as the disk
location to use when running the processes and keeping their
outputs. The `use_parameterized_dirs` tells the engine to create
sub-directories under `workdir` corresponding to the iterables in the
pipeline. Thus for this pipeline there will be subject specific
sub-directories.

The ``nipype.pipeline.engine.Pipeline.connect`` function creates the
links between the processes, i.e., how data should flow in and out of
the processing nodes.
"""

level1 = pe.Workflow(name="level1")
level1.base_dir = os.path.abspath('spm_auditory_tutorial/workingdir')

level1.connect([(infosource, datasource, [('subject_id', 'subject_id')]),
                (datasource, l1pipeline, [('struct', 'preproc.coregister.source')])
                ])
if merge_to_4d:
    level1.connect([(datasource, l1pipeline, [('func', 'preproc.merge.in_files')])])
else:
    level1.connect([(datasource, l1pipeline, [('func', 'preproc.realign.in_files')])])

"""

Setup storage results
---------------------

Use :class:`nipype.interfaces.io.DataSink` to store selected outputs
from the pipeline in a specific location. This allows the user to
selectively choose important output bits from the analysis and keep
them.

The first step is to create a datasink node and then to connect
outputs from the modules above to storage locations. These take the
following form directory_name[.[@]subdir] where parts between [] are
optional. For example 'realign.@mean' below creates a directory called
realign in 'l1output/subject_id/' and stores the mean image output
from the Realign process in the realign directory. If the @ is left
out, then a sub-directory with the name 'mean' would be created and
the mean image would be copied to that directory.
"""

datasink = pe.Node(interface=nio.DataSink(), name="datasink")
datasink.inputs.base_directory = os.path.abspath('spm_auditory_tutorial/l1output')

def getstripdir(subject_id):
    import os
    return os.path.join(os.path.abspath('spm_auditory_tutorial/workingdir'), '_subject_id_%s' % subject_id)

# store relevant outputs from various stages of the 1st level analysis
level1.connect([(infosource, datasink, [('subject_id', 'container'),
                                        (('subject_id', getstripdir), 'strip_dir')]),
                (l1pipeline, datasink, [('analysis.contrastestimate.con_images', 'contrasts.@con'),
                                        ('analysis.contrastestimate.spmT_images', 'contrasts.@T')]),
                ])

"""
Execute the pipeline
--------------------

The code discussed above sets up all the necessary data structures
with appropriate parameters and the connectivity between the
processes, but does not generate any output. To actually run the
analysis on the data the ``nipype.pipeline.engine.Pipeline.Run``
function needs to be called.
"""

if __name__ == '__main__':
    level1.run()
    level1.write_graph()
satra commented 7 years ago

@mgxd - can you check out the workflow on the tutorial dataset. in theory it should work, but the crashfile suggests that the interface is not getting any inputs, and therefore the output of segment is not working:

                 (segment, normalize_struc, [('transformation_mat', 'parameter_file'),
                                             ('modulated_input_image', 'apply_to_files'),
                                             (('modulated_input_image', get_vox_dims), 'write_voxel_sizes')]),

@ankita940 - could you please report the contents of the _report.rst inside the segment working directory?

ankita940 commented 7 years ago

Hello @satra ,

Below attached the content of _report.rst file: P.S. The preprocessing is making normalize, smoothing output folder too but crash file is there for normalization_structural then how is it working.

Node: firstlevel (preproc (segment (spm)

Hierarchy : level1.firstlevel.preproc.segment Exec ID : segment.a0

Original Inputs

Execution Inputs

Execution Outputs

Runtime info

Terminal output


Environment
satra commented 7 years ago

@ankita940 - could you try adding this line after the segment node is defined:

segment.inputs.save_bias_corrected = True

and then run it again?

ankita940 commented 7 years ago

Hello @satra

Its again giving an error regarding normalize but now i guess its because of may be version

Here is the crash file generated-

File: crash-20170322-203217-ankita-normalize_struc.a0-c2864d14-984d-43eb-851d-b0ac8b1c48f6.pklz
Node: level1.firstlevel.preproc.normalize_struc.a0
Working directory: /home/ankita/preprocess/spm_auditory_tutorial/workingdir/level1/firstlevel/preproc/_subject_id_M00223/normalize_struc

Node inputs:

DCT_period_cutoff = <undefined>
affine_regularization_type = <undefined>
apply_to_files = <undefined>
ignore_exception = False
jobtype = write
matlab_cmd = <undefined>
mfile = True
nonlinear_iterations = <undefined>
nonlinear_regularization = <undefined>
out_prefix = w
parameter_file = /home/ankita/preprocess/spm_auditory_tutorial/workingdir/level1/firstlevel/preproc/_subject_id_M00223/normalize_struc/sM00223_002_seg_sn.mat
paths = <undefined>
source = <undefined>
source_image_smoothing = <undefined>
source_weight = <undefined>
template = <undefined>
template_image_smoothing = <undefined>
template_weight = <undefined>
use_mcr = <undefined>
use_v8struct = True
write_bounding_box = <undefined>
write_interp = <undefined>
write_preserve = <undefined>
write_voxel_sizes = <undefined>
write_wrap = <undefined>

Traceback: 
Traceback (most recent call last):
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/pipeline/plugins/linear.py", line 43, in run
    node.run(updatehash=updatehash)
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 366, in run
    self._run_interface()
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 476, in _run_interface
    self._result = self._run_command(execute)
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 607, in _run_command
    result = self._interface.run()
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/interfaces/base.py", line 1085, in run
    runtime = self._run_wrapper(runtime)
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/interfaces/base.py", line 1033, in _run_wrapper
    runtime = self._run_interface(runtime)
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/interfaces/spm/base.py", line 323, in _run_interface
    results = self.mlab.run()
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/interfaces/base.py", line 1085, in run
    runtime = self._run_wrapper(runtime)
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/interfaces/base.py", line 1728, in _run_wrapper
    runtime = self._run_interface(runtime)
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/interfaces/matlab.py", line 152, in _run_interface
    self.raise_exception(runtime)
  File "/home/ankita/anaconda2/lib/python2.7/site-packages/nipype/interfaces/base.py", line 1686, in raise_exception
    **runtime.dictcopy()))
RuntimeError: Command:
matlab -nodesktop -nosplash -nodesktop -nosplash -singleCompThread -r "addpath('/home/ankita/preprocess/spm_auditory_tutorial/workingdir/level1/firstlevel/preproc/_subject_id_M00223/normalize_struc');pyscript_normalize;exit"
Standard output:
MATLAB is selecting SOFTWARE OPENGL rendering.

                            < M A T L A B (R) >
                  Copyright 1984-2016 The MathWorks, Inc.
                   R2016b (9.1.0.441655) 64-bit (glnxa64)
                             September 7, 2016

To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.

Executing pyscript_normalize at 22-Mar-2017 20:32:01:
----------------------------------------------------------------------------------------------------
MATLAB Version: 9.1.0.441655 (R2016b)
MATLAB License Number: 40480989
Operating System: Linux 3.16.0-60-generic #80~14.04.1-Ubuntu SMP Wed Jan 20 13:37:48 UTC 2016 x86_64
Java Version: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
----------------------------------------------------------------------------------------------------
MATLAB                                                Version 9.1         (R2016b)
Simulink                                              Version 8.8         (R2016b)
Antenna Toolbox                                       Version 2.1         (R2016b)
Audio System Toolbox                                  Version 1.1         (R2016b)
Bioinformatics Toolbox                                Version 4.7         (R2016b)
Communications System Toolbox                         Version 6.3         (R2016b)
Computer Vision System Toolbox                        Version 7.2         (R2016b)
Control System Toolbox                                Version 10.1        (R2016b)
Curve Fitting Toolbox                                 Version 3.5.4       (R2016b)
DSP System Toolbox                                    Version 9.3         (R2016b)
Database Toolbox                                      Version 7.0         (R2016b)
Embedded Coder                                        Version 6.11        (R2016b)
Filter Design HDL Coder                               Version 3.1         (R2016b)
Fixed-Point Designer                                  Version 5.3         (R2016b)
Fuzzy Logic Toolbox                                   Version 2.2.24      (R2016b)
Global Optimization Toolbox                           Version 3.4.1       (R2016b)
HDL Coder                                             Version 3.9         (R2016b)
HDL Verifier                                          Version 5.1         (R2016b)
Image Acquisition Toolbox                             Version 5.1         (R2016b)
Image Processing Toolbox                              Version 9.5         (R2016b)
Instrument Control Toolbox                            Version 3.10        (R2016b)
LTE System Toolbox                                    Version 2.3         (R2016b)
MATLAB Coder                                          Version 3.2         (R2016b)
MATLAB Report Generator                               Version 5.1         (R2016b)
Mapping Toolbox                                       Version 4.4         (R2016b)
Model Predictive Control Toolbox                      Version 5.2.1       (R2016b)
Neural Network Toolbox                                Version 9.1         (R2016b)
Optimization Toolbox                                  Version 7.5         (R2016b)
Parallel Computing Toolbox                            Version 6.9         (R2016b)
Partial Differential Equation Toolbox                 Version 2.3         (R2016b)
Phased Array System Toolbox                           Version 3.3         (R2016b)
RF Toolbox                                            Version 3.1         (R2016b)
Robotics System Toolbox                               Version 1.3         (R2016b)
Robust Control Toolbox                                Version 6.2         (R2016b)
Signal Processing Toolbox                             Version 7.3         (R2016b)
SimRF                                                 Version 5.1         (R2016b)
Simscape                                              Version 4.1         (R2016b)
Simscape Driveline                                    Version 2.11        (R2016b)
Simscape Electronics                                  Version 2.10        (R2016b)
Simscape Multibody                                    Version 4.9         (R2016b)
Simulink 3D Animation                                 Version 7.6         (R2016b)
Simulink Control Design                               Version 4.4         (R2016b)
Stateflow                                             Version 8.8         (R2016b)
Statistical Parametric Mapping                        Version 6906        (SPM12) 
Statistics and Machine Learning Toolbox               Version 11.0        (R2016b)
Symbolic Math Toolbox                                 Version 7.1         (R2016b)
System Identification Toolbox                         Version 9.5         (R2016b)
WLAN System Toolbox                                   Version 1.2         (R2016b)
Wavelet Toolbox                                       Version 4.17        (R2016b)
SPM version: SPM12 Release: 6906
SPM path: /usr/local/MATLAB/R2016b/toolbox/spm12/spm.m
Conversion Normalise:Write -> Old Normalise:Write

Standard error:
MATLAB code threw an exception:
No executable modules, but still unresolved dependencies or incomplete module inputs.
File:/usr/local/MATLAB/R2016b/toolbox/spm12/spm_jobman.m
Name:/usr/local/MATLAB/R2016b/toolbox/spm12/spm_jobman.m
Line:47
File:home/ankita/preprocess/spm_auditory_tutorial/workingdir/level1/firstlevel/preproc/_subject_id_M00223/normalize_struc/pyscript_normalize.m
Name:fill_run_job
Line:115
File:pm_jobman
Name:pyscript_normalize
Line:461
File:\xc3\xb7
Name:
Line:
Return code: 0
Interface MatlabCommand failed to run. 
Interface Normalize failed to run. 
ankita940 commented 7 years ago

Hello @satra @mgxd , What should I do to make normalization work and can you let me know is this compatability issue or something else since I am working on spm12 and the script is for spm8. If so can I change the script to make it work or I have to find script compatible with spm12.

Is there is some dependency that is missing from system.Please can anyone help me to solve the problem

Any help will be appreciated.

mgxd commented 7 years ago

@ankita940 AFAIK, this is a compatibility issue with SPM12. We'll have to revisit this workflow and update it for both versions of SPM

ankita940 commented 7 years ago

@mgxd I am using matlab version R2016b and now if i will use spm8 with it will this script written for spm8 will work in this environment

mgxd commented 7 years ago

@ankita940 have you tried with spm8? if so, can you verify that was the problem?

hurtb commented 7 years ago

@ankita940 had a similar error trying to run Normalize12 with Matlab2017A. It executed successfully by specifying the tpm kwarg to spm's MNI file.

# Normalize to apply the transformations - spm.Normalize12
normalize = pe.Node(spm.Normalize12(), name='normalize')
normalize.inputs.jobtype = 'estwrite'
normalize.inputs.tpm = '/usr/local/MATLAB/R2017a/toolbox/spm12/tpm/TPM.nii'
normalize.inputs.image_to_align = 'structural.nii'
normalize.inputs.apply_to_files = 'functional.nii'

Unfortunately I do not know why this is the case, but it seems like the template file is not being set correctly in the cmd-line call to matlab. You all are the experts, though.

mgxd commented 7 years ago

@hurtb are you including the property inputs to your declarations? aka

normalize.inputs.image_to_align = 'structural.nii'
hurtb commented 7 years ago

@mgxd - yes. All of the Node inputs are in the form you describe.