Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-dzaye committed Apr 18, 2023
1 parent a9ab703 commit b08f8e9
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 51 deletions.
10 changes: 9 additions & 1 deletion berlin_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"012": 0,
"013": 3,
"014": 4,
"015": 4
"015": 4,
'EL016': 4
}
NEW_CH_NAMES_MAP = {
"003": [
Expand Down Expand Up @@ -128,6 +129,13 @@
"ECOG_R_3_4_SMC_AT",
"ECOG_R_4_5_SMC_AT",
"ECOG_R_5_6_SMC_AT"
],
"016": [
"ECOG_R_1_2_SMC_AT",
"ECOG_R_2_3_SMC_AT",
"ECOG_R_3_4_SMC_AT",
"ECOG_R_4_5_SMC_AT",
"ECOG_R_5_6_SMC_AT"
]
}
layout = BIDSLayout(data_path)
Expand Down
5 changes: 5 additions & 0 deletions berlin_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def statistic(x, y):
dist13 = df_sub_dist[df_sub_dist["Subject"] == 13]
dist14 = df_sub_dist[df_sub_dist["Subject"] == 14]
dist15 = df_sub_dist[df_sub_dist["Subject"] == 15]
dist16 = df_sub_dist[df_sub_dist["Subject"] == 16]

# plot_utils.plot_distribution_sub3(dist3)
# plot_utils.plot_distribution_sub4(dist4)
Expand All @@ -209,6 +210,7 @@ def statistic(x, y):
# plot_utils.plot_distribution_sub13(dist13)
# plot_utils.plot_distribution_sub14(dist14)
# plot_utils.plot_distribution_sub15(dist15)
# plot_utils.plot_distribution_sub16(dist16)


(
Expand Down Expand Up @@ -236,6 +238,8 @@ def statistic(x, y):
psd_s14on,
psd_s15off,
psd_s15on,
psd_s16off,
psd_s16on,
psd_off,
psd_on,
) = postprocessing.arrange_psd(npow_list_all)
Expand Down Expand Up @@ -264,6 +268,7 @@ def statistic(x, y):
plot_utils.plot_psd_s13(psd_s13off, psd_s13on)
plot_utils.plot_psd_s14(psd_s14off, psd_s14on)
plot_utils.plot_psd_s15(psd_s15off, psd_s15on)
plot_utils.plot_psd_s16(psd_s16off, psd_s16on)
print("done")

# peak analyse
Expand Down
96 changes: 48 additions & 48 deletions src/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,55 +75,55 @@ def bursts_single_run(

run_TF = burst_calc.Time_Frequency_Estimation(stand_signal)

#l_beta = burst_calc.beta_bands(run_TF)
l_beta = burst_calc.beta_bands(run_TF)

# list of low, high, full beta bands for all channels
if sub == "003" and med == "Off":
l_beta = burst_calc.beta_bands_sub3(run_TF)
if sub == "003" and med == "On":
l_beta = burst_calc.beta_bands_sub3_on(run_TF)
if sub == "004" and med == "Off":
l_beta = burst_calc.beta_bands_sub4(run_TF)
if sub == "004" and med == "On":
l_beta = burst_calc.beta_bands_sub4_on(run_TF)
if sub == "005" and med == "Off":
l_beta = burst_calc.beta_bands_sub5(run_TF)
if sub == "005" and med == "On":
l_beta = burst_calc.beta_bands_sub5_on(run_TF)
if sub == "006":
l_beta = burst_calc.beta_bands_sub6(run_TF)
if sub == "007" and med == 'Off':
l_beta = burst_calc.beta_bands_sub7(run_TF)
if sub == "007" and med == 'On':
l_beta = burst_calc.beta_bands_sub7_on(run_TF)
if sub == "008" and med == "Off":
l_beta = burst_calc.beta_bands_sub8(run_TF)
if sub == "008" and med == "On":
l_beta = burst_calc.beta_bands_sub8_on(run_TF)
if sub == "009" and med == "Off":
l_beta = burst_calc.beta_bands_sub9(run_TF)
if sub == "009" and med == "On":
l_beta = burst_calc.beta_bands_sub9_on(run_TF)
if sub == "011" and med == "Off":
l_beta = burst_calc.beta_bands_sub11(run_TF)
if sub == "011" and med == "On":
l_beta = burst_calc.beta_bands_sub11_on(run_TF)
if sub == "012" and med == "Off":
l_beta = burst_calc.beta_bands_sub12(run_TF)
if sub == "012" and med == "On":
l_beta = burst_calc.beta_bands_sub12_on(run_TF)
if sub == "013" and med == 'Off':
l_beta = burst_calc.beta_bands_sub13(run_TF)
if sub == "013" and med == 'On':
l_beta = burst_calc.beta_bands_sub13_on(run_TF)
if sub == "014" and med == "Off":
l_beta = burst_calc.beta_bands_sub14(run_TF)
if sub == "014" and med == "On":
l_beta = burst_calc.beta_bands_sub14_on(run_TF)
if sub == "015" and med == "Off":
l_beta = burst_calc.beta_bands_sub15(run_TF)
if sub == "015" and med == "On":
l_beta = burst_calc.beta_bands_sub15_on(run_TF)
#if sub == "003" and med == "Off":
# l_beta = burst_calc.beta_bands_sub3(run_TF)
#if sub == "003" and med == "On":
# l_beta = burst_calc.beta_bands_sub3_on(run_TF)
#if sub == "004" and med == "Off":
# l_beta = burst_calc.beta_bands_sub4(run_TF)
#if sub == "004" and med == "On":
# l_beta = burst_calc.beta_bands_sub4_on(run_TF)
#if sub == "005" and med == "Off":
# l_beta = burst_calc.beta_bands_sub5(run_TF)
#if sub == "005" and med == "On":
# l_beta = burst_calc.beta_bands_sub5_on(run_TF)
#if sub == "006":
# l_beta = burst_calc.beta_bands_sub6(run_TF)
#if sub == "007" and med == 'Off':
# l_beta = burst_calc.beta_bands_sub7(run_TF)
#if sub == "007" and med == 'On':
# l_beta = burst_calc.beta_bands_sub7_on(run_TF)
#if sub == "008" and med == "Off":
# l_beta = burst_calc.beta_bands_sub8(run_TF)
#if sub == "008" and med == "On":
# l_beta = burst_calc.beta_bands_sub8_on(run_TF)
#if sub == "009" and med == "Off":
# l_beta = burst_calc.beta_bands_sub9(run_TF)
#if sub == "009" and med == "On":
# l_beta = burst_calc.beta_bands_sub9_on(run_TF)
#if sub == "011" and med == "Off":
# l_beta = burst_calc.beta_bands_sub11(run_TF)
#if sub == "011" and med == "On":
# l_beta = burst_calc.beta_bands_sub11_on(run_TF)
#if sub == "012" and med == "Off":
# l_beta = burst_calc.beta_bands_sub12(run_TF)
#if sub == "012" and med == "On":
# l_beta = burst_calc.beta_bands_sub12_on(run_TF)
#if sub == "013" and med == 'Off':
# l_beta = burst_calc.beta_bands_sub13(run_TF)
#if sub == "013" and med == 'On':
# l_beta = burst_calc.beta_bands_sub13_on(run_TF)
#if sub == "014" and med == "Off":
# l_beta = burst_calc.beta_bands_sub14(run_TF)
#if sub == "014" and med == "On":
# l_beta = burst_calc.beta_bands_sub14_on(run_TF)
#if sub == "015" and med == "Off":
# l_beta = burst_calc.beta_bands_sub15(run_TF)
#if sub == "015" and med == "On":
# l_beta = burst_calc.beta_bands_sub15_on(run_TF)

theta = 0
mu = 1
Expand All @@ -141,7 +141,7 @@ def bursts_single_run(
l_beta_avg_norm = [burst_calc.z_score(l) for l in l_beta_avg]

# smoothing traces
l_beta_smooth = [burst_calc.smooth(l) for l in l_beta_avg_norm[indbeta]]
l_beta_smooth = [burst_calc.smooth(l) for l in l_beta_avg_norm[full]]

# 75th percentile of the power
l_beta_thr = [burst_calc.percentile(l, percentile=75) for l in l_beta_smooth]
Expand Down
51 changes: 49 additions & 2 deletions src/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def avg_features_sub(burst_char_pd_all):
feat_14on = burst_char_pd_all[21]
feat_15off = burst_char_pd_all[22]
feat_15on = burst_char_pd_all[23]
feat_16off = burst_char_pd_all[24]
feat_16on = burst_char_pd_all[25]

rfeat_3off = feat_3off.drop(columns=["Run"])
rfeat_3on = feat_3on.drop(columns=["Run"])
Expand All @@ -83,6 +85,8 @@ def avg_features_sub(burst_char_pd_all):
rfeat_14on = feat_14on.drop(columns=["Run"])
rfeat_15off = feat_15off.drop(columns=["Run"])
rfeat_15on = feat_15on.drop(columns=["Run"])
rfeat_16off = feat_16off.drop(columns=["Run"])
rfeat_16on = feat_16on.drop(columns=["Run"])

avg_features = pd.concat(
[
Expand Down Expand Up @@ -110,6 +114,8 @@ def avg_features_sub(burst_char_pd_all):
rfeat_14on,
rfeat_15off,
rfeat_15on,
rfeat_16off,
rfeat_16on,
]
)
return avg_features
Expand Down Expand Up @@ -261,6 +267,18 @@ def avg_distribution(M1_burst_dynamics_all):
.to_numpy()
.flatten()
)
dis_s16off = (
M1_burst_dynamics_all[24]
.drop(columns=["Subject", "Medication", "Run"])
.to_numpy()
.flatten()
)
dis_s16on = (
M1_burst_dynamics_all[25]
.drop(columns=["Subject", "Medication", "Run"])
.to_numpy()
.flatten()
)
dis_off = np.nanmean(
[
dis_s3off,
Expand All @@ -275,6 +293,7 @@ def avg_distribution(M1_burst_dynamics_all):
dis_s13off,
dis_s14off,
dis_s15off,
dis_s16off
],
axis=0,
)
Expand All @@ -292,6 +311,7 @@ def avg_distribution(M1_burst_dynamics_all):
dis_s13on,
dis_s14on,
dis_s15on,
dis_s16on
],
axis=0,
)
Expand Down Expand Up @@ -424,8 +444,8 @@ def avg_distribution(M1_burst_dynamics_all):
df14_avg_dist = pd.concat([dt14_off, dt14_on], ignore_index=True)
df14_avg_dist.insert(1, "Subject", 14)

d15_off = {"Burst Duration (s)": bins, "Probability of Bursts (%)": dis_s14off}
d15_on = {"Burst Duration (s)": bins, "Probability of Bursts (%)": dis_s14on}
d15_off = {"Burst Duration (s)": bins, "Probability of Bursts (%)": dis_s15off}
d15_on = {"Burst Duration (s)": bins, "Probability of Bursts (%)": dis_s15on}
dt15_off = pd.DataFrame(d15_off)
dt15_off.insert(1, "Medication", "OFF")
dt15_on = pd.DataFrame(d15_on)
Expand All @@ -434,6 +454,16 @@ def avg_distribution(M1_burst_dynamics_all):
df15_avg_dist = pd.concat([dt15_off, dt15_on], ignore_index=True)
df15_avg_dist.insert(1, "Subject", 15)

d16_off = {"Burst Duration (s)": bins, "Probability of Bursts (%)": dis_s16off}
d16_on = {"Burst Duration (s)": bins, "Probability of Bursts (%)": dis_s16on}
dt16_off = pd.DataFrame(d16_off)
dt16_off.insert(1, "Medication", "OFF")
dt16_on = pd.DataFrame(d16_on)
dt16_on.insert(1, "Medication", "ON")

df16_avg_dist = pd.concat([dt16_off, dt16_on], ignore_index=True)
df16_avg_dist.insert(1, "Subject", 16)

df_sub_dist = pd.concat(
[
df3_avg_dist,
Expand All @@ -448,6 +478,7 @@ def avg_distribution(M1_burst_dynamics_all):
df13_avg_dist,
df14_avg_dist,
df15_avg_dist,
df16_avg_dist
]
)
return df_gavg_dist, df_sub_dist
Expand Down Expand Up @@ -598,6 +629,18 @@ def arrange_psd(npow_list_all):
.to_numpy()
.flatten()
)
psd_s16off = (
npow_list_all[24]
.drop(columns=["Subject", "Medication", "Run"])
.to_numpy()
.flatten()
)
psd_s16on = (
npow_list_all[25]
.drop(columns=["Subject", "Medication", "Run"])
.to_numpy()
.flatten()
)
psd_off = np.mean(
[
psd_s3off,
Expand All @@ -612,6 +655,7 @@ def arrange_psd(npow_list_all):
psd_s13off,
psd_s14off,
psd_s15off,
psd_s16off
],
axis=0,
)
Expand All @@ -629,6 +673,7 @@ def arrange_psd(npow_list_all):
psd_s13on,
psd_s14on,
psd_s15on,
psd_s16on
],
axis=0,
)
Expand Down Expand Up @@ -657,6 +702,8 @@ def arrange_psd(npow_list_all):
psd_s14on,
psd_s15off,
psd_s15on,
psd_s16off,
psd_s16on,
psd_off,
psd_on,
)
Expand Down

0 comments on commit b08f8e9

Please sign in to comment.