Skip to content

Commit 2b7f11c

Browse files
authored
.
1 parent 5563bbe commit 2b7f11c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lecilab_behavior_analysis/df_transforms.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,16 @@ def get_performance_by_difficulty(df: pd.DataFrame) -> pd.DataFrame:
171171
pbd_df["leftward_choices"] = np.where(pbd_df["correct_side"] == "left", pbd_df["value"], 1 - pbd_df["value"])
172172
return pbd_df
173173

174+
def add_auditory_real_statistics(df: pd.DataFrame) -> pd.DataFrame:
175+
df['number_of_tones_high'] = df['auditory_real_statistics'].apply(lambda x: eval(x)['high_tones']['number_of_tones'])
176+
df['number_of_tones_low'] = df['auditory_real_statistics'].apply(lambda x: eval(x)['low_tones']['number_of_tones'])
177+
df['total_percentage_of_tones_high'] = df['auditory_real_statistics'].apply(lambda x: eval(x)['high_tones']['total_percentage_of_tones'])
178+
df['total_percentage_of_tones_low'] = df['auditory_real_statistics'].apply(lambda x: eval(x)['low_tones']['total_percentage_of_tones'])
179+
df['percentage_of_timebins_with_evidence_high'] = df['auditory_real_statistics'].apply(lambda x: eval(x)['high_tones']['percentage_of_timebins_with_evidence'])
180+
df['percentage_of_timebins_with_evidence_low'] = df['auditory_real_statistics'].apply(lambda x: eval(x)['low_tones']['percentage_of_timebins_with_evidence'])
181+
df['total_evidence_strength'] = df['auditory_real_statistics'].apply(lambda x: eval(x)['total_evidence_strength'])
182+
183+
174184
def get_performance_by_difficulty_ratio(df: pd.DataFrame) -> pd.DataFrame:
175185
if df["stimulus_modality"].unique() == 'visual':
176186
stim_col = "visual_stimulus"
@@ -554,14 +564,6 @@ def add_visual_stimulus_difference(df_in: pd.DataFrame) -> pd.DataFrame:
554564
# summary_matrix_df = summary_matrix(df)
555565
# print(summary_matrix_df)
556566

557-
def add_auditory_real_statistics(df: pd.DataFrame) -> pd.DataFrame:
558-
df['number_of_tones_high'] = df['auditory_real_statistics'].apply(lambda x: eval(x)['high_tones']['number_of_tones'])
559-
df['number_of_tones_low'] = df['auditory_real_statistics'].apply(lambda x: eval(x)['low_tones']['number_of_tones'])
560-
df['total_percentage_of_tones_high'] = df['auditory_real_statistics'].apply(lambda x: eval(x)['high_tones']['total_percentage_of_tones'])
561-
df['total_percentage_of_tones_low'] = df['auditory_real_statistics'].apply(lambda x: eval(x)['low_tones']['total_percentage_of_tones'])
562-
df['percentage_of_timebins_with_evidence_high'] = df['auditory_real_statistics'].apply(lambda x: eval(x)['high_tones']['percentage_of_timebins_with_evidence'])
563-
df['percentage_of_timebins_with_evidence_low'] = df['auditory_real_statistics'].apply(lambda x: eval(x)['low_tones']['percentage_of_timebins_with_evidence'])
564-
df['total_evidence_strength'] = df['auditory_real_statistics'].apply(lambda x: eval(x)['total_evidence_strength'])
565567

566568
def parameters_for_fit(df):
567569
"""

0 commit comments

Comments
 (0)