SPM12b now generates nii files instead of img/hdr pairs
The nipype interfaces need to be updated to allow spm12b compatibility for nii files.

diff --git a/CHANGES b/CHANGES
index 24a004c51..19da675be 100644
--- a/CHANGES
+++ b/CHANGES
@@ -19,6 +19,7 @@ Next Release
 * ENH: New ANTs interface: LaplacianThickness
 * FIX: MRTrix tracking algorithms were ignoring mask parameters.
 * FIX: FNIRT registration pathway and associated OpenFMRI example script
+* FIX: spm12b compatibility for Model estimate
 
 Release 0.9.2 (January 31, 2014)
 ============
diff --git a/examples/fmri_spm.py b/examples/fmri_spm.py
index 0d124c56d..5c0ba2faa 100755
--- a/examples/fmri_spm.py
+++ b/examples/fmri_spm.py
@@ -15,6 +15,8 @@ nipype tutorial directory:
 
 Import necessary modules from nipype."""
 
+import os                                    # system functions
+
 from nipype import config
 config.enable_provenance()
 
@@ -30,7 +32,7 @@ import nipype.interfaces.utility as util     # utility
 import nipype.pipeline.engine as pe          # pypeline engine
 import nipype.algorithms.rapidart as ra      # artifact detection
 import nipype.algorithms.modelgen as model   # model specification
-import os                                    # system functions
+import nipype.interfaces.matlab as mlab
 
 """
 
@@ -50,6 +52,9 @@ fsl.FSLCommand.set_default_output_type('NIFTI')
 # import nipype.interfaces.matlab as mlab      # how to run matlab
 # mlab.MatlabCommand.set_default_matlab_cmd("matlab -nodesktop -nosplash")
 
+# In case a different path is required
+# mlab.MatlabCommand.set_default_paths('/software/matlab/spm12b/spm12b_r5918')
+
 """The nipype tutorial contains data for two subjects.  Subject data
 is in two subdirectories, ``s1`` and ``s2``.  Each subject directory
 contains four functional volumes: f3.nii, f5.nii, f7.nii, f10.nii. And
diff --git a/nipype/interfaces/spm/model.py b/nipype/interfaces/spm/model.py
index 1fa0d1730..5b0528a08 100644
--- a/nipype/interfaces/spm/model.py
+++ b/nipype/interfaces/spm/model.py
@@ -213,7 +213,11 @@ class EstimateModel(SPMCommand):
     def _list_outputs(self):
         outputs = self._outputs().get()
         pth, _ = os.path.split(self.inputs.spm_mat_file)
-        mask = os.path.join(pth, 'mask.img')
+        spm12 = '12' in self.version.split('.')[0]
+        if spm12:
+            mask = os.path.join(pth, 'mask.nii')
+        else:
+            mask = os.path.join(pth, 'mask.img')
         outputs['mask_image'] = mask
         spm = sio.loadmat(self.inputs.spm_mat_file, struct_as_record=False)
         betas = []
@@ -221,9 +225,15 @@ class EstimateModel(SPMCommand):
             betas.append(str(os.path.join(pth, vbeta.fname[0])))
         if betas:
             outputs['beta_images'] = betas
-        resms = os.path.join(pth, 'ResMS.img')
+        if spm12:
+            resms = os.path.join(pth, 'ResMS.nii')
+        else:
+            resms = os.path.join(pth, 'ResMS.img')
         outputs['residual_image'] = resms
-        rpv = os.path.join(pth, 'RPV.img')
+        if spm12:
+            rpv = os.path.join(pth, 'RPV.nii')
+        else:
+            rpv = os.path.join(pth, 'RPV.img')
         outputs['RPVimage'] = rpv
         spm = os.path.join(pth, 'SPM.mat')
         outputs['spm_mat_file'] = spm
@@ -382,10 +392,17 @@ class EstimateContrast(SPMCommand):
         if con_images:
             outputs['con_images'] = con_images
             outputs['spmT_images'] = spmT_images
-        ess = glob(os.path.join(pth, 'ess*.img'))
+        spm12 = '12' in self.version.split('.')[0]
+        if spm12:
+            ess = glob(os.path.join(pth, 'ess*.nii'))
+        else:
+            ess = glob(os.path.join(pth, 'ess*.img'))
         if len(ess) > 0:
             outputs['ess_images'] = sorted(ess)
-        spmf = glob(os.path.join(pth, 'spmF*.img'))
+        if spm12:
+            spmf = glob(os.path.join(pth, 'spmF*.nii'))
+        else:
+            spmf = glob(os.path.join(pth, 'spmF*.img'))
         if len(spmf) > 0:
             outputs['spmF_images'] = sorted(spmf)
         outputs['spm_mat_file'] = self.inputs.spm_mat_file
['examples/fmri_spm.py', 'nipype/interfaces/spm/model.py', 'CHANGES']