title: How to Apply maximum intensity projection and Minimum intensity projection on DICOM file using python?
body: <p>I wanted to Apply maximum intensity projection and Minimum intensity projection on DICOM file using python? i used the following code from GitHub but i am facing issue while i give image to this function</p>
  <pre><code>def createMIP(np_img, slices_num = 15):
      ''' create the mip image from original image, slice_num is the number of 
      slices for maximum intensity projection'''
      img_shape = np_img.shape
      np_mip = np.zeros(img_shape)
      for i in range(img_shape[0]):
          start = max(0, i-slices_num)
          np_mip[i,:,:] = np.amax(np_img[start:i+1],0)
      return np_mip
  </code></pre>
  <pre><code>import os
  import numpy as np 
  from pydicom import dcmread
  from pydicom.data import get_testdata_file 
  from PIL import Image
  directory= &quot;/home/&quot;
  f=os.listdir(directory)
  size= len([name for name in os.listdir(directory) if os.path.isfile(os.path.join(directory, name))])
  for root,dirs,files in os.walk(directory):
      for file in files:
          if file.endswith(&quot;.dcm&quot;):
             path=os.path.join(directory,file)
             ds = pydicom.dcmread(path)
             img=ds.pixel_array
              A= createMIP(img)
  </code></pre>
  <p>it gives the error of the following</p>
  <pre><code>---------------------------------------------------------------------------
  IndexError                                Traceback (most recent call last)
  &lt;ipython-input-305-fc1fa862cfa8&gt; in &lt;module&gt;
       13            ds = pydicom.dcmread(path)
       14            img=ds.pixel_array
  ---&gt; 15            A= createMIP(img)
  
  &lt;ipython-input-294-dab2f30d1fa1&gt; in createMIP(np_img, slices_num)
        6     for i in range(img_shape[0]):
        7         start = max(0, i-slices_num)
  ----&gt; 8         np_mip[i,:,:] = np.amax(np_img[start:i+1],0)
        9     return np_mip
  
  IndexError: too many indices for array
  </code></pre>