MReyeQC is a tool for creating a regression model to predict the quality of eye MRI images. This project is inspired by and based on FetMRQC and MRIQC frameworks.
The main workflow consists of:
- Preprocessing a dataset of ocular MRI images and their segmentations.
- Computing a set of Image Quality Metrics (IQMs) using MRIQC tools.
- Training models (either regression or binary classification) to predict an image's quality from its IQMs.
To install MReyeQC, start by creating a new conda environment. Python 3.9 is recommended.
conda create --name MReyeQC python=3.9
conda activate MReyeQCThen, install the project and its dependencies by cloning this repository and running:
pip install -e .This section describes the steps required to add new images to the dataset, preprocess them, and compute the Image Quality Metrics (IQMs).
-
Add Images Place your MRI images in NIfTI format into the
data/img/directory. -
Index New Images Run the
add_new_img.pyscript. This script prepares the new data for the subsequent steps. Warning: Do not run this script twice in a row, as it deletes tracking columns that are only generated on the first run. -
Prepare Segmentation Masks Run the following scripts sequentially to generate and format the binary masks required for IQM calculation:
add_new_seg.pyconvert_to_binary_mask.py
-
Generate BIDS List Use the
qc_list_bids_csvcommand to create a CSV file listing your images and their corresponding masks. Replace<path_to_project>with the absolute path to the project's root directory.qc_list_bids_csv \ --bids_dir "<path_to_project>/data/img" \ --mask_patterns_base "<path_to_project>/data/mask" \ --mask_patterns "sub-{subject}_mask.nii.gz" \ --out_csv "<path_to_project>/data/bids_csv/bids_csv.csv" \ --suffix T1w \ --no-anonymize_name -
Add Ratings Run the following scripts to integrate the quality ratings (manual or existing) into the CSV file:
add_average_rating_to_bids.pyadd_new_rating.py
-
Compute IQMs Finally, run the
srqc_compute_iqmscommand to extract the quality metrics from the images and masks. The output will be saved toIQA.csv.srqc_compute_iqms \ --bids_csv "<path_to_project>/data/bids_csv/bids_csv_rating.csv" \ --out_csv "<path_to_project>/data/IQA.csv"
Once the IQMs are computed and the ratings have been added, you can train the quality prediction models.
To do this, run one of the following Jupyter notebooks, depending on the desired model type:
train_model_MREye_3_models_regression.ipynb: To train a regression model that predicts a continuous quality score.train_model_MREye_3_models_binary.ipynb: To train a classification model that predicts a binary quality label (e.g., "good" vs. "bad").
This project includes several utility scripts to help with data management and analysis.
add_new_IQM.py: Adds IQMs from MRIQC to theIQA.csvfile.average_rating.py: Calculates the average rating from files in thedata/ratingdirectory and saves the result todata/bids_csv/rating.csv.change_name_to_report_name_83.py: Updates the 'name' column in theIQA.csvfile based on mappings from an auxiliary CSV file by extracting a common subject ID.correlation.py: Calculates the correlation between the Image Quality Metrics (IQMs) and the manual ratings.remove_column.py: Removes specified columns from theIQA.csvfile.
Sanchez, T., Esteban, O., Gomez, Y., Eixarch, E., Bach Cuadra, M. (2023). "FetMRQC: Automated Quality Control for Fetal Brain MRI." PIPPI MICCAI Workshop 2023. https://doi.org/10.1007/978-3-031-45544-5_1
Esteban O, Birman D, Schaer M, Koyejo OO, Poldrack RA, Gorgolewski KJ; MRIQC: Advancing the Automatic Prediction of Image Quality in MRI from Unseen Sites; PLOS ONE 12(9):e0184661; doi:10.1371/journal.pone.0184661.