Skip to content
Snippets Groups Projects
metrics.ipynb 37.4 KiB
Newer Older
Bart Leenheer's avatar
Bart Leenheer committed
    "    \n",
    "    # Calculate Hausdorff distance for ES\n",
    "    hd_lv_es = max([hausdorff_distance(label_pred_ES_LV[i][:,:,y], label_gt_ES_LV[i][:,:,y], distance='euclidean') for y in range(label_pred_ES_LV[i].shape[2])])\n",
    "    hd_wall_es = max([hausdorff_distance(label_pred_ES_wall[i][:,:,y], label_gt_ES_wall[i][:,:,y], distance='euclidean') for y in range(label_pred_ES_wall[i].shape[2])])\n",
    "    hd_rv_es = max([hausdorff_distance(label_pred_ES_RV[i][:,:,y], label_gt_ES_RV[i][:,:,y], distance='euclidean') for y in range(label_pred_ES_RV[i].shape[2])])\n",
    "    hd_LV_ES.append(hd_lv_es)\n",
    "    hd_wall_ES.append(hd_wall_es)\n",
    "    hd_RV_ES.append(hd_rv_es)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5c4c95a1",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(len(hd_LV_ED))\n",
    "print(hd_wall_ES[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2b9b673e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Calculations of average HD\n",
    "# ED\n",
    "HD_LV_ED_mean = statistics.mean(hd_LV_ED)\n",
    "HD_RV_ED_mean = statistics.mean(hd_RV_ED)\n",
    "HD_MYO_ED_mean = statistics.mean(hd_wall_ED)\n",
    "\n",
    "print('The average hd of the left ventricle EDV is ', HD_LV_ED_mean)\n",
    "print('The average hd of the right ventricle EDV is ', HD_RV_ED_mean)\n",
    "print('The average hd of the myocardium EDV is ', HD_MYO_ED_mean)\n",
    "\n",
    "HD_LV_ES_mean = statistics.mean(hd_LV_ES)\n",
    "HD_RV_ES_mean = statistics.mean(hd_RV_ES)\n",
    "HD_MYO_ES_mean = statistics.mean(hd_wall_ES)\n",
    "\n",
    "print('The average hd of the left ventricle ESV is ', HD_LV_ES_mean)\n",
    "print('The average hd of the right ventricle ESV is ', HD_RV_ES_mean)\n",
    "print('The average hd of the myocardium ESV is ', HD_MYO_ES_mean)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
Bart Leenheer's avatar
Bart Leenheer committed
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}