title: "argument must be a callable function" when using scipy.integrate.quad
body: <p>I've written some code that enables me to take data from DICOM files and separate the data into the individual FID signals.</p>
  
  <pre><code>from pylab import *
  import dicom
  import numpy as np
  import scipy as sp
  
  plan=dicom.read_file("1.3.46.670589.11.38085.5.22.3.1.4792.2013050818105496124")
  all_points = array(plan.SpectroscopyData)
  cmplx_data = all_points[0::2] -1j*all_points[1::2]
  frames = int(plan.NumberOfFrames)
  fid_pts = len(cmplx_data)/frames
  del_t = plan.AcquisitionDuration / (frames * fid_pts)
  
  fid_list = []
  for fidN in arange(frames):
      offset = fidN * fid_pts 
      current_fid = cmplx_data[offset:offset+fid_pts]
      fid_list.append(current_fid)
  </code></pre>
  
  <p>I'd now like to quantify some of this data so, after applying a Fourier transform and shift I've tried to use Scipy's quad function and encountered the following error:</p>
  
  <pre><code>spec = fftshift(fft(fid_list[0])))
  sp.integrate.quad(spec, 660.0, 700.0)
  
  
  
  error                                     Traceback (most recent call last)
  /home/dominicc/Experiments/In Vitro/Glu, Cr/Phantom 1: 10mM Cr, 5mM Glu/WIP_SV_PRESS_ME_128TEs_5ms_spacing_1828/&lt;ipython-input-107-17cb50e45927&gt; in &lt;module&gt;()
  ----&gt; 1 sp.integrate.quad(fid, 660.0, 700.0)
  
  /usr/lib/python2.7/dist-packages/scipy/integrate/quadpack.pyc in quad(func, a, b, args, full_output, epsabs, epsrel, limit, points, weight, wvar, wopts, maxp1, limlst)
  243     if type(args) != type(()): args = (args,)
  244     if (weight is None):
  --&gt; 245         retval = _quad(func,a,b,args,full_output,epsabs,epsrel,limit,points)
  246     else:
  247         retval = _quad_weight(func,a,b,args,full_output,epsabs,epsrel,limlst,limit,maxp1,weight,wvar,wopts)
  
  /usr/lib/python2.7/dist-packages/scipy/integrate/quadpack.pyc in _quad(func, a, b, args, full_output, epsabs, epsrel, limit, points)
  307     if points is None:
  308         if infbounds == 0:
  --&gt; 309             return _quadpack._qagse(func,a,b,args,full_output,epsabs,epsrel,limit)
  310         else:
  311             return _quadpack._qagie(func,bound,infbounds,args,full_output,epsabs,epsrel,limit)
  
  error: First argument must be a callable function.
  </code></pre>
  
  <p>Could somebody please suggest a way to make this object callable? I'm still not particularly clear after reading <a href="https://stackoverflow.com/questions/111234/what-is-a-callable-in-python">What is a &quot;callable&quot; in Python?</a>. After reading that I tried</p>
  
  <pre><code>def fid():
      spec = fftshift(fft(fid_list[0])) 
      return spec
  </code></pre>
  
  <p>Which returned the same error.</p>
  
  <p>Any help would be greatly appreciated, thanks.</p>