diff --git a/excel_to_edf.py b/excel_to_edf.py new file mode 100644 index 0000000000000000000000000000000000000000..05b8866495fd7934da2bd77c9f78a5bc772a3006 --- /dev/null +++ b/excel_to_edf.py @@ -0,0 +1,46 @@ +import pandas as pd +import pyedflib +import numpy as np + +def convert_excel_to_edf(excel_path, edf_output_path): + excel_data = pd.ExcelFile(excel_path) #Excel megnyitása + + recordings_data = excel_data.parse('Recordings') #A két munkalap betöltése + patients_data = excel_data.parse('Patients') + + patient_data = patients_data.iloc[0].to_dict() # Az első sorból kiszedi az adatokat + patient_name = patient_data.get('Name', 'N/A') + patient_birthdate = patient_data.get('Birthdate', 'N/A') + patient_sex = patient_data.get('Sex', 'N/A') + patient_ID = patient_data.get ('ID', 'N/A') + record_date = patient_data.get ('Recording_date', 'N/A') + record_lenght = patient_data.get ('Record_lenght', 'N/A') + patient_height = patient_data.get ('Height', 'N/A') + patient_weight = patient_data.get ('Weight', 'N/A') + notes = patient_data.get ('Notes', 'N/A') + + # if pd.isna(patient_birthdate): + # patient_birthdate = 'N/A' + # else: + # patient_birthdate = str(patient_birthdate.date()) + + # Jeladatok kinyerése + signal_labels = recordings_data.columns.tolist() + signals = [recordings_data[col].to_numpy() for col in signal_labels] + + # EDF létrehozása + with pyedflib.EdfWriter(edf_output_path, len(signals), file_type=pyedflib.FILETYPE_EDFPLUS) as edf: + # # Header beállítása + # edf.setHeader({ + + # }) + + + +if __name__ == "__main__": + + excel_path = "test_generator2.xlsx" + + edf_output_path = "output_data.edf" + + convert_excel_to_edf(excel_path, edf_output_path)