A data science and machine learning framework for nursing research
Project description
MIMIC-IV Analysis Toolkit
Unlock Insights from Healthcare Data Effortlessly
Development Architecture and Implementation of the MIMIC-IV Analysis User Interface
The MIMIC-IV Analysis User Interface was developed as a comprehensive web-based dashboard using a modern, modular architecture that prioritizes scalability, maintainability, and user experience. The application is built on Streamlit, a Python-based framework specifically designed for data science applications, which enables rapid development of interactive web applications without requiring extensive frontend development expertise. This choice was particularly advantageous for nursing research applications, as it allows researchers to focus on data analysis rather than web development complexities.
The application follows a component-based architecture with clear separation of concerns, organized into distinct modules that handle different aspects of the analytical workflow. The main application class (MIMICDashboardApp) serves as the orchestrator, managing session state and coordinating between specialized components including data loading (SideBar), exploration and visualization (ExplorationAndViz), feature engineering (FeatureEngineeringTab), clustering analysis (ClusteringAnalysisTab), and post-analysis visualization (AnalysisVisualizationTab). Each component is encapsulated as a separate class with its own render() method, ensuring modularity and facilitating future enhancements or modifications to specific functionality areas.
Performance optimization was a critical consideration in the development process, particularly given the large-scale nature of MIMIC-IV datasets. The application integrates Dask, a parallel computing library, to handle distributed data processing and enable efficient analysis of datasets that exceed available memory. The Dask integration includes automatic client initialization with configurable worker processes, memory limits, and dashboard monitoring capabilities. Additionally, the application implements intelligent data caching strategies using Streamlit's built-in caching mechanisms (@st.cache_resource and @st.cache_data) to minimize redundant computations and improve user experience during iterative analysis sessions.
The user interface design emphasizes accessibility and usability for nursing researchers with varying levels of technical expertise. The dashboard features an intuitive tab-based navigation system with four primary analytical workflows: data exploration and visualization, feature engineering, clustering analysis, and cluster interpretation. Each tab provides contextual guidance and progressive disclosure of advanced options, allowing users to begin with basic exploration and gradually access more sophisticated analytical tools. The interface includes comprehensive data filtering capabilities with predefined inclusion and exclusion criteria specific to nursing research contexts, such as age-based patient selection (18-75 years), specific admission types, and clinical outcome considerations. Real-time feedback mechanisms, including progress indicators and dataset statistics, help users understand the impact of their analytical choices and maintain confidence in the analysis process.
Data integration and preprocessing capabilities are seamlessly embedded within the interface, supporting both CSV and Parquet file formats with automatic format detection and conversion. The application includes sophisticated data validation and error handling mechanisms that provide clear feedback when data quality issues are encountered, ensuring that nursing researchers can confidently work with complex clinical datasets. The modular design also facilitates easy integration of new data sources or analytical methods, making the platform adaptable to evolving research needs in nursing informatics and clinical data analysis.
Table of Contents
- MIMIC-IV Analysis Toolkit
About MIMIC-IV Data
This toolkit is designed to analyze data from the MIMIC-IV (Medical Information Mart for Intensive Care IV) clinical database. MIMIC-IV is a large, freely-available database comprising de-identified health-related data associated with patients who stayed in critical care units at the Beth Israel Deaconess Medical Center.
For detailed information on the MIMIC-IV data structure used by this project, please refer to the documentation:
Features
- Comprehensive Data Loader: Utilities for loading and preparing MIMIC-IV data, simplifying the process of loading and preprocessing MIMIC-IV datasets, addressing common data management challenges. Supports both CSV and Parquet formats, with options for Dask integration for large datasets.
- Interactive Visualization: A Streamlit application for visualizing data, cluster results, and analysis. Utilizes Streamlit for real-time data exploration, enhancing user engagement and understanding of complex datasets.
- Feature Engineering Tools: Tools for creating meaningful features from clinical temporal data, including order frequency matrices, temporal order sequences, and order timing features. Provides utilities for identifying and extracting relevant features, streamlining the data preparation process.
- Clustering Analysis Capabilities: Implementations for K-Means, Hierarchical, DBSCAN clustering, and LDA Topic Modeling to identify patterns in clinical data.
- Predictive Modeling Support: Designed to prepare data for various predictive tasks.
- Configuration Management: Easy-to-use YAML configuration for managing data paths and application settings.
- MIMIC-IV Data Focus: Specifically designed to work with the MIMIC-IV clinical database structure.
- Modular Architecture: Facilitates easy updates and maintenance, promoting a seamless development experience.
- Exploratory Data Analysis
- Patient Trajectory Visualization
- Order Pattern Analysis
Project Structure
The repository is organized as follows:
mimic_iv_analysis/
├── mimic_iv_analysis/ # Main package source code
│ ├── __init__.py # Package initialization
│ ├── configurations/ # Configuration files (e.g., config.yaml)
│ ├── core/ # Core functionalities (data loading, clustering, feature engineering)
│ │ ├── __init__.py
│ │ ├── clustering.py
│ │ ├── data_loader.py
│ │ ├── feature_engineering.py
│ │ └── filtering.py
│ ├── examples/ # Example scripts and notebooks
│ └── visualization/ # Streamlit dashboard application and utilities
│ ├── __init__.py
│ ├── app.py
│ └── app_components/
├── documentations/ # Project documentation
├── scripts/ # Utility and helper scripts (install, run dashboard)
├── setup_config/ # Configuration for setup and testing (e.g., pytest.ini)
├── tests/ # Test suite for the project
├── .streamlit/ # Configuration for Streamlit Cloud deployment
├── README.md # This file
├── requirements.txt # Python package dependencies
└── setup.py # Package setup script
(Note: The src/ directory mentioned in one of the older READMEs is now represented by the top-level mimic_iv_analysis/ package directory for source code.)
Installation
Prerequisites
- Python 3.12 or higher
- pip or conda package manager
Installation Steps
-
Clone the repository:
git clone https://github.com/artinmajdi/mimic_iv_analysis.git cd mimic_iv_analysis
-
Create a virtual environment (recommended):
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies: The
requirements.txtfile lists all necessary Python packages.pip install -r requirements.txt
To install the package in editable mode along with development dependencies:
pip install -e ".[dev]"
Alternatively, you can use the provided installation script which offers environment choices (venv, conda, docker):
bash scripts/install.sh
Configuration
The main configuration for the application is located in mimic_iv_analysis/configurations/config.yaml.
You must update the mimic_data_path in this file to point to the root directory of your local MIMIC-IV dataset (version 3.1 or compatible).
Example config.yaml structure:
data:
mimic_data_path: "/path/to/your/mimic-iv-data" # <-- IMPORTANT: Update this path
app:
port: 8501
theme: "light"
debug: false
# ... other configurations
Usage
Running the Streamlit Dashboard
- Ensure your virtual environment is activated (if you created one).
- Make sure you have configured the
mimic_data_pathinconfig.yaml. - Run the application using:
streamlit run mimic_iv_analysis/visualization/app.py
Alternatively, if the package was installed using pip (e.g., viapip install -e .or from PyPI), you might be able to use a command like:mimic-iv
The dashboard should open in your web browser, typically at http://localhost:8501 (or the port specified in config.yaml).
Install the package from TestPyPI (Example for version 0.5.8)
If a version is available on TestPyPI, you can install it using:
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ mimic_iv_analysis==0.5.8
(Replace 0.5.8 with the desired version if applicable.)
Core Modules Overview
mimic_iv_analysis.core: Contains the fundamental logic for data handling and analysis.data_loader.py: Utilities for loading MIMIC-IV tables efficiently, supporting both CSV and Parquet formats, with options for Dask integration for large datasets.feature_engineering.py: Tools to create meaningful features from raw clinical data, such as order frequencies and temporal sequences.clustering.py: Implements various clustering algorithms (K-Means, Hierarchical, DBSCAN) and LDA topic modeling.filtering.py: Enables applying inclusion and exclusion criteria to the dataset.
mimic_iv_analysis.visualization: Houses the Streamlit application.app.py: The main entry point for the interactive dashboard.app_components/: Contains different tabs and UI elements of the dashboard.
mimic_iv_analysis.configurations: Manages application settings.
Development
Code Style
This project uses the following tools to maintain code quality:
- Black: For code formatting.
- isort: For import sorting.
- Flake8: For style guide enforcement (PEP 8).
- MyPy: For static type checking.
To format your code:
black .
isort .
To check your code:
flake8 .
mypy .
Running Tests
Tests are located in the tests/ directory. To run the test suite:
pytest tests/
To run tests with coverage:
pytest --cov=mimic_iv_analysis tests/
Test configuration can be found in setup_config/pytest.ini (or pytest.ini / pyproject.toml depending on project setup).
Documentation
Further documentation can be found in the documentations/ directory:
DATA_STRUCTURE.md: Describes the expected structure of the MIMIC-IV data.mimic_iv_data_structure.md: Provides an overview of MIMIC-IV tables and identifiers..streamlit/README.md: Guide for deploying the Streamlit application to Streamlit Cloud.- The
documentations/pyhealth/directory contains documentation for the PyHealth library, which might be a dependency or a related project.
Streamlit Cloud Deployment
For deploying the dashboard to Streamlit Cloud, refer to the guide in .streamlit/README.md. This includes steps for repository preparation, secret management, and dependency configuration.
Contributing
Contributions are welcome! Please follow these general steps:
- Fork the repository.
- Create a new feature branch (
git checkout -b feature/your-feature-name). - Make your changes.
- Ensure all tests pass (
pytest tests/). - Format your code (
black .andisort .). - Submit a pull request with a clear description of your changes.
License
This project is licensed under the MIT License. See the LICENSE.md file for details.
Author
- Artin Majdi (msm2024@gmail.com)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mimic_iv_analysis-1.13.1.tar.gz.
File metadata
- Download URL: mimic_iv_analysis-1.13.1.tar.gz
- Upload date:
- Size: 233.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b501992a5cc2d088bb735f3a86e7fe294e9426c415816e03bc4c6354a648ab00
|
|
| MD5 |
93d0a778e849d2a39924f7492a6b1b44
|
|
| BLAKE2b-256 |
3d4e1d2427a07b15689fa94c700fe169b8a6660a49b9744155cf864e33023d58
|
File details
Details for the file mimic_iv_analysis-1.13.1-py3-none-any.whl.
File metadata
- Download URL: mimic_iv_analysis-1.13.1-py3-none-any.whl
- Upload date:
- Size: 245.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
176ab911d96e0da399c1fa5947294050b3d2cbf85ac1789ce92cbb4a06d84db8
|
|
| MD5 |
2e281def1f2a68edd8f06a72449819ac
|
|
| BLAKE2b-256 |
55e898d9c93b62773679d485843d782a56b80ce0144b416a231afe0eeaf39434
|