# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import pandas as pd
import os 
import shutil

FILE_PATH = "PC/PADCHEST_chest_x_ray_images_labels_160K_01.02.19.csv"
IMAGES_PATH = "PC/images-224"

df = pd.read_csv(FILE_PATH)

df.shape

df.head()

# +
TARGET_DIR = "D:/thesis/dataset/Normal"

if not os.path.exists(TARGET_DIR):
    os.mkdir(TARGET_DIR)
    print("Normal Folder Created")
# -

cnt= 0 
target = "[\'normal\']"
for (i,row) in df.iterrows():
    if row["Labels"]== target:
        cnt+=1
print(cnt)

df.columns

cnt = 0
count_append = []
for(i,row) in df.iterrows():
    if row["Labels"]==target and row["Projection"]=="PA":
        cnt+=1
print(cnt)
count_append.append(cnt)

cnt = 0
target = "[\'COPD signs\']"
for(i,row) in df.iterrows():
    if row["Labels"]==target and row["Projection"]=="PA":
        cnt+=1
print(cnt)
count_append.append(cnt)

cnt = 0
target = "[\'scoliosis\']"
for(i,row) in df.iterrows():
    if row["Labels"]==target and row["Projection"]=="PA":
        cnt+=1
print(cnt)
count_append.append(cnt)

cnt = 0
target = "[\'air trapping\']"
for(i,row) in df.iterrows():
    if row["Labels"]==target and row["Projection"]=="PA":
        cnt+=1
print(cnt)
count_append.append(cnt)

cnt = 0
target = "[\'aortic elongation\']"
for(i,row) in df.iterrows():
    if row["Labels"]==target and row["Projection"]=="PA":
        cnt+=1
print(cnt)
count_append.append(cnt)

cnt = 0
target = "[\'pleural effusion\']"
for(i,row) in df.iterrows():
    if row["Labels"]==target and row["Projection"]=="PA":
        cnt+=1
print(cnt)
count_append.append(cnt)

cnt = 0
target = "[\'laminar atelectasis\']"
for(i,row) in df.iterrows():
    if row["Labels"]==target and row["Projection"]=="PA":
        cnt+=1
print(cnt)
count_append.append(cnt)

cnt = 0
target = "[\'callus rib fracture\']"
for(i,row) in df.iterrows():
    if row["Labels"]==target and row["Projection"]=="PA":
        cnt+=1
print(cnt)
count_append.append(cnt)

cnt = 0
target = "[\'kyphosis\']"
for(i,row) in df.iterrows():
    if row["Labels"]==target and row["Projection"]=="PA":
        cnt+=1
print(cnt)
count_append.append(cnt)

cnt = 0
target = "[\'hiatal hernia\']"
for(i,row) in df.iterrows():
    if row["Labels"]==target and row["Projection"]=="PA":
        cnt+=1
print(cnt)
count_append.append(cnt)

cnt = 0
target = "[\'vascular hilar enlargement\']"
for(i,row) in df.iterrows():
    if row["Labels"]==target and row["Projection"]=="PA":
        cnt+=1
print(cnt)
count_append.append(cnt)

cnt = 0
target = "[\'calcified granuloma\']"
for(i,row) in df.iterrows():
    if row["Labels"]==target and row["Projection"]=="PA":
        cnt+=1
print(cnt)
count_append.append(cnt)

labels = ['normal', 'COPD signs', 'scoliosis', 'air trapping', 'aortic elongation','pleural effusion', 'laminar atelectasis','callus rib fracture','kyphosis','hiatal hernia','vascular hilar enlargement','calcified granuloma']

print(labels)
print(count_append)

final_labels = dict(zip(labels,count_append))

print(final_labels)

# +
import matplotlib.pyplot as plt 
names = list(final_labels.keys())
values = list(final_labels.values())

plt.figure(figsize=(30,30))
plt.xticks(size=20,rotation = 90)
plt.yticks(size=20)
plt.bar(range(len(final_labels)),values,tick_label=names)
plt.show()
# -

print(final_labels)



StarcoderdataJupyterScriptsDedupFiltered