mov = libtiff.TiffFile(current_file)
 mov = mov.get_tiff_array()
 mov = np.array(mov[:,:,:],dtype='d')
 frame1 = len(mov[:,0,0])
 nrow = len(mov[0,:,0])
 ncol = len(mov[0,0,:])
 if count == 0:
     if assignmask == 0:
         fig1, ax = plt.subplots()
         cax = ax.imshow(mov[0,:,:], interpolation='none', cmap='afmhot')
         cbar = fig1.colorbar(cax, ax=ax)
         print("Choose polygon ROI by clicking multiple points")
         print("If finished, press enter")
         pts = plt.ginput(0, timeout=0)
         pts = np.array(pts)
         mask = polygon.mask_polygon(mov,pts)
         print("Choose background")
         bgpts = plt.ginput(1, timeout=0)
         bgpts = np.array(bgpts)
         ax.plot(pts[:,0],pts[:,1], 'b-+')
         ax.plot([bgpts[:,0]+bgscan,bgpts[:,0]+bgscan,bgpts[:,0]-bgscan,bgpts[:,0]-bgscan,bgpts[:,0]+bgscan],[bgpts[:,1]+bgscan,bgpts[:,1]-bgscan,bgpts[:,1]-bgscan,bgpts[:,1]+bgscan,bgpts[:,1]+bgscan], '-o', color='w')
         ax.set_xlim([0,ncol])
         ax.set_ylim([nrow,0])
         fig1.canvas.draw()
     elif assignmask == 1:
         fig1, ax = plt.subplots()
         cax = ax.imshow(mov[0,:,:], interpolation='none', cmap='afmhot')
         cbar = fig1.colorbar(cax, ax=ax)
         cax1 = ax.imshow(mask, interpolation='none', cmap='gray', alpha=0.5)
         cbar1 = fig1.colorbar(cax1, ax=ax)
         if thresholdmask == 0: