<commit_before># -*- coding: utf-8 -*-
"""
Spike Triggered Average calculator

Input:
stimulus (t)
spike times (t)

output:
averaged stimulus before the spiketime


Created on Wed Feb 11 21:20:00 2015
@author: <NAME>, <EMAIL>
"""
<commit_msg>made random spiketime generator, window grabber, and STA. Tested with random spikes and got a flat filter, as expected!<commit_after># -*- coding: utf-8 -*-
"""
Spike Triggered Average calculator

Input:
stimulus (t)
spike times (t)

output:
averaged stimulus before the spiketime


Created on Wed Feb 11 21:20:00 2015
@author: <NAME>, <EMAIL>
"""
import numpy as np

stimulus = np.genfromtxt("gauss_stimulus_3000dim.txt")
STIM_LEN = len(stimulus)
WINDOW_LEN = 5

def gen_rand_spiketimes(number_of_spikes):
    """given stimulus, generate 10 random spikes"""
    rand_spike_times = np.zeros(STIM_LEN)
    timebins = []
    for i in range(number_of_spikes):
        timebin = np.random.randint(low=0, high=STIM_LEN-1)
        rand_spike_times[timebin] = 1
        timebins.append(timebin)
    return rand_spike_times, timebins
        
spikes, times = gen_rand_spiketimes(5)

def window_grabber():
    spike_triggers = []
    for time in times:
        if time > WINDOW_LEN:
            spike_triggers.append(stimulus[time-WINDOW_LEN:time])
        else:
            spike_triggers.append(stimulus[0:time])
    return spike_triggers
    
spike_triggers = window_grabber()
spike_trigger_average = np.average(spike_triggers, axis=0)
{'fraction_non_alphanumeric': 0.10469068660774983, 'fraction_numerical': 0.026512576478585997, 'mean_word_length': 3.9395973154362416, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5845777', 'n_tokens_mistral': 563, 'n_tokens_neox': 508, 'n_words': 133}