-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpairPlots.py
40 lines (37 loc) · 1.74 KB
/
pairPlots.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
## Pair plots per electrode and experiment (including bandPower at the end)
#electrodes: List of electrodes to be ploted
#bandPower: List of bands to be ploted
#pathToSavePlot: path where to save pairplots
def pairPlotsPerExperiment ( patientsDF, electrodes, bandPower, pathToSavePlot ):
bandColumns = [ ]
bandPowerColumns = [ ]
for i in electrodes:
for j in bandPower:
combinationBand = i + '_(' + j + ')'
bandColumns.append( combinationBand )
combinationPower = 'BPR_' + i
bandPowerColumns.append( combinationPower )
numberOfBandPower = len ( bandPower )
experiments = list( patientsDF.Experiment.unique() )
for exp in experiments:
#For each electrode
for i in range( 0, len( bandColumns ) - 1, numberOfBandPower ):
electrodePossition = int( (i + 1 ) / numberOfBandPower )
electrodeBand = bandColumns[ i : i + numberOfBandPower ]
electrodeBand.append( bandPowerColumns[ electrodePossition ] )
df = patientsDF.loc[ patientsDF.Experiment == exp, electrodeBand ]
plot = sns.pairplot(df)
electrode = electrodes[ electrodePossition ]
picPath = pathToSavePlot + electrode + "_exp_" + exp + ".png"
plot.savefig( picPath )
print ("Pair-plot for the electrode " + electrode + " and the experiment " + exp + " has been saved")
plt.close('all')
######
## HOW TO USE IT: EXAMPLE
##patientsDF = loadData( path )
##electrodes = ['Fp1', 'F3', 'C3', 'Fz', 'Cz', 'Fp2', 'F4', 'C4']
##bandPower = ['Theta', 'Theta2+Alpha1', 'Alpha', 'Beta_Global']
##pathToSavePlot = mainPath + "Plots/"
##pairPlotsPerExperiment ( patientsDF, electrodes, bandPower, pathToSavePlot )
##
######