image_output_1.png
import matplotlib.pyplot as plt

import os

import pandas as pd

import seaborn as sns

flairs = t1ws = t2ws = t1gds = 0
study = {}
for p in os.listdir('../input/rsna-miccai-brain-tumor-radiogenomic-classification/train'):
    for i in os.listdir('../input/rsna-miccai-brain-tumor-radiogenomic-classification/train/' + p):
        study[p] = {}
        if i == 'FLAIR':
            flairs = len(os.listdir('../input/rsna-miccai-brain-tumor-radiogenomic-classification/train/' + p + '/' + i))
        elif i == 'T1w':
            t1ws = len(os.listdir('../input/rsna-miccai-brain-tumor-radiogenomic-classification/train/' + p + '/' + i))
        elif i == 'T2w':
            t2ws = len(os.listdir('../input/rsna-miccai-brain-tumor-radiogenomic-classification/train/' + p + '/' + i))
        elif i == 'T1wCE':
            t1gds = len(os.listdir('../input/rsna-miccai-brain-tumor-radiogenomic-classification/train/' + p + '/' + i))
        study[p]['FLAIR'] = flairs
        study[p]['T1w'] = t1ws
        study[p]['T2w'] = t2ws
        study[p]['T1wCE'] = t1gds

study = pd.DataFrame(study).transpose()
plt.figure(figsize=(30, 5))
tmp = study.sort_values('FLAIR', ascending=False)['FLAIR'][:10]
plt.subplot(141)
sns.barplot(x=tmp.index, y=tmp)
plt.title('FLAIR TOP 10')
tmp = study.sort_values('T1w', ascending=False)['T1w'][:10]
plt.subplot(142)
sns.barplot(x=tmp.index, y=tmp)
plt.title('T1w TOP 10')
tmp = study.sort_values('T2w', ascending=False)['T2w'][:10]
plt.subplot(143)
sns.barplot(x=tmp.index, y=tmp)
plt.title('T2w TOP 10')
tmp = study.sort_values('T1wCE', ascending=False)['T1wCE'][:10]
plt.subplot(144)
sns.barplot(x=tmp.index, y=tmp)
plt.title('T1wCE TOP 10')
plt.show()
plt.figure(figsize=(20, 5))
tmp = ['FLAIR', 'T1w', 'T2w', 'T1wCE']
tmp2 = []
for col in tmp:
    tmp2.append(sum(study[col]))
sns.barplot(x=tmp, y=tmp2)
plt.show()