def add_empty_vol(in_file, out_file=None):
 import nibabel as nb
 import os.path as op
 import numpy as np
 import math
 if (out_file is None):
  (fname, fext) = op.splitext(op.basename(in_file))
  if (fext == u'.gz'):
   (fname, _) = op.splitext(fname)
  out_file = op.abspath((u'./%s_4D.nii.gz' % fname))
 im = nb.load(in_file)
 zim = nb.Nifti1Image(np.zeros_like(im.get_data()), im.affine, im.header)
 nb.funcs.concat_images([im, zim]).to_filename(out_file)
 return out_file

def add_empty_vol ( in_file , out_file = None ) : import nibabel as nb import os . path as op import numpy as np import math if ( out_file is None ) : ( fname , fext ) = op . splitext ( op . basename ( in_file ) ) if ( fext == u'.gz' ) : ( fname , _ ) = op . splitext ( fname ) out_file = op . abspath ( ( u'./%s_4D.nii.gz' % fname ) ) im = nb . load ( in_file ) zim = nb . Nifti1Image ( np . zeros_like ( im . get_data ( ) ) , im . affine , im . header ) nb . funcs . concat_images ( [ im , zim ] ) . to_filename ( out_file ) return out_file
adds an empty vol to the phase difference image .