import gradio as gr import json ABSTRACT_TEXT = "Machine learning (ML) approaches have demonstrated promising results in a wide range of healthcare applications. Data plays a crucial role in developing ML-based healthcare systems that directly affect people's lives. Many of the ethical issues surrounding the use of ML in healthcare stem from structural inequalities underlying the way we collect, use, and handle data. Developing guidelines to improve documentation practices regarding the creation, use, and maintenance of ML healthcare datasets is therefore of critical importance. In this work, we introduce Healthsheet, a contextualized adaptation of the original datasheet questionnaire ~\cite{gebru2018datasheets} for health-specific applications. Through a series of semi-structured interviews, we adapt the datasheets for healthcare data documentation. As part of the Healthsheet development process and to understand the obstacles researchers face in creating datasheets, we worked with three publicly-available healthcare datasets as our case studies, each with different types of structured data: Electronic health Records (EHR), clinical trial study data, and smartphone-based performance outcome measures. Our findings from the interviewee study and case studies show 1) that datasheets should be contextualized for healthcare, 2) that despite incentives to adopt accountability practices such as datasheets, there is a lack of consistency in the broader use of these practices 3) how the ML for health community views datasheets and particularly \textit{Healthsheets} as diagnostic tool to surface the limitations and strength of datasets and 4) the relative importance of different fields in the datasheet to healthcare concerns." CITATION_BUTTON_TEXT = """@article{2022, title={Healthsheet: Development of a Transparency Artifact for Health Datasets}, url={http://dx.doi.org/10.1145/3531146.3533239}, DOI={10.1145/3531146.3533239}, journal={2022 ACM Conference on Fairness, Accountability, and Transparency}, publisher={ACM}, author={Rostamzadeh, Negar and Mincu, Diana and Roy, Subhrajit and Smart, Andrew and Wilcox, Lauren and Pushkarna, Mahima and Schrouff, Jessica and Amironesei, Razvan and Moorosi, Nyalleng and Heller, Katherine}, year={2022}, month={Jun} } """ def initialize_healthsheet(json_data): healthsheet_dict = {} for header in json_data: healthsheet_dict[header] = {} for var_name, question in json_data[header].items(): healthsheet_dict[header][var_name] = { 'question': question, 'answer': None } return healthsheet_dict def print_healthsheet(healthsheet_dict): healthsheet = "" for header in healthsheet_dict: healthsheet += f"# {header}\n\n" for var_name in healthsheet_dict[header]: question = healthsheet_dict[header][var_name]['question'] answer = healthsheet_dict[header][var_name]['answer'] healthsheet += f"## {question}\n\n" healthsheet += f"`{answer}`\n\n" return healthsheet def update_healthsheet(healthsheet_dict, header, var_name, answer): healthsheet_dict[header][var_name]['answer'] = answer healthsheet = print_healthsheet(healthsheet_dict) return healthsheet_dict, healthsheet with open('healthsheet.json', 'r') as file: json_data = json.load(file) healthsheet_dict = initialize_healthsheet(json_data) healthsheet = print_healthsheet(healthsheet_dict) with gr.Blocks() as demo: gr.HTML("

Healthsheet Creator for Healthcare AI Datasets! 🪄📄✨

") gr.HTML('

Create a healthsheet for your dataset based on Rostamzadeh et al. (2022) "Healthsheet: Development of a Transparency Artifact for Health Datasets"

') with gr.Row(): with gr.Accordion("📝 Abstract", open=False): abstract_button = gr.Markdown(ABSTRACT_TEXT) with gr.Row(): with gr.Accordion("📘 Citation", open=False): citation_button = gr.Textbox( label = '', value=CITATION_BUTTON_TEXT, lines=9, ).style(show_copy_button=True) with gr.Row(): with gr.Column(): for tab_name in json_data: with gr.Tab(tab_name): for var_name, label_text in json_data[tab_name].items(): answer = gr.Textbox(label=label_text, lines=3) update_btn = gr.Button("Update") #update_btn.click(fn=update_healthsheet, inputs=[healthsheet_dict, tab_name, var_name, answer], outputs=[healthsheet_dict, healthsheet]) with gr.Column(): gr.Markdown("This is where your healthsheet will appear! You can copy and paste it into your dataset card.") with gr.Accordion("Progress Tracker", open=True): for header in healthsheet_dict: gr.Markdown(f"❌ {header}") with gr.Accordion("Preview your Healthsheet", open=False): gr.Markdown(healthsheet) with gr.Accordion("Markdown Text (for copying)", open=False): gr.Textbox(healthsheet, label='Your Healthsheet', show_copy_button=True) if __name__ == "__main__": demo.launch()