def correct_background (bkgnd_data, track_coords, track_intensities):
    """Subtract background intensity from track_coords.
    
    Args:
        bkgnd_data (dict): Background intensities, e.g. from read_ij_intensity
        track_coords (list): numpy arrays of x,y,t spot positions per track
        track_intensities (list): List of float numpy arrays, one per track, 
            containing the fluorescence intensity values of each tracked spot
    Returns:
        bkgnd_int (list): List of numpy arrays (one for each track in 
            track_intensities) storing background intensity values
        bkgnd_corr_int (list): List of numpy arrays (one for each track in 
            track_intensities) storing background-subtracted track intensities     
    """
    # Subtract background intensities from track intensities
    bkgnd_raw = bkgnd_data['intensities']
    bkgnd_int = [] # background intensities per track
    bkgnd_corr_int = [] # spot intensities corrected for background
    
    for i, track in enumerate(track_coords):
        start = int(track[0,2])
        n_frames = track.shape[0]
        bkgnd_temp = bkgnd_raw[start:(start+n_frames)]
        corrected_int = track_intensities[i]-bkgnd_temp
        bkgnd_int.append(bkgnd_temp)
        bkgnd_corr_int.append(corrected_int)
    
    return bkgnd_int, bkgnd_corr_int