fMRIprep Automatic Output QC Assessment

Summary of what happened:

fMRIprep Automatic Output QC Assessment

Is there any automatic classifier that take the metrics of IQMs to have image quality criteria? After using nipreps/mriqc I noticed that in the .html reports that are generated, a gadget appears at the top right of the screen to manually classify the image according to its quality. In this case, is there any quantitative criteria to qualify the quality of the image based on the values of the IQMs metrics? In other words, is there a range of values that each of these metrics or exclusion thresholds should have?

On the idea of the automatic classifier …

I was reading in some forums and they mention ‘mriqc_clf’ and ‘mriqc-learn’ but I haven’t found a wiki for either. I also noticed on the command lines they refer to poldracklab/mriqc or poldracklab/fmriprep. I’m working with the nipreps version and I don’t know if ‘mriqc_clf’ and ‘mriqc-learn’ will be implemented for it. Currently esxist any classifier implemented that use the .tsv data from T1 and BOLD to qualify the image quality?

I would welcome any comments.

Command used (and if a helper script was used, a link to the helper script or the command generated):

Version:

nipreps/fmriprep: 23.1.4
nipreps/mriqc: 23.2.0

Environment (Docker, Singularity, custom installation):

Docker

Data formatted according to a validatable standard? Please provide the output of the validator:

BIDS ok, no errors.

Relevant log outputs (up to 20 lines):

Screenshots / relevant information:

Hi @ARIEL_VINA and welcome to Neurostars!

To my knowledge no such tool exists for BOLD, but for T1w, you can use the classifier described in Keshavan, Yeatman, and Roekm 2019, which uses outputs from MRIQC.

Here is some example code:

import pandas as pd
from xgboost import XGBClassifier

# Create dataframe that will be input to classifer
df_classifier = pd.DataFrame()

# Add MRIQC metrics to the dataframe
classifier_keys = ['cjv', 'cnr', 'efc', 'fber', 'fwhm_avg', 'fwhm_x', 'fwhm_y',
 'fwhm_z', 'icvs_csf', 'icvs_gm', 'icvs_wm', 'inu_med', 'inu_range', 'qi_1',
 'qi_2', 'rpve_csf', 'rpve_gm', 'rpve_wm', 'size_x', 'size_y', 'size_z', 'snr_csf',
 'snr_gm', 'snr_total', 'snr_wm', 'snrd_csf', 'snrd_gm', 'snrd_total', 'snrd_wm',
 'spacing_x', 'spacing_y', 'spacing_z', 'summary_bg_k', 'summary_bg_mad', 'summary_bg_mean',
 'summary_bg_median', 'summary_bg_n', 'summary_bg_p05', 'summary_bg_p95', 'summary_bg_stdv',
 'summary_csf_k', 'summary_csf_mad', 'summary_csf_mean', 'summary_csf_median', 'summary_csf_n',
 'summary_csf_p05', 'summary_csf_p95', 'summary_csf_stdv', 'summary_gm_k', 'summary_gm_mad',
 'summary_gm_mean', 'summary_gm_median', 'summary_gm_n','summary_gm_p05', 'summary_gm_p95',
 'summary_gm_stdv', 'summary_wm_k', 'summary_wm_mad', 'summary_wm_mean', 'summary_wm_median',
 'summary_wm_n', 'summary_wm_p05', 'summary_wm_p95', 'summary_wm_stdv', 'tpm_overlap_csf',
 'tpm_overlap_gm', 'tpm_overlap_wm', 'wm2max']

classifier_keys.sort()

t1_mriqc_jsons = [] # DEFINE THIS AS A LIST OF PATHS TO T1W MRIQC JSON FILES
for key in classifier_keys:
    df_classifier[key] = [json.load(open(json_path,'r'))[key] for json_path in t1_mriqc_jsons]

# Prepare model input by getting array of just the MRIQC values
mriqc_model_input = df_classifier.values

# Run the model
model_json_path = "/path/to/mriqc_t1_model.json"
model=XGBClassifier()
model.load_model(model_json_path)
df_classifier['xgbscore'] = model.predict_proba(mriqc_model_input)[:, 1]

The XGB Score is the model QC output. The mriqc_t1_model file is attached as a .txt, please rename it as a .json after (neurostars would not let me upload the json file extension).

Best,
Steven

mriqc_t1_model.txt (263.4 KB)

Hi Steven,

Thank you for the warm welcome to Neurostars! I really appreciate your helpful response and the code snippet you provided for T1w classification. I’ll definitely give it a try!

Best,
ARIEL_VINA