<jupyter_start><jupyter_text>Functions for trajectory and heat-map plotting<jupyter_code>def plot_trajectory(frame, start_time_str, end_time_str, return_fr=False):
    '''
    Given a frame, plot the animal's trajectory during the specified period
    Returns the frame used for plotting
    '''
    start_time = pd.to_datetime(start_time_str)
    end_time = pd.to_datetime(end_time_str)
    frame_interest = frame[(frame.Time > start_time) & (frame.Time < end_time)]
    plt.plot(frame_interest.x, frame_interest.y)
    
    if return_fr:
        return frame_interest
    
def plot_heatmap(frame, start_time_str, end_time_str, return_fr=False, sigma=1, bins=100):
    '''
    Given a frame, plot the animal's trajectory during the specified period
    Returns the frame used for plotting
    '''
    start_time = pd.to_datetime(start_time_str)
    end_time = pd.to_datetime(end_time_str)
    frame_interest = frame[(frame.Time > start_time) & (frame.Time < end_time)]
    
    heatmap, x_edges, y_edges  = np.histogram2d(frame_interest.x, frame_interest.y, 
                                  weights=frame_interest.Interval, bins=bins)
    
    # Apply a Gaussian filter to the heatmap
    heatmap_filt = scipy.ndimage.filters.gaussian_filter(heatmap, sigma=sigma)
    
    
    extent = [x_edges[0], x_edges[-1], y_edges[0], y_edges[-1]]
    
    
    with sns.axes_style("dark"):
        plt.imshow(heatmap_filt.T, extent=extent, cmap='jet')
        
    if return_fr:
        return heatmap
    
fr, activity = process_animal('2CW100', '9/25/2016', ndays=5, save=False)


hm = plot_heatmap(fr, '9/29/2016 10:00AM', '9/29/2016 4:00PM', return_fr=False, bins=100, sigma=1)
process_animal('2CW305', '7/14/2016', ndays=4, parse_filename=True, save=True)
process_animal('2CW318', '6/28/2016', ndays=4, save=True, parse_filename=True, find_cumtime=False)
process_animal('LB21', '7/1/2016', ndays=5, save=True, parse_filename=True)
process_animal('2CW312', '7/9/2016', ndays=6, save=True, parse_filename=True)
process_animal('LB15', '7/11/2016', ndays=4, save=True)
process_animal('2CW306', '7/19/2016', ndays=4, save=True)
process_animal('2CW308', '7/14/2016', ndays=4, save=True)
process_animal('LB06', '7/18/2016', ndays=3, save=True)
process_animal('Or130', '7/22/2016', ndays=7, save=True)
process_animal('Or114', '7/26/2016', ndays=9, save=True)
process_animal('2CW317', '7/20/2016', ndays=6, save=True)
process_animal('Z1Pi229', '8/3/2016', ndays=15, save=True)
process_animal('Z1Pi230', '8/3/2016', ndays=13, save=True)
process_animal('LB2', '9/19/2016', ndays=6, save=True)
process_animal('LB11', '8/22/2016', ndays=9, save=True)
process_animal('Or128', '8/22/2016', ndays=9, save=True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14763128901946382, 'fraction_numerical': 0.08152772677194271, 'mean_word_length': 4.698744769874477, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '297869', 'license': 'MIT', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1006, 'n_words': 190, 'path': 'Finch_Movement.ipynb', 'repo_name': 'lmn93beo/Finch_Movement', 'size': '2723'}