7 March 2021 Guido Cattani
from pathlib import Path
import pandas as pd
from scipy.stats import mannwhitneyu as mannwhitneyu
import matplotlib.pyplot as plt
import seaborn as sns
def read_AC_thresholds():
# function to read AC thersholds data
f_in = '/media/guido/LACIE/Cingle_Guido/Master/Headband/AC_thresholds.xlsx'
p_in = Path(f_in)
df = pd.read_excel(p_in, sheet_name=0, header=0, nrows=85)
df = df.drop(['Unnamed: 0'], axis=1)
new_names = {
'AC_125':'AC_125_Hz', 'AC_250':'AC_250_Hz', 'AC_500':'AC_500_Hz',
'AC_1000': 'AC_1000_Hz', 'AC_2000': 'AC_2000_Hz',
'AC_4000': 'AC_4000_Hz', 'AC_8000': 'AC_8000_Hz'}
df.rename(mapper=new_names, axis=1, inplace=True)
df = df.fillna(pd.NA)
return df
def present_AC_thresholds():
# func. to work on and present AC thresholds data
ac = read_AC_thresholds()
ac1 = ac[['Study_ID', 'Device', 'AC_500_Hz', 'AC_1000_Hz', 'AC_2000_Hz', 'AC_4000_Hz']].copy()
ac1 = ac1.dropna()
pta = ac1.iloc[:, 1:].mean(axis='columns')
ac1.insert(5, column= 'PTA (0.5-4 kHz)', value=pta)
pta_hf = ac1.iloc[:, 2:].mean(axis='columns')
ac1.insert(6, column= 'PTA_HF (1-4 kHz)', value=pta_hf)
ac1.set_index('Study_ID', drop=True, inplace=True, verify_integrity=True)
ac1 = ac1.fillna(pd.NA)
ac1 = ac1.drop(['Device'], axis=1)
return ac1
def read_BC_thresholds():
# function to read BC direct threshold data in dB FL
f_in = '/media/guido/LACIE/Cingle_Guido/Master/Headband/BC_direct_thresholds.xlsx'
p_in = Path(f_in)
df = pd.read_excel(p_in, header=0, nrows=85)
df = df.drop(['Unnamed: 0', 'Device'], axis=1)
df = df.fillna(pd.NA)
df.set_index('Study_ID', drop=True, append=False, inplace=True, verify_integrity=True)
return df
# read difference sensation levels BC - AC simulated with a 65 dB ISDS input signal in front (0 degree angle)
def read_diff_sl():
f_in = '/media/guido/LACIE/Cingle_Guido/Master/Headband/Diff_SL.xlsx'
p_in = Path(f_in)
df = pd.read_excel(p_in, engine='openpyxl', sheet_name='Diff_SL_65dB_0deg', header=0, nrows=85)
df = df.drop(['Unnamed: 0'], axis=1)
df.set_index('Study_ID', drop=True, inplace=True, verify_integrity=True)
df = df.fillna(pd.NA)
return df
def read_SL_BC():
# read sensation levels BC path in the condition with signal at BCD side
f_in = '/media/guido/LACIE/Cingle_Guido/Master/Headband/SL_BC.xlsx'
p_in = Path(f_in)
df = pd.read_excel(p_in, engine='openpyxl', sheet_name="BC_SL_65dB_90deg", header=0, nrows=85)
df = df.drop(['Unnamed: 0'], axis=1)
df.set_index('Study_ID', drop=True, inplace=True, verify_integrity=True)
df = df.fillna(pd.NA)
return df
def select_bp110(df):
# select BP110 data
is_bp110 = df['Device']=='BP110'
df_bp110 = df[is_bp110]
df_bp110.pop('Device')
return(df_bp110)
def select_bh5(df):
# select BAHA5P data
is_baha5p = df['Device']=='BAHA5P'
df_baha5p = df[is_baha5p]
df_baha5p.pop('Device')
return(df_baha5p)
def read_device():
# fuc. to read device type (BP110 or BAHA5P)
df = read_SL_BC()
dvc = df['Device']
return dvc
def diff_sl_filtered():
# boolean mask func. for diff SL, CROS balance criterium
diff_sl= read_diff_sl()
diff_sl.dropna(inplace = True)
dvc = diff_sl.pop('Device')
criterium = -3
pos_diff_sl = diff_sl >= criterium
pos_diff_sl
return pos_diff_sl
def sl_bc_filtered():
# boolean mask func. for SL BC, audibility criterium of BC path
sl_bc= read_SL_BC()
sl_bc.dropna(inplace = True)
dvc = sl_bc.pop('Device')
criterium = 0
pos_sl = sl_bc > criterium
pos_sl
return pos_sl
def bct_better30():
# boolean mask func. for BC direct thresholds with criterium <= 35 dB
bct= read_BC_thresholds()
bct.dropna(inplace = True)
criterium = 30 # criterium BC direct threshold 35 dB or lower
btr = bct <= criterium
btr
return btr
def bct_better2et3k():
# function to combine criterium <=30 dB for BC direct thresholds at 2 & 4 k
btr = bct_better30()
combi_23 = btr['BCd_2000'] & btr['BCd_3000']
combi_23.name = 'BCd_<=30_2&3k'
return combi_23
def mwu_test(df1,df2):
# compare distribution with Mann Whitney U test
mwu = dict()
f = df1.columns.values.tolist()
for i in range(len(f)):
a = df1.iloc[:, i]
b = df2.iloc[:, i]
u_statistic, pVal = mannwhitneyu(a , b, use_continuity=False, alternative='two-sided') # scipy.stats mannwhitneyu test
pVal = round(pVal, 3)
st = {f[i]: [u_statistic, pVal]}
mwu.update(st)
u_test = pd.DataFrame.from_dict(mwu, dtype='float')
diu = {0: 'Mann-Whitney U statistic', 1: 'p-value (two-sided)'}
u_test = u_test.rename(index=diu)
return u_test
def balanced_audible():
# in the f-band is the fitting CROS-balanced & BC SL is >= threshold
audible = diff_sl_filtered() & sl_bc_filtered()
audible_hf = audible.iloc[:, 12 : 16]
audible_hf
# in all 1.6-4k bands at meantime is the fitting CROS-balanced & BC SL is >= threshold
clmns = audible_hf.columns
overall = audible_hf.loc[:, '2000_Hz']
for clmn in clmns:
overall = overall & audible_hf.loc[:, clmn]
overall.rename('balanced & audible', inplace=True)
return overall
diff_sl_filtered()
125_Hz | 160_Hz | 200_Hz | 250_Hz | 315_Hz | 400_Hz | 500_Hz | 630_Hz | 800_Hz | 1000_Hz | 1250_Hz | 1600_Hz | 2000_Hz | 2500_Hz | 3150_Hz | 4000_Hz | 5000_Hz | 6300_Hz | 8000_Hz | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Study_ID | |||||||||||||||||||
1 | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False |
2 | False | False | False | False | False | False | False | False | False | False | False | True | False | False | False | False | False | False | False |
6 | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | True | True |
10 | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False |
12 | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
81 | False | False | False | False | False | False | False | False | False | False | False | False | False | False | True | False | False | False | False |
82 | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False |
83 | False | False | False | False | False | False | False | False | False | False | False | True | True | False | False | False | False | False | False |
84 | False | False | False | False | False | False | False | False | False | True | False | False | False | False | False | True | False | True | False |
85 | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False | False |
70 rows × 19 columns
sl_bc_filtered()
125_Hz | 160_Hz | 200_Hz | 250_Hz | 315_Hz | 400_Hz | 500_Hz | 630_Hz | 800_Hz | 1000_Hz | 1250_Hz | 1600_Hz | 2000_Hz | 2500_Hz | 3150_Hz | 4000_Hz | 5000_Hz | 6300_Hz | 8000_Hz | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Study_ID | |||||||||||||||||||
1 | False | False | False | False | False | False | True | True | True | True | True | True | True | False | True | False | False | True | False |
2 | False | False | False | False | False | False | False | True | True | True | True | True | True | True | False | False | False | False | False |
6 | False | False | False | False | True | True | True | True | True | True | True | True | True | True | True | True | True | True | True |
10 | False | False | False | False | False | True | True | True | True | True | True | True | True | True | True | False | False | False | False |
12 | False | False | False | False | False | True | True | True | True | True | True | True | True | True | True | False | False | True | False |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
81 | False | False | False | False | False | False | False | True | True | True | True | True | True | True | True | False | False | False | False |
82 | False | False | False | False | False | False | False | True | True | True | True | True | True | True | True | False | False | True | False |
83 | False | False | False | False | False | False | True | True | True | True | True | True | True | True | True | False | False | False | False |
84 | False | False | False | False | False | False | False | True | True | True | True | True | True | False | False | False | False | False | False |
85 | False | False | False | False | False | False | False | True | True | True | True | True | True | True | True | True | True | True | True |
70 rows × 19 columns
overall = balanced_audible()
overall
Study_ID 1 False 2 False 6 False 10 False 12 False ... 81 False 82 False 83 False 84 False 85 False Name: balanced & audible, Length: 70, dtype: bool
overall.value_counts()
False 70 Name: balanced & audible, dtype: int64
idx = overall.index
dvc = read_device().loc[idx]
pos_bc_sl = pd.concat([dvc, overall], axis = 1)
pos_bc_sl
Device | balanced & audible | |
---|---|---|
Study_ID | ||
1 | BP110 | False |
2 | BP110 | False |
6 | BP110 | False |
10 | BP110 | False |
12 | BP110 | False |
... | ... | ... |
81 | BAHA5P | False |
82 | BAHA5P | False |
83 | BAHA5P | False |
84 | BAHA5P | False |
85 | BAHA5P | False |
70 rows × 2 columns
bp110 = select_bp110(pos_bc_sl)
idx_bp110 = bp110.index
bp110.value_counts()
balanced & audible False 35 dtype: int64
bh5 = select_bh5(pos_bc_sl)
idx_bh5 = bh5.index
bh5.value_counts()
balanced & audible False 35 dtype: int64
fltr_weak = bh5['balanced & audible']==False
is_weak = bh5[fltr_weak]
weak_cases = is_weak.index
weak_cases
Int64Index([21, 48, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85], dtype='int64', name='Study_ID')
fltr_strong = bh5['balanced & audible']==True
is_strong = bh5[fltr_strong]
strong_cases = is_strong.index
strong_cases
Int64Index([], dtype='int64', name='Study_ID')
act = present_AC_thresholds()
act_weak = act.loc[weak_cases]
act_strong = act.loc[strong_cases]
mwu_test(act_weak,act_strong)
/home/guido/anaconda3/lib/python3.8/site-packages/scipy/stats/stats.py:7171: RuntimeWarning: invalid value encountered in double_scalars z = (bigu - meanrank) / sd
AC_500_Hz | AC_1000_Hz | AC_2000_Hz | PTA (0.5-4 kHz) | PTA_HF (1-4 kHz) | AC_4000_Hz | |
---|---|---|---|---|---|---|
Mann-Whitney U statistic | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
p-value (two-sided) | NaN | NaN | NaN | NaN | NaN | NaN |
bct = read_BC_thresholds()
bct_weak = bct.loc[weak_cases]
bct_strong = bct.loc[strong_cases]
bct_strong
BCd_250 | BCd_500 | BCd_1000 | BCd_1500 | BCd_2000 | BCd_3000 | BCd_4000 | |
---|---|---|---|---|---|---|---|
Study_ID |
bct_weak
BCd_250 | BCd_500 | BCd_1000 | BCd_1500 | BCd_2000 | BCd_3000 | BCd_4000 | |
---|---|---|---|---|---|---|---|
Study_ID | |||||||
21 | 20.0 | 20.0 | 20 | 15.0 | 30 | 50.0 | 35.0 |
48 | 25.0 | 30.0 | 20 | 10.0 | 30 | 30.0 | 25.0 |
52 | 18.0 | 25.0 | 15 | 25.0 | 30 | 45.0 | 30.0 |
54 | 20.0 | 30.0 | 20 | 15.0 | 35 | 48.0 | 50.0 |
55 | 30.0 | 30.0 | 20 | 15.0 | 20 | 35.0 | 50.0 |
56 | 27.0 | 35.0 | 30 | 20.0 | 45 | 63.0 | 63.0 |
57 | 35.0 | 45.0 | 30 | 35.0 | 50 | 35.0 | 40.0 |
58 | 15.0 | 0.0 | 20 | 25.0 | 35 | 40.0 | 35.0 |
59 | 30.0 | 35.0 | 30 | 15.0 | 30 | 35.0 | 45.0 |
60 | 15.0 | 25.0 | 15 | -5.0 | 20 | 25.0 | 35.0 |
61 | 30.0 | 40.0 | 35 | 20.0 | 50 | 65.0 | 65.0 |
62 | 25.0 | 35.0 | 30 | 35.0 | 40 | 45.0 | 55.0 |
63 | 25.0 | 30.0 | 20 | 20.0 | 15 | 20.0 | 45.0 |
64 | 25.0 | 25.0 | 25 | 25.0 | 25 | 35.0 | 35.0 |
65 | 25.0 | 25.0 | 20 | 10.0 | 25 | 25.0 | 20.0 |
66 | 20.0 | 20.0 | 15 | 25.0 | 25 | 25.0 | 35.0 |
67 | 25.0 | 30.0 | 20 | 10.0 | 25 | 35.0 | 35.0 |
68 | 35.0 | 35.0 | 20 | 15.0 | 30 | 45.0 | 35.0 |
69 | 25.0 | 35.0 | 40 | 25.0 | 30 | 30.0 | 35.0 |
70 | 15.0 | 20.0 | 30 | 20.0 | 30 | 25.0 | 25.0 |
71 | 28.0 | 45.0 | 25 | 25.0 | 40 | 45.0 | 50.0 |
72 | 25.0 | 25.0 | 15 | 10.0 | 30 | 35.0 | 45.0 |
73 | 18.0 | 30.0 | 25 | 25.0 | 30 | 25.0 | 40.0 |
74 | 30.0 | 35.0 | 20 | 25.0 | 20 | 35.0 | 25.0 |
75 | 30.0 | 35.0 | 40 | 35.0 | 25 | 30.0 | 25.0 |
76 | 35.0 | 40.0 | 30 | 20.0 | 30 | 25.0 | 25.0 |
77 | 15.0 | 35.0 | 25 | 30.0 | 35 | 35.0 | 30.0 |
78 | 25.0 | 20.0 | 25 | 20.0 | 30 | 35.0 | 35.0 |
79 | 25.0 | 30.0 | 20 | 20.0 | 40 | 40.0 | 40.0 |
80 | 30.0 | 40.0 | 20 | 15.0 | 20 | 30.0 | 25.0 |
81 | 30.0 | 45.0 | 20 | 40.0 | 35 | 25.0 | 45.0 |
82 | 20.0 | 40.0 | 30 | 30.0 | 25 | 35.0 | 45.0 |
83 | 25.0 | 25.0 | 25 | 5.0 | 15 | 35.0 | 50.0 |
84 | 30.0 | 45.0 | 20 | 35.0 | 50 | 65.0 | 60.0 |
85 | 30.0 | 35.0 | 30 | 35.0 | 30 | 15.0 | 35.0 |
mwu_test(bct_weak,bct_strong)
/home/guido/anaconda3/lib/python3.8/site-packages/scipy/stats/stats.py:7171: RuntimeWarning: invalid value encountered in double_scalars z = (bigu - meanrank) / sd
BCd_250 | BCd_500 | BCd_1000 | BCd_1500 | BCd_2000 | BCd_3000 | BCd_4000 | |
---|---|---|---|---|---|---|---|
Mann-Whitney U statistic | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
p-value (two-sided) | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
sw = bct_strong.join(bct_weak, how='outer', lsuffix='_strong', rsuffix='_weak')
sw
BCd_250_strong | BCd_500_strong | BCd_1000_strong | BCd_1500_strong | BCd_2000_strong | BCd_3000_strong | BCd_4000_strong | BCd_250_weak | BCd_500_weak | BCd_1000_weak | BCd_1500_weak | BCd_2000_weak | BCd_3000_weak | BCd_4000_weak | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Study_ID | ||||||||||||||
21 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 20.0 | 20.0 | 20 | 15.0 | 30 | 50.0 | 35.0 |
48 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 25.0 | 30.0 | 20 | 10.0 | 30 | 30.0 | 25.0 |
52 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 18.0 | 25.0 | 15 | 25.0 | 30 | 45.0 | 30.0 |
54 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 20.0 | 30.0 | 20 | 15.0 | 35 | 48.0 | 50.0 |
55 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 30.0 | 30.0 | 20 | 15.0 | 20 | 35.0 | 50.0 |
56 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 27.0 | 35.0 | 30 | 20.0 | 45 | 63.0 | 63.0 |
57 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 35.0 | 45.0 | 30 | 35.0 | 50 | 35.0 | 40.0 |
58 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 15.0 | 0.0 | 20 | 25.0 | 35 | 40.0 | 35.0 |
59 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 30.0 | 35.0 | 30 | 15.0 | 30 | 35.0 | 45.0 |
60 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 15.0 | 25.0 | 15 | -5.0 | 20 | 25.0 | 35.0 |
61 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 30.0 | 40.0 | 35 | 20.0 | 50 | 65.0 | 65.0 |
62 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 25.0 | 35.0 | 30 | 35.0 | 40 | 45.0 | 55.0 |
63 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 25.0 | 30.0 | 20 | 20.0 | 15 | 20.0 | 45.0 |
64 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 25.0 | 25.0 | 25 | 25.0 | 25 | 35.0 | 35.0 |
65 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 25.0 | 25.0 | 20 | 10.0 | 25 | 25.0 | 20.0 |
66 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 20.0 | 20.0 | 15 | 25.0 | 25 | 25.0 | 35.0 |
67 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 25.0 | 30.0 | 20 | 10.0 | 25 | 35.0 | 35.0 |
68 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 35.0 | 35.0 | 20 | 15.0 | 30 | 45.0 | 35.0 |
69 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 25.0 | 35.0 | 40 | 25.0 | 30 | 30.0 | 35.0 |
70 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 15.0 | 20.0 | 30 | 20.0 | 30 | 25.0 | 25.0 |
71 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 28.0 | 45.0 | 25 | 25.0 | 40 | 45.0 | 50.0 |
72 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 25.0 | 25.0 | 15 | 10.0 | 30 | 35.0 | 45.0 |
73 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 18.0 | 30.0 | 25 | 25.0 | 30 | 25.0 | 40.0 |
74 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 30.0 | 35.0 | 20 | 25.0 | 20 | 35.0 | 25.0 |
75 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 30.0 | 35.0 | 40 | 35.0 | 25 | 30.0 | 25.0 |
76 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 35.0 | 40.0 | 30 | 20.0 | 30 | 25.0 | 25.0 |
77 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 15.0 | 35.0 | 25 | 30.0 | 35 | 35.0 | 30.0 |
78 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 25.0 | 20.0 | 25 | 20.0 | 30 | 35.0 | 35.0 |
79 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 25.0 | 30.0 | 20 | 20.0 | 40 | 40.0 | 40.0 |
80 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 30.0 | 40.0 | 20 | 15.0 | 20 | 30.0 | 25.0 |
81 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 30.0 | 45.0 | 20 | 40.0 | 35 | 25.0 | 45.0 |
82 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 20.0 | 40.0 | 30 | 30.0 | 25 | 35.0 | 45.0 |
83 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 25.0 | 25.0 | 25 | 5.0 | 15 | 35.0 | 50.0 |
84 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 30.0 | 45.0 | 20 | 35.0 | 50 | 65.0 | 60.0 |
85 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 30.0 | 35.0 | 30 | 35.0 | 30 | 15.0 | 35.0 |
sw1k = sw[['BCd_1000_strong', 'BCd_1000_weak']]
# make a figure to plot BC direct threshold at 3 kHz for strong & weak fitting groups
ttl = 'Qualitative analysis of fittings as function of BC direct at 1k'
tp = pd.melt(sw1k, var_name = 'strong & weak fitting groups', value_name = 'BC direct threshold at 1 kHz [dB HL]')
fig, ax = plt.subplots(constrained_layout=True)
fig.set_figheight(5)
fig.set_figwidth(7)
ax = sns.swarmplot(data = tp, x = 'strong & weak fitting groups', y = 'BC direct threshold at 1 kHz [dB HL]',
size=6, palette={'grey', 'black'})
ax.set_title(ttl)
#plt.legend(bbox_to_anchor=(0.15, 0.25), fontsize='large')
# save figure to file
plt.savefig('/media/guido/LACIE/Cingle_Guido/Analysis_results/strong_weak_1k_front.tiff',
transparent=False, dpi=500, bbox_inches="tight")
plt.show()
sw2k = sw[['BCd_2000_strong', 'BCd_2000_weak']]
# make a figure to plot BC direct threshold at 3 kHz for strong & weak fitting groups
ttl = 'Qualitative analysis of fittings as function of BC direct at 2k'
tp = pd.melt(sw2k, var_name = 'strong & weak fitting groups', value_name = 'BC direct threshold at 2 kHz [dB HL]')
fig, ax = plt.subplots(constrained_layout=True)
fig.set_figheight(5)
fig.set_figwidth(7)
ax = sns.swarmplot(data = tp, x = 'strong & weak fitting groups', y = 'BC direct threshold at 2 kHz [dB HL]',
size=6, palette={'grey', 'black'})
ax.set_title(ttl)
#plt.legend(bbox_to_anchor=(0.15, 0.25), fontsize='large')
# save figure to file
plt.savefig('/media/guido/LACIE/Cingle_Guido/Analysis_results/strong_weak_2k_front.tiff',
transparent=False, dpi=500, bbox_inches="tight")
plt.show()
sw3k = sw[['BCd_3000_strong', 'BCd_3000_weak']]
# make a figure to plot BC direct threshold at 3 kHz for strong & weak fitting groups
ttl = 'Qualitative analysis of fittings as function of BC direct at 3k'
tp = pd.melt(sw3k, var_name = 'strong & weak fitting groups', value_name = 'BC direct threshold at 3 kHz [dB HL]')
fig, ax = plt.subplots(constrained_layout=True)
fig.set_figheight(5)
fig.set_figwidth(7)
ax = sns.swarmplot(data = tp, x = 'strong & weak fitting groups', y = 'BC direct threshold at 3 kHz [dB HL]',
size=6, palette={'grey', 'black'})
ax.set_title(ttl)
#plt.legend(bbox_to_anchor=(0.15, 0.25), fontsize='large')
# save figure to file
plt.savefig('/media/guido/LACIE/Cingle_Guido/Analysis_results/strong_weak_3k_front.tiff',
transparent=False, dpi=500, bbox_inches="tight")
plt.show()
/home/guido/anaconda3/lib/python3.8/site-packages/seaborn/categorical.py:1296: UserWarning: 28.6% of the points cannot be placed; you may want to decrease the size of the markers or use stripplot. warnings.warn(msg, UserWarning)
sw4k = sw[['BCd_4000_strong', 'BCd_4000_weak']]
# make a figure to plot BC direct threshold at 3 kHz for strong & weak fitting groups
ttl = 'Qualitative analysis of fittings as function of BC direct at 4k'
tp = pd.melt(sw4k, var_name = 'strong & weak fitting groups', value_name = 'BC direct threshold at 4 kHz [dB HL]')
fig, ax = plt.subplots(constrained_layout=True)
fig.set_figheight(5)
fig.set_figwidth(7)
ax = sns.swarmplot(data = tp, x = 'strong & weak fitting groups', y = 'BC direct threshold at 4 kHz [dB HL]',
size=6, palette={'grey', 'black'})
ax.set_title(ttl)
#plt.legend(bbox_to_anchor=(0.15, 0.25), fontsize='large')
# save figure to file
plt.savefig('/media/guido/LACIE/Cingle_Guido/Analysis_results/strong_weak_4k_front.tiff',
transparent=False, dpi=500, bbox_inches="tight")
plt.show()
/home/guido/anaconda3/lib/python3.8/site-packages/seaborn/categorical.py:1296: UserWarning: 28.6% of the points cannot be placed; you may want to decrease the size of the markers or use stripplot. warnings.warn(msg, UserWarning)
bcb = bct_better2et3k()
bcb
Study_ID 1 False 2 False 6 True 10 False 12 False ... 81 False 82 False 83 False 84 False 85 True Name: BCd_<=30_2&3k, Length: 70, dtype: bool
td = [overall, bcb]
qlt = pd.DataFrame(td).T
qlt
balanced & audible | BCd_<=30_2&3k | |
---|---|---|
Study_ID | ||
1 | False | False |
2 | False | False |
6 | False | True |
10 | False | False |
12 | False | False |
... | ... | ... |
81 | False | False |
82 | False | False |
83 | False | False |
84 | False | False |
85 | False | True |
70 rows × 2 columns
qlt = qlt.loc[idx_bh5]
# number of subjects with balanced en audible SL BC
qlt['balanced & audible'].sum()
0
# number of subjects fulfilling criterium BCdT 3 & 4 k
qlt['BCd_<=30_2&3k'].sum()
12
# number of subjects with balanced en audible SL BC fulfilling criterium BCdT 3 & 4 k
vrf = qlt['balanced & audible'] & qlt['BCd_<=30_2&3k']
vrf.sum()
0
# sensitivity
round(vrf.sum() / qlt['balanced & audible'].sum(),2)
<ipython-input-43-cf7d429f0e30>:2: RuntimeWarning: invalid value encountered in long_scalars round(vrf.sum() / qlt['balanced & audible'].sum(),2)
nan
# number of subjects with balanced en audible SL BC not fulfilling criterium BCdT 3 & 4 k
vrf2 = qlt['balanced & audible'] & ~qlt['BCd_<=30_2&3k']
vrf2.sum()
0
# number of subjects with NOT balanced en audible SL BC fulfilling criterium BCdT 3 & 4 k
vrf3 = ~qlt['balanced & audible'] & qlt['BCd_<=30_2&3k']
vrf3.sum()
12
# specificity %
negatieve = len(qlt) - qlt['balanced & audible'].sum()
thrue_neg = negatieve - vrf3.sum()
round(thrue_neg / negatieve, 2)
0.66