示例#1
0
#root_path = Path("/Users/arminbahl/Desktop/preprocessed data/4 fish setups free swimming behavior/dot_motion_coherence8_2")
#root_path = Path("/Users/arminbahl/Desktop/mutant_behavior_data/scn1lab_sa16474")
#root_path = Path("/Users/arminbahl/Desktop/mutant_behavior_data/surrogate_fish1")
#root_path = Path("/Users/arminbahl/Desktop/mutant_behavior_data/surrogate_fish1")
root_path = Path(
    "/Users/arminbahl/Dropbox/mutant_manuscript/mutant_behavior_data/dot_motion_coherence/surrogate_fish1"
)
#root_path = Path("/Users/arminbahl/Desktop/mutant_behavior_data/scn1lab_NIBR")
#root_path = Path("/Users/arminbahl/Desktop/mutant_behavior_data/immp2l_NIBR")
#root_path = Path("/Users/arminbahl/Desktop/mutant_behavior_data/immp2l_summer")
#root_path = Path("/Users/arminbahl/Desktop/mutant_behavior_data/disc1_hetinx")

df = pd.read_hdf(root_path / "found_parameters.h5", key="parameters")
df.to_excel(root_path / "found_parameters.xlsx", sheet_name="parameters")

fig = myfig.Figure(title="Found parameters")

fig.add_text(10.5, 22.2 + 1.5, "Optimal parameters", font=fig.font2)

p0 = myfig.Plot(fig,
                num='',
                xpos=1.5,
                ypos=22,
                plot_height=1.25,
                plot_width=1.25,
                lw=1,
                pc='white',
                errorbar_area=False,
                xl="",
                xmin=-1,
                xmax=3,
示例#2
0
    cv2.putText(img, f"{t-930:.1f} s", (20, 30), cv2.FONT_HERSHEY_SIMPLEX, fontScale=0.6, color=(255, 255, 255))

    cv2.line(img, (head_x, head_y), (centroid_x, centroid_y), (0, 0, 255), 2, cv2.LINE_AA)
    cv2.line(img, (tail_x, tail_y), (centroid_x, centroid_y), (0, 0, 255), 2, cv2.LINE_AA)

    cv2.circle(img, (head_x, head_y), 6, tuple(np.array(to_rgb("C0")) * 255), -1, lineType=cv2.LINE_AA)
    cv2.circle(img, (centroid_x, centroid_y), 6, tuple(np.array(to_rgb("C1")) * 255), -1, lineType=cv2.LINE_AA)
    cv2.circle(img, (tail_x, tail_y), 6, tuple(np.array(to_rgb("C0")) * 255), -1, lineType=cv2.LINE_AA)

    writer.append_data(img)

writer.close()
dddd

fig = myfig.Figure(title="Figure 2")

##########
p0 = myfig.Plot(fig, num='c', xpos=3.5, ypos=22, plot_height=1.25, plot_width=1.5,
                    lw=1, pc='white', errorbar_area=False,
                    xl="Time (s)", xmin=-5, xmax=105, xticks=[0, 25, 50, 75, 100], hlines=[30],
                    yl="Larval curvature (deg)", ymin=-1, ymax=60.1, yticks=[0, 30, 60])

myfig.Line(p0, x=df_raw_data_selected_larva.query("time > 930 and time < 1030").index - 930,
           y=df_raw_data_selected_larva.query("time > 930 and time < 1030")["curvature"],
           lc='blue', lw=0.5, zorder=1, alpha=0.5)
myfig.Scatter(p0, x=df_event_data_selected_larva.query("time_at_current_turn_event > 930 and time_at_current_turn_event < 1030")["time_at_current_turn_event"] - 930,
              y=df_event_data_selected_larva.query("time_at_current_turn_event > 930 and time_at_current_turn_event < 1030")["curvature_at_current_turn_event"],
              lc='C1', pt='o', lw=0.5, ps=2, pc='white', zorder=2, alpha=0.5)

##########
示例#3
0
    i = np.where((data[:, 0] > period-0.2) & (data[:, 1] == 0))[0][0]

    d0.append(data[i - 10:i + 40, 0] - data[i, 0])
    d1.append(data[i - 10:i + 40, 1])
    d2.append(data[i - 10:i + 40, 2])

d0 = np.mean(d0, axis=0)
d1 = np.mean(d1, axis=0)
d2 = np.mean(d2, axis=0)

d1 -= d1.min()
d2 -= d2.min()

d1 /= d1.max()
d2 /= d2.max()

fig = myfig.Figure(title="Closed-loop delay")

p0 = myfig.Plot(fig, xpos=4, ypos=15, plot_height=3, plot_width=4, lw=1, title='Closed-loop delay',
                xl="Time (s)", xmin=-0.1, xmax=0.4, xticks=[0, 0.1, 0.2, 0.3, 0.4],
                yl="Brightness (a.u)", ymin=-0.1, ymax=1.1, yticks=[0, 0.5, 1])

myfig.Line(p0, x=d0, y=d1, lc='C0', zorder=2, lw=1, alpha=0.9, label='Set by computer')
myfig.Line(p0, x=d0, y=d2, lc='C1', zorder=2, lw=1, alpha=0.9, label='Measured by camera')


fig.savepdf(root_path / f"closed_loop_delay", open_pdf=True)



示例#4
0
# print(phototaxis_index_mean)

for experiment_name in ["temporal_phototaxis_drosolarva"]:

    if experiment_name == "virtual_valley_stimulus_drosolarva":
        color = 'C0'
        df = df1

    elif experiment_name == "temporal_phototaxis_drosolarva":
        color = "C1"
        df = df1
    else:
        color = "C2"
        df = df2

    fig = myfig.Figure(title=f"Figure 1 - {experiment_name}")

    # Show the luminance profile
    p0 = myfig.Plot(fig,
                    num='d',
                    xpos=12,
                    ypos=22,
                    plot_height=1.25,
                    plot_width=2.0,
                    lw=1,
                    pc='white',
                    errorbar_area=False,
                    xl="Radial distance from center (cm)",
                    xmin=-0.1,
                    xmax=6.1,
                    xticks=[0, 2, 4, 6],
              "larva_ID != '2018_03_01_fish027_setup0' and "
              "larva_ID != '2018_03_12_fish040_setup1' and "
              "larva_ID != '2018_11_20_fish035_setup0'")

all_results = dict({
    "experiment_name": [],
    "larva_ID": [],
    "region_bin": [],
    "time_bin": [],
    "fraction_of_time_spent": [],
    "speed": []
})

experiment_names = df.index.get_level_values('experiment_name').unique().values

fig = myfig.Figure(title="Figure 1 examples")

xs = np.arange(-6, 6, 0.025)
ys = np.arange(-6, 6, 0.025)

XX, YY = np.meshgrid(xs, ys)

r = np.sqrt(XX**2 + YY**2)
c1 = (1 - pow((1 - r / 6), 0.5)) * 255
c2 = np.ones_like(r) * 200
c3 = 255 * (r - 3)**2 / 9

c1[np.where(r >= 5.6)] = np.nan
c2[np.where(r >= 5.6)] = np.nan
c3[np.where(r >= 5.6)] = np.nan
示例#6
0
import pandas as pd
from pathlib import Path
import matplotlib
import my_figure as myfig
import pylab as pl
import numpy as np

root_path = Path("/Users/arminbahl/Desktop/preprocessed data/maxwell_paper")

phototaxis_index_grid_search = pd.read_hdf(root_path /
                                           "all_data_model_profile1.h5",
                                           key="phototaxis_index_grid_search")

fig = myfig.Figure(title="Figure 3")

# Only Rule 1
for rule_i in range(7):
    if rule_i == 0:
        rule_name = "No rules"
        rule1 = False
        rule2 = False
        rule3 = False
        rule4 = False

    if rule_i == 1:
        rule_name = "Only rule 1"
        rule1 = True
        rule2 = False
        rule3 = False
        rule4 = False
示例#7
0
    target_binned_same_direction, \
    target_binned_features_heading_angle_change_histograms,\
    target_binned_features_inter_bout_interval_histograms = get_target_result(root_path, genotype)

    print(target_correctness_as_function_of_coherence)

    for repeat in range(1):
        try:
            X = np.load(root_path /
                        f"leaky_integrator_model2_X_{genotype}_{repeat}.npy")
            F = np.load(root_path /
                        f"leaky_integrator_model2_F_{genotype}_{repeat}.npy")
        except:
            continue

        fig = myfig.Figure(title=f"Model fits to {genotype}", fig_width=26)

        p1_experiment = myfig.Plot(
            fig,
            num='a',
            xpos=1.5,
            ypos=22,
            plot_height=1.25,
            plot_width=1.25,
            title="Experiment",
            lw=1,
            pc='white',
            errorbar_area=False,
            xl="Coherence (%)",
            xmin=-15,
            xmax=115,
root_path = Path(
    "/Users/arminbahl/Desktop/mutant_behavior_data/dot_motion_coherence")
target_path = Path(
    "/Users/arminbahl/Dropbox/pandas_data_for_ariel/paper/figures")

dt = 0.01
time = np.arange(0, 12000 * dt, dt)[::10]
time_lowrest = np.arange(0, 119, 1)

chance_distance = 534.361450802352 / 100
chance_polarization = 0.3169689901297303

colors = ["C3", "red", "C4"]
for age in [7, 14, 21]:

    fig = myfig.Figure(title=f"Figure 3")

    for i, experiment in enumerate(
        ["scn1lab_NIBR_20200708", "scn1lab_zirc_20200710", "disc1_hetinx"]):

        polarizations_wt = np.load(
            root_path / experiment /
            f"polarizations_wt_age{age}dpf.npy")[:, ::10]
        neighbor_distances_wt = np.load(
            root_path / experiment /
            f"neighbor_distances_wt_age{age}dpf.npy")[:, ::10] / 100
        speed_over_time_wt = np.load(
            root_path / experiment /
            f"speed_over_time_wt_age{age}dpf.npy")[:, :] / 100

        if experiment == "scn1lab_NIBR_20200708" or experiment == "scn1lab_zirc_20200710":
示例#9
0
# # use fast non-dominated sorting
# res = NonDominatedSorting().do(F)
#
# pl.plot(F[:,0], F[:,1],'o')
# for i in range(len(res)):
#     pl.plot(F[res[i]][:,0], F[res[i]][:,1],'.')
# pl.show()
# sadf
import matplotlib
print(F.shape)
import my_figure as myfig

norm = matplotlib.colors.Normalize(vmin=0, vmax=79)
cmap = matplotlib.cm.get_cmap('seismic')

fig = myfig.Figure(title="Pareto fronts")

y_pos = 22
for error_index0, error_index1, xmin, xmax, xticks, ymin, ymax, yticks in [[0, 1, -10, 1010, [0, 500, 1000], -0.1, 5.1, [0, 2.5, 5]],
                                                                           [1, 2, -0.01, 0.6, [0, 0.25, 0.5], -10, 5010, [0, 2500, 5000]],
                                                                           [2, 3, -10, 5010, [0, 2500, 5000], -5, 205, [0, 100, 200]],
                                                                           [3, 4, -10, 510, [0, 250, 500], -0.01, 0.51, [0, 0.25, 0.5]],
                                                                           ]:

        p0 = myfig.Plot(fig, num='', xpos=1.5, ypos=y_pos, plot_height=2.5, plot_width=2.5,
                        lw=1, pc='white', errorbar_area=False,
                        xl=errornames[error_index0], xmin=xmin, xmax=xmax, xticks=xticks,
                        yl=errornames[error_index1], ymin=ymin, ymax=ymax,yticks=yticks, hlines=[0], vlines=[0])


        print(F[0][:, error_index0].max())