{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "6d5d23e4",
"metadata": {
"tags": [
"remove-cell"
]
},
"outputs": [],
"source": [
"# Some configurations to \"beautify\" plots\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"\n",
"mpl.rcParams[\"font.family\"] = \"Libre Franklin\"\n",
"plt.rcParams[\"axes.facecolor\"] = \"white\"\n",
"plt.rcParams[\"savefig.facecolor\"] = \"white\""
]
},
{
"cell_type": "markdown",
"id": "b1fb6f76",
"metadata": {},
"source": [
"# Understanding IQMs generated by MRIQC\n",
"\n",
"The `mriqc-learn` package comes with some example data for users, derived from the MRIQC paper.\n",
"First, we will be using a dataset containing IQMs generated on the open-access ABIDE I dataset which contains manual assessments by human raters.\n",
"Let's explore the dataset:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "091defb4",
"metadata": {},
"outputs": [],
"source": [
"# 1. mriqc-learn comes with a convenience data loader, you'll need to first import it.\n",
"from mriqc_learn.datasets import load_dataset\n",
"\n",
"# 2. Once imported, let's pull up some data\n",
"(train_x, train_y), _ = load_dataset(split_strategy=\"none\")\n",
"\n",
"# 3. Remove non-informative IQMs (image size and spacing)\n",
"train_x = train_x.drop(columns=[\n",
" \"size_x\",\n",
" \"size_y\",\n",
" \"size_z\",\n",
" \"spacing_x\",\n",
" \"spacing_y\",\n",
" \"spacing_z\",\n",
"])\n",
"\n",
"# 4. Keep a list of numeric columns before adding the site as a column\n",
"numeric_columns = train_x.columns.tolist()"
]
},
{
"cell_type": "markdown",
"id": "bc9bed6a",
"metadata": {},
"source": [
"With the argument `split_strategy=\"none\"` we are indicating that we want to obtain the full dataset, without partitioning it in any ways.\n",
"That means variable `train_x` will contain *features* (in other words, the actual IQMs) and `train_y` contains manual assessments, for 1101 T1-weighted MRI images of ABIDE I.\n",
"Both data tables `train_x` and `train_y` have the structure of Pandas DataFrames.\n",
"\n",
"In order to investigate those \"site-effects\", let's add a column to `train_x` with site information:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "e6140a05",
"metadata": {},
"outputs": [],
"source": [
"train_x[\"site\"] = train_y.site"
]
},
{
"cell_type": "markdown",
"id": "5e57ca03",
"metadata": {},
"source": [
"These sites correspond to the following acquisition parameters:\n",
"\n",
"\n",
"\n",
"## A first look on the dataset\n",
"Lets now have a first quick look over the data:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "099ba7c7",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n", " | cjv | \n", "cnr | \n", "efc | \n", "fber | \n", "fwhm_avg | \n", "fwhm_x | \n", "fwhm_y | \n", "fwhm_z | \n", "icvs_csf | \n", "icvs_gm | \n", "... | \n", "summary_wm_median | \n", "summary_wm_n | \n", "summary_wm_p05 | \n", "summary_wm_p95 | \n", "summary_wm_stdv | \n", "tpm_overlap_csf | \n", "tpm_overlap_gm | \n", "tpm_overlap_wm | \n", "wm2max | \n", "site | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "0.383747 | \n", "3.259968 | \n", "0.609668 | \n", "181.619858 | \n", "3.944888 | \n", "3.959924 | \n", "4.039157 | \n", "3.835584 | \n", "0.199774 | \n", "0.449138 | \n", "... | \n", "1000.013428 | \n", "189965.0 | \n", "908.938904 | \n", "1079.413428 | \n", "51.778980 | \n", "0.225944 | \n", "0.525072 | \n", "0.540801 | \n", "0.540213 | \n", "PITT | \n", "
1 | \n", "0.574080 | \n", "2.279440 | \n", "0.606361 | \n", "172.500031 | \n", "3.992397 | \n", "3.877495 | \n", "4.173095 | \n", "3.926602 | \n", "0.203301 | \n", "0.429628 | \n", "... | \n", "1000.033569 | \n", "187992.0 | \n", "901.788293 | \n", "1120.833569 | \n", "67.136932 | \n", "0.223374 | \n", "0.521399 | \n", "0.560238 | \n", "0.571425 | \n", "PITT | \n", "
2 | \n", "0.314944 | \n", "3.998569 | \n", "0.577123 | \n", "273.688171 | \n", "4.016382 | \n", "4.066009 | \n", "4.092888 | \n", "3.890248 | \n", "0.201591 | \n", "0.446495 | \n", "... | \n", "1000.015198 | \n", "188213.0 | \n", "913.847803 | \n", "1067.003662 | \n", "46.623932 | \n", "0.233414 | \n", "0.531020 | \n", "0.556496 | \n", "0.612655 | \n", "PITT | \n", "
3 | \n", "0.418505 | \n", "3.050534 | \n", "0.571343 | \n", "237.531143 | \n", "3.601741 | \n", "3.629409 | \n", "3.627568 | \n", "3.548246 | \n", "0.190612 | \n", "0.468255 | \n", "... | \n", "1000.005981 | \n", "146722.0 | \n", "872.409717 | \n", "1083.139264 | \n", "63.131420 | \n", "0.227282 | \n", "0.528115 | \n", "0.526254 | \n", "0.600312 | \n", "PITT | \n", "
4 | \n", "0.286560 | \n", "4.214082 | \n", "0.550083 | \n", "427.042389 | \n", "3.808350 | \n", "3.839143 | \n", "3.841085 | \n", "3.744823 | \n", "0.162421 | \n", "0.505201 | \n", "... | \n", "1000.004150 | \n", "162584.0 | \n", "900.433481 | \n", "1069.912750 | \n", "50.874363 | \n", "0.195150 | \n", "0.543591 | \n", "0.531606 | \n", "0.603308 | \n", "PITT | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
1096 | \n", "0.428731 | \n", "3.030323 | \n", "0.789654 | \n", "2519.999512 | \n", "3.176760 | \n", "3.166740 | \n", "3.359990 | \n", "3.003550 | \n", "0.169851 | \n", "0.424819 | \n", "... | \n", "1000.034668 | \n", "241117.0 | \n", "902.529590 | \n", "1088.244409 | \n", "56.683868 | \n", "0.162535 | \n", "0.476992 | \n", "0.536843 | \n", "0.537140 | \n", "SBL | \n", "
1097 | \n", "0.610845 | \n", "2.155928 | \n", "0.800116 | \n", "1769.720093 | \n", "3.209497 | \n", "3.164760 | \n", "3.381280 | \n", "3.082450 | \n", "0.170732 | \n", "0.405536 | \n", "... | \n", "1000.039429 | \n", "251136.0 | \n", "903.951080 | \n", "1093.323273 | \n", "57.789230 | \n", "0.193376 | \n", "0.465232 | \n", "0.545695 | \n", "0.564010 | \n", "SBL | \n", "
1098 | \n", "0.461773 | \n", "2.794299 | \n", "0.789859 | \n", "2248.858398 | \n", "3.149920 | \n", "3.112220 | \n", "3.326700 | \n", "3.010840 | \n", "0.165501 | \n", "0.441190 | \n", "... | \n", "1000.036438 | \n", "209298.0 | \n", "891.934216 | \n", "1093.973322 | \n", "61.108639 | \n", "0.198508 | \n", "0.497137 | \n", "0.523571 | \n", "0.564865 | \n", "SBL | \n", "
1099 | \n", "0.457718 | \n", "2.862913 | \n", "0.706924 | \n", "114.865364 | \n", "3.486750 | \n", "3.421200 | \n", "3.881950 | \n", "3.157100 | \n", "0.209701 | \n", "0.381839 | \n", "... | \n", "999.990356 | \n", "234957.0 | \n", "904.907922 | \n", "1101.429980 | \n", "60.045422 | \n", "0.235618 | \n", "0.477310 | \n", "0.563352 | \n", "0.534626 | \n", "MAX_MUN | \n", "
1100 | \n", "0.419648 | \n", "3.129415 | \n", "0.783152 | \n", "116.484947 | \n", "3.579490 | \n", "3.538990 | \n", "3.991800 | \n", "3.207680 | \n", "0.215531 | \n", "0.402868 | \n", "... | \n", "1000.005981 | \n", "244797.0 | \n", "904.572144 | \n", "1095.835376 | \n", "58.381458 | \n", "0.227491 | \n", "0.492317 | \n", "0.549036 | \n", "0.573174 | \n", "MAX_MUN | \n", "
1101 rows × 63 columns
\n", "