1 Introduction
Currently, a large amount of data, highly relevant to health systems, is generated through biomedical research. All this data requires proper management for its analysis to be viable [1]. In this context, the large amount and variability of data make it possible for researchers from the most diverse areas of study to use this information to conduct their research.
Computing at the service of medicine is a multidisciplinary field, capable of promoting computational models that make it possible to make inferences related to the health status of patients through the use of scientific computing methods in the analysis of biomedical data [2]. This field, despite being very promising, brings researchers challenges related to data access and manipulation, stemming from information security requirements and the inherent complexity of heterogeneous biomedical data structures.
Biomedical data have a high level of sensitivity, when we think about information security, implying the work of Ethics Committees together with researchers, making the research process more bureaucratic. On the other hand, some regulatory frameworks allow the use of publicly accessible and properly de-identified databases without requiring formal evaluation by an Ethics Committee. In Brazil, for example, Resolution 510/16, of the National Health Council, makes it feasible to use publicly accessible databases so that research can be conducted without the need for evaluation by an Ethics Committee [3].
Among the publicly available biomedical databases, the Medical Information Mart for Intensive Care IV (MIMIC-IV) stands out as one of the most widely used resources in clinical research. MIMIC-IV is a public biomedical database containing de-identified information from patients admitted to the Beth Israel Deaconess Medical Center in Boston, Massachusetts, between 2008 and 2019 [4]. The database follows a modular organization composed of hospital-wide clinical data, intensive care unit data, and clinical notes, containing information such as laboratory tests, medications, diagnoses, vital signs, and free-text medical notes [4].
Although MIMIC-IV provides a rich source of clinical information, its modular structure and large data volume create substantial technical barriers for researchers without advanced knowledge of Structured Query Language (SQL) and data engineering. Accessing relevant information often requires complex joins between multiple tables, application of business rules, and familiarity with database structures.
In heterogeneous environments, extract, transform, load (ETL) processes are commonly used to integrate data from different sources while maintaining consistency and quality [5]. In parallel, cloud computing technologies have enabled scalable storage and processing infrastructures, reducing local infrastructure costs and facilitating large-scale biomedical analysis [6-8]. Despite these advances, researchers still face difficulties related to technical implementation and data manipulation workflows.
In this context, Python has become one of the most widely adopted programming languages in scientific computing due to its syntactic simplicity, open-source ecosystem, and extensive support for data analysis libraries [9,10]. The popularity of Python in the scientific community creates an opportunity for the development of tools capable of abstracting technical database operations and simplifying access to biomedical information.
Several recent studies have explored the use of MIMIC-IV for clinical prediction and retrospective analyses. Previous works investigated mortality prediction in patients with bone tumors [11], early prediction of sepsis-associated encephalopathy using machine learning models [12], and the impact of beta-blockers on mortality in critically ill oncology patients [13]. These studies reinforce the scientific relevance of MIMIC-IV while also highlighting the technical complexity involved in extracting and consolidating its data.
Therefore, there is a demand for tools capable of reducing the engineering overhead involved in accessing and consolidating MIMIC-IV data, allowing multidisciplinary research teams to operate more efficiently regardless of their primary area of expertise. In this context, this work proposes the development of a Python library as a proof of concept (PoC) aimed at demonstrating the feasibility of simplifying access to MIMIC-IV through high-level abstraction methods that encapsulate SQL logic and return data structures directly usable in scientific workflows. The time and effort demanded by data engineering tasks represent a real cost to scientific productivity, given that such resources could otherwise be directed toward clinical analysis and discovery. Abstraction layers address this imbalance directly, serving as a strategy of efficiency for multidisciplinary research teams.
2 Methods
This section describes the methodology adopted for the development of this work.
2.1 Accessing MIMIC-IV data
Access to the data contained in MIMIC-IV is conditioned on the completion of a training course in research with human participants, typically provided by the Collaborative Institutional Training Initiative (CITI). This training addresses the protection of human research participants and includes the requirements of the Health Insurance Portability and Accountability Act (HIPAA), which establishes the standards for information protection that health organizations in the United States must follow.
After completing the course and obtaining the completion certificate, the researcher must submit the documentation on the PhysioNet platform and sign a Data Use Agreement (DUA). The DUA is a mandatory legal contract that requires users to adequately safeguard the dataset, strictly prohibits any attempts to re-identify individuals, and forbids the sharing of the data.
2.2 Preparation of the development environment
The main objective of this work is to develop a PoC tool to optimize the data consolidation workflow in MIMIC-IV, reducing the time and effort spent on data engineering tasks. Rather than delivering a production-ready solution, this work focuses on demonstrating the feasibility of reducing the complexity of data access through abstraction mechanisms. Taking advantage of the widespread use of the Python programming language in the scientific field, due to its syntactic simplicity and extensive library ecosystem, the proposed approach was implemented as a Python library.
For this purpose, a dedicated development environment was set up. The strategies for local database management and the technical procedures for data import followed a practical guide focused on the access and retrieval of MIMIC-IV biomedical data [14].
The development of the library was conducted using the open-source Integrated Development Environment (IDE) Visual Studio Code, making use of specific plugins to support Python development. Additionally, DBeaver was adopted as a local SQL client to facilitate testing and data exploration during the development process.
For development, libraries were incorporated into the work to establish the connection between the Python library and the locally hosted MIMIC-IV database. In this context, the SQLAlchemy library was used to manage database connections and execute queries within a local environment.
2.3 Development and publication of the library
It is important to highlight that the implementation of the library was conducted as a PoC, with the primary objective of validating the proposed approach. The focus was not on delivering a fully optimized or production-ready system, but rather on demonstrating that the abstraction of complex SQL queries into Python methods is a viable strategy to simplify data access in MIMIC-IV.
The library is composed of SQL queries that are encapsulated by Python methods. The queries are responsible for retrieving and consolidating the MIMIC-IV data, and the methods play the role of an interface between the library user and SQL queries. In essence, users will only operate using Python methods, assigning them parameters to customize SQL queries, enabling researchers to retrieve complex information efficiently, without the need to divert attention from their primary research objectives to low-level query logic.
The first step towards defining the queries in SQL and the main data of interest to be extracted from MIMIC-IV was the analysis of its data model. After the analysis, it was possible to identify that very relevant data about the patients, such as sociodemographic information (age, ethnicity, gender, etc.), are present in the database. This information, however, has a certain complexity of access, in technical terms, due to the need to join tables to add this information to the study dataset. Based on this finding, the process of creating specific queries to return each piece of information was started, based on the unique identifier of each patient contained in the MIMIC-IV to carry out the necessary data aggregation processes and return this information so that the user can easily add it to their dataset using the Python programming language.
The methods in Python, used in the construction of this library to encapsulate the SQL queries, were designed to bring as a final result an object that could be used in the most dynamic ways possible by users with an intermediate knowledge of data manipulation in this programming language. For this reason, all methods return objects of type DataFrame. DataFrames are data structures implemented by the Pandas library, which is aimed at data analysis, and are capable of storing two-dimensional tabular data, changeable in size and potentially heterogeneous. In addition, DataFrames contain labeled axes (columns and rows), being very similar to tables [15].
Since the main objective of this work is to support the scientific community in making better use of the data available in MIMIC-IV, it is convenient that this library is made available to everyone who wants to use it and contribute to its development.
2.4 Ethical Aspects
All stages of the project were conducted using public data. Therefore, as this is a study that does not involve research with human subjects, it is in accordance with Resolution No. 510, of April 7, 2016, of the Brazilian National Health Council, and does not require submission to a Research Ethics Committee.
3 Results
As a result of this work, we developed a PoC implementation in the form of an open-source Python library called “MIMIC-IV Extractor Tool.” Its main objective is to demonstrate how the access and consolidation of biomedical data from MIMIC-IV can be simplified for researchers who work primarily with Python and seek to minimize the time spent on data engineering tasks. This library is available in a public repository on GitHub, accessible at: https://github.com/willian2610/MIMIC-IV-Extractor-Tool.
The library acts as an interactive interface between the user (researchers) and the MIMIC-IV database, which is hosted in a local environment (PostgreSQL), as shown in Figure 1. Its main purpose is to abstract the complexity of SQL queries, allowing users to retrieve data of interest without directly manipulating query logic.
The selection of methods implemented in the library was guided by the relevance of the information for the construction of datasets for biomedical studies, prioritizing core patient attributes such as age, race, and gender. In addition, the library includes more specific methods capable of retrieving information such as intensive care unit (ICU) admissions based
Table 1. Available methods on MIMIC-IV Extractor Tool Library
| Method | Description |
|---|
| get_data_from_mimic | This method runs a given query on MIMIC-IV. |
| get_patients_age | This method calculates the true age of patients by using a Hospital Admission ID. |
| get_patients_race | This method retrieves patients’ race information from hospital admissions, supporting strategies like the most recent race per patient. |
| get_patients_gender | This method returns patients’ gender using their subject IDs. |
| get_icu_stays_by_diagnosis | This method uses a diagnosis term to return all ICU stays that can relate to that diagnosis. |
Source: Prepared by the authors (2026).
on diagnosis.
The methods made available by the library act as facilitators for consolidating the information contained in MIMIC-IV. The researcher can make use of more generic methods that capture patients’ information to create their own datasets based on MIMIC-IV data and customize them according to the needs of their research. These methods can be used individually or in combination, allowing queries that are quite complex in terms of data manipulation in SQL and business rules to be easily resolved with just the use of parameters chosen by the researcher. Table 1 presents the available methods along with their descriptions.
To better illustrate the use of library methods, we are going to present a use case:
Use case: Suppose a researcher needs to obtain a dataset of male patients aged between 30 and 49 years who were admitted to the ICU under the diagnosis of sepsis.
If this query were created directly in SQL, the researcher would first need to map which of the available tables could contain sufficiently useful information for the composition of the dataset to be feasible. In this case, a total of 5 tables would need to be crossed using different identifiers, in addition to applying business rules to correctly filter the results.
When using the library, the researcher would need to use two methods in combination, applying the appropriate manipulations to the resulting DataFrames, such as merging and removing unwanted rows.
The first step is to instantiate the library class. For this, we need to import the class MimicExtractor and then instantiate it by passing the parameters responsible for connecting to the database (Figure 2).
Now, we need to get all the ICU stays under the desired diagnosis (Figure 3):
Executing the method shown in Figure 3 returns a DataFrame containing 19 columns with a total of 25,298 rows, considering the full MIMIC-IV dataset.
The next step is to retrieve the age of all patients of interest. For this, all of the Hospital Admission IDs (hadm_id) retrieved in the previous step should be used in order to generate a new DataFrame that will relate the patient with their respective age at the moment of admission to the ICU (Figure 4).
With a DataFrame containing the ICU stays under sepsis diagnosis and a DataFrame containing the ages of the patients, it is possible to merge both objects since the columns hadm_id and subject_id are present in both DataFrames (Figure 5).
Now we have a DataFrame with 20 columns and 25,298 records, containing all the information of the ICU stays under the diagnosis of sepsis in addition to the age of the patient. The last step is to filter the information we need from this DataFrame (male patients with ages from 30 to 49 years old), as shown in Figure 6:
The final dataset for this use case is composed of a DataFrame with 15 columns and 1,508 rows. With the combination of the library methods, we were able to retrieve data from MIMIC-IV in a simple way, without the need to manipulate SQL code.
This use case serves as a practical validation of the proposed PoC, illustrating how the library can effectively reduce the complexity involved in querying MIMIC-IV. By comparing the traditional SQL-based approach with the proposed abstraction, it becomes evident that the PoC successfully simplifies the data retrieval workflow.
4 Discussion
The MIMIC-IV Extractor Tool addresses a critical bottleneck in biomedical research by replacing complex SQL logic with a high-level Python interface. The practical use case demonstrated that operations involving the joining of multiple distinct tables can be reduced to just two methods, substantially reducing the engineering effort required and the risk of extraction errors introduced by manual query construction.
When compared to existing literature, a clear difference can be observed: while researchers usually focus on high-level clinical outcomes, their work presupposes an advanced level of data engineering to handle the modular complexity of MIMIC-IV. This work, on the other hand, focuses on the infrastructure used to access the data, providing tools that make these clinical insights more accessible to multidisciplinary researchers.
In addition, by returning results as Pandas DataFrames, the library integrates easily into the scientific tools already familiar to the community. These findings confirm that abstraction layers are a valid and necessary strategy for accelerating data-driven healthcare research, enabling multidisciplinary collaboration while preserving analytical depth.
5 Conclusion
Data engineering overhead is an avoidable tax on research productivity. By abstracting the complexity of data retrieval, the developed tool allows researchers to redirect their effort toward clinical analysis and value generation.
This work presented a PoC demonstrating that a Python-based abstraction layer effectively simplifies the process of accessing and consolidating data from the MIMIC-IV database. By abstracting the complexity of data retrieval, the developed tool allows researchers to redirect their effort from infrastructure concerns to clinical analysis and value generation.
The initiative contributes to the advancement of science by enabling multidisciplinary teams to conduct research that previously required complex, specialized engineering processes. By lowering the entry point for MIMIC-IV data access, the tool broadens the range of researchers who can engage with one of the most comprehensive freely available clinical databases, potentially accelerating the pace of biomedical discoveries.
As an open-source project, the tool is designed to evolve alongside the needs of the scientific community. Future development directions include the integration with cloud environments such as Google Cloud Platform (GCP) and Amazon Web Services (AWS), which would enable scalable and infrastructure-independent data access, particularly relevant for institutions with limited local computing resources. Additionally, the expansion of available retrieval methods, guided by the clinical demands expressed by the research community, represents a natural path for consolidating the tool as a reliable resource for biomedical data science.
Links
The library is available on GitHub, accessible at: https://github.com/willian2610/MIMIC-IV-Extractor-Tool.