# user input for how many events of each type (On/Off and discrete) to plot long_events = input("How many behavioral On/Off events do you want to show?") long_events = int(long_events) short_events = input("How many discrete events would you like to show?") short_events = int(short_events) fig, ax = plt.subplots() y = 1 # for-loop plotting On/Off events for a in range(0, long_events): # user input for correct event title, then getting list of indices for event event1 = input( "Type the correct event title for a longer event turning ""On"" as written in the eventcodes dictionary (eg. DipOn):") on = get_events_indices(eventcode, [event1]) event2 = input( "Type the correct event title for a longer event turning ""Off"" as written in the eventcodes dictionary (eg. DipOff):") eventlabel = input("What do you want to label this longer event (eg. Dipper):") off = get_events_indices(eventcode, [event2, 'EndSession']) # randomizing color for plotting of event r = np.random.random() b = np.random.random() g = np.random.random() col = (r, g, b) for i in range(len(on)): on_idx = on[i] off_idx = off[i] # plotting horizontal line for each On/Off pair ax.plot([timecode[on_idx], timecode[off_idx]], [y, y], color=col) ax.plot([timecode[on_idx], timecode[off_idx]], [y, y], color=col, label=eventlabel)
def test_get_events_indices(): assert get_events_indices( ['PokeOn1', 'DipOn', 'DipOff', 'PokeOff1', 'PokeOn1'], 'PokeOn1') == [0, 4] assert get_events_indices( ['PokeOn1', 'DipOn', 'DipOff', 'PokeOff1', 'PokeOn1'], 'DipOn') == [1]
# data transformed into lists of time- and eventcodes (timecode, eventcode) = extract_info_from_file(loaded_file, 500) # user input for choosing which events to graph dip = input("Type 1 if you want to display Dipper values, type 0 otherwise:") dip = int(dip) poke = input("Type 1 if you want to display Poke values, type 0 otherwise:") poke = int(poke) lever = input("Type 1 if you want to display Lever On/Off values, type 0 otherwise:") lever = int(lever) leverpress = input("Type 1 if you want to display Lever Press values, type 0 otherwise:") leverpress = int(leverpress) # getting lists of indices for different events dip_on = get_events_indices(eventcode, ['DipOn']) dip_off = get_events_indices(eventcode, ['DipOff', 'EndSession']) poke_on = get_events_indices(eventcode, ['StartTrial']) poke_off = get_events_indices(eventcode, ['EndTrial', 'EndSession']) lever_on = get_events_indices(eventcode, ['RLeverOn']) lever_off = get_events_indices(eventcode, ['RLeverOff', 'EndSession']) lever_press = get_events_indices(eventcode, ['RPressOn']) fig, ax = plt.subplots(4) # plotting different events subplot = 0 while subplot < 4: if dip == 1:
# data transformed into lists of time- and eventcodes (timecode, eventcode) = extract_info_from_file(loaded_file, 500) # user input for choosing which events to graph dip = input("Type 1 if you want to display Dipper values, type 0 otherwise:") dip = int(dip) poke = input("Type 1 if you want to display Poke values, type 0 otherwise:") poke = int(poke) lever = input("Type 1 if you want to display Lever On/Off values, type 0 otherwise:") lever = int(lever) leverpress = input("Type 1 if you want to display Lever Press values, type 0 otherwise:") leverpress = int(leverpress) # getting lists of indices for different events dip_on = get_events_indices(eventcode, ['DipOn']) dip_off = get_events_indices(eventcode, ['DipOff', 'EndSession']) poke_on = get_events_indices(eventcode, ['PokeOn1']) poke_off = get_events_indices(eventcode, ['PokeOff1']) lever_on = get_events_indices(eventcode, ['RLeverOn']) lever_off = get_events_indices(eventcode, ['RLeverOff', 'EndSession']) lever_press = get_events_indices(eventcode, ['RPressOn']) fig, ax = plt.subplots() # plotting different events if dip == 1: for i in range(len(dip_on)): dip_on_idx = dip_on[i] dip_off_idx = dip_off[i]