{ "cells": [ { "cell_type": "markdown", "id": "c9b616f1-95bf-4f1b-8e64-6db01abe7dc2", "metadata": {}, "source": [ "# Paper creation\n", "\n", "This document provides more information on the main results in the academic paper about the stroke outcome model.\n", "\n", "For each result, there are links to the pages in this online book where the data was created, and information on accessing the data shown in the paper's figures and tables or referenced in the text.\n", "\n", "The paper is _\"Modelling disability-level and utility outcome in stroke patients depending on time to intravenous thrombolysis and mechanical thrombectomy. Application to England and Wales\"_\n", "\n", "![Preview of the first page of the stroke outcome paper.](images/paper_preview.png) \n", "Preview of the first page of the stroke outcome paper." ] }, { "cell_type": "markdown", "id": "45441e7f-27ae-4958-85cd-189dd3c01a67", "metadata": {}, "source": [ "## mRS distribution derivation\n", "\n", "Table 1 contains the derived mRS distributions:" ] }, { "cell_type": "code", "execution_count": 9, "id": "0a22edaa-94bf-4ab3-a6c8-d9c3f0abac61", "metadata": {}, "outputs": [], "source": [ "import stroke_outcome.outcome_utilities\n", "\n", "mrs_dists, mrs_dists_notes = (\n", " stroke_outcome.outcome_utilities.import_mrs_dists_from_file())" ] }, { "cell_type": "code", "execution_count": 10, "id": "965ced00-b37c-46c9-bd53-04118c071b4e", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
mRS<=0mRS<=1mRS<=2mRS<=3mRS<=4mRS<=5mRS<=6
Stroke type
pre_stroke_nlvo0.5830.7460.8500.9510.9931.0001
pre_stroke_lvo0.4080.5520.6720.8380.9561.0001
no_treatment_lvo0.0500.1290.2650.4290.6760.8111
no_treatment_nlvo0.1980.4600.5800.7080.8560.9181
no_effect_nlvo_ivt_deaths0.1960.4550.5740.7010.8470.9081
no_effect_lvo_ivt_deaths0.0480.1240.2550.4140.6530.7831
no_effect_lvo_mt_deaths0.0480.1240.2550.4120.6490.7791
t0_treatment_nlvo_ivt0.4450.6420.7520.8620.9410.9671
t0_treatment_lvo_ivt0.1400.2330.3610.5220.7300.8381
t0_treatment_lvo_mt0.3060.4290.5480.7070.8510.9151
\n", "
" ], "text/plain": [ " mRS<=0 mRS<=1 mRS<=2 mRS<=3 mRS<=4 mRS<=5 \\\n", "Stroke type \n", "pre_stroke_nlvo 0.583 0.746 0.850 0.951 0.993 1.000 \n", "pre_stroke_lvo 0.408 0.552 0.672 0.838 0.956 1.000 \n", "no_treatment_lvo 0.050 0.129 0.265 0.429 0.676 0.811 \n", "no_treatment_nlvo 0.198 0.460 0.580 0.708 0.856 0.918 \n", "no_effect_nlvo_ivt_deaths 0.196 0.455 0.574 0.701 0.847 0.908 \n", "no_effect_lvo_ivt_deaths 0.048 0.124 0.255 0.414 0.653 0.783 \n", "no_effect_lvo_mt_deaths 0.048 0.124 0.255 0.412 0.649 0.779 \n", "t0_treatment_nlvo_ivt 0.445 0.642 0.752 0.862 0.941 0.967 \n", "t0_treatment_lvo_ivt 0.140 0.233 0.361 0.522 0.730 0.838 \n", "t0_treatment_lvo_mt 0.306 0.429 0.548 0.707 0.851 0.915 \n", "\n", " mRS<=6 \n", "Stroke type \n", "pre_stroke_nlvo 1 \n", "pre_stroke_lvo 1 \n", "no_treatment_lvo 1 \n", "no_treatment_nlvo 1 \n", "no_effect_nlvo_ivt_deaths 1 \n", "no_effect_lvo_ivt_deaths 1 \n", "no_effect_lvo_mt_deaths 1 \n", "t0_treatment_nlvo_ivt 1 \n", "t0_treatment_lvo_ivt 1 \n", "t0_treatment_lvo_mt 1 " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mrs_dists" ] }, { "cell_type": "code", "execution_count": 12, "id": "cc7997ce-2618-4c92-ab4b-78c80777b0f6", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['# If these change, please ensure the no-effect times are still correct.',\n", " '#',\n", " '# Acronyms: No-effect times:',\n", " '# lvo: large-vessel occlusion IVT: 378mins (6.3hr)',\n", " '# nlvo: non-large-vessel occlusion MT: 480mins (8hr)',\n", " '# ivt: intra-veneous thrombolysis',\n", " '# mt: mechanical thrombectomy',\n", " '# t0: time zero, zero minutes after stroke onset.',\n", " '#',\n", " '']" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mrs_dists_notes.split('\\n')" ] }, { "cell_type": "markdown", "id": "0d7b99c7-b743-4317-92d4-78c1c72b86eb", "metadata": {}, "source": [ "Data creation:\n", "+ [Derivation of mRS distributions from reference data](https://samuel-book.github.io/stroke_outcome/outcome_model_methods/01_mrs_dist_derivation.html)\n", "\n", "Data behind the table:\n", "+ Stored on [GitHub](https://github.com/stroke-modelling/stroke-outcome/tree/main/stroke_outcome/data):\n", " + Location: `stroke_outcome/data/` \n", " + File name for mRS distributions: `mrs_dist_probs_cumsum.csv` \n", " + File name for utility weight conversions: `utility_dists.csv`\n", "+ Or install the stroke-outcome package and import the data as above.\n" ] }, { "cell_type": "markdown", "id": "6b5b4919-5e96-47f2-94bc-7da250ec0eab", "metadata": {}, "source": [ "## Probability with time\n", "\n", "Figure 1 contains the mRS probability distributions with time.\n", "\n", "![Figure from the stroke outcome paper with probabilities of each mRS score varying with time to treatment.](../outcome_model_methods/images/probs_with_time.png)\n", "\n", "Data creation:\n", "+ [Resulting probabilities with time](../outcome_model_methods/03_probs_with_time_results)\n", "\n", "The data behind the figure is stored on [GitHub](https://github.com/samuel-book/stroke_outcome) in the directory `outcome_model_methods/output`. The mRS values given are cumulative probabilities, e.g. the `mRS<=2` column contains the sum of the probabilities of mRS of zero, one and two.\n", "\n", "Data behind the figure:\n", "+ nLVO with IVT: `probs_with_time_nlvo_ivt.csv`\n", "+ LVO with IVT: `probs_with_time_lvo_ivt.csv`\n", "+ LVO with MT: `probs_with_time_lvo_mt.csv`\n", "\n", "Supplementary data:\n", "+ [Calculating outcome probabilities with time to treatment](../outcome_model_methods/02_probs_with_time) - explains how the probabilities with time are calculated." ] }, { "cell_type": "markdown", "id": "20f25e6c-d999-439e-94d5-c1de1f071358", "metadata": {}, "source": [ "## Geographic modelling (generic)\n", "\n", "Figure:\n", "\n", "![Figure from the stroke outcome paper with circle plots showing variation in outcomes with a generic geography.](../general_results/images/circle_plots_stroke_type_all_60_60.jpg)\n", "\n", "Data creation:\n", "+ [Distance-based treatment effects for many cohorts](../general_results/05_geography_outcomes.html)\n", "\n", "Figure creation:\n", "+ [Plot distance-based treatment effects for many cohorts](../general_results/05_geography_outcomes_plots.html)\n", "\n", "Supplementary info:\n", "+ [Example patient population](../general_results/01b_population.ipynb)\n", "\n", "Data behind the figure: Available on [Github](https://github.com/samuel-book/stroke_outcome/tree/main/general_results/output) in the directory `general_results/output`:\n", "\n", "Times:\n", "+ `generic_geography_grid_time_travel_directly_to_ivt.csv` - time grid of travel directly to IVT centre in the middle of the grid.\n", "+ `generic_geography_grid_time_travel_directly_diff.csv` - time grid of difference in travel times to IVT centre in middle and MT centre at bottom of grid.\n", "+ `generic_geography_dict_travel_grid.csv` - dictionary of information needed to plot the time grids to scale.\n", "\n", "Outcomes:\n", "+ `generic_geography_df_lvo_diff.csv` - outcomes for the LVO patients\n", "+ `generic_geography_df_nlvo_ivt_diff.csv` - outcomes for the nLVO patients \n", "+ `generic_geography_df_mixed_diff.csv` - outcomes for the mixed treated ischaemic population\n", "\n", "An example of how to import this data into Python for plotting is given in the Figure Creation notebook linked above." ] }, { "cell_type": "markdown", "id": "5d29e5c1-8037-4db4-8dab-5f6544b6fdba", "metadata": {}, "source": [ "## Geographic modelling (England and Wales)\n", "\n", "Data creation:\n", "+ [Model outcomes for drip’and’ship vs mothership based on geography](../england_wales/01_model_outcomes.html)\n", "+ [Combine populations for weighted outcomes](../england_wales/01c_weighted_outcomes.html)\n", "\n", "Supplementary info:\n", "+ [Admission prediction](../admission_prediction/01_msoa_regression.html)\n", "+ [Example patient population](../general_results/01b_population.ipynb)\n" ] }, { "cell_type": "markdown", "id": "87c1bf20-613b-4196-ba9e-02d654b7b184", "metadata": {}, "source": [ "### Maps\n", "\n", "![Figure from the stroke outcome paper with maps of England and Wales showing variation in added utility.](../england_wales/output/added_utility_nine_in_one.jpg)\n", "\n", "Figure creation:\n", "+ [Mapping LSOA results](../england_wales/02_lsoa_analysis_added_utility.html)\n", "\n", "The data behind the figure is stored on [GitHub](https://github.com/samuel-book/stroke_outcome) in the directory `england_wales/output`.\n", "\n", "Data behind the figure:\n", "+ `fig_data_englandwales_maps_added_utility.csv`\n", "\n", "Supplementary data:\n", "+ Outlier regions mentioned in the Discussion: [Mapping outliers](../england_wales/04_outlier_areas.html)" ] }, { "cell_type": "markdown", "id": "0a3fcdc3-fe42-4921-9f9a-e7c450fe310b", "metadata": {}, "source": [ "### mRS distributions\n", "\n", "![Figure from the stroke outcome paper with mRS distributions post-treatment averaged across England and Wales.](../england_wales/output/mrs_dists_redirection_areas.png)\n", "\n", "Figure creation:\n", "+ [National mRS distributions](../england_wales/03_national_mrs_dists.html)\n", "\n", "The data behind the figure is stored on [GitHub](https://github.com/samuel-book/stroke_outcome) in the directory `england_wales/output`.\n", "\n", "Data behind the figure:\n", "+ Bars: `fig_data_mrs_dists.csv`\n", "+ Errorbars: `fig_data_mrs_dists_std.csv`\n", "\n", "Supplementary data:\n", "+ Mean shift in mRS, added utility, proportion with mRS<=2: `fig_data_mrs_dists_means.csv` __CHECK THIS - file not uploaded yet?__" ] }, { "cell_type": "markdown", "id": "393603d1-8dde-4376-b2ac-bac3e786367e", "metadata": {}, "source": [ "## Data creation date\n", "\n", "The code was last re-run and so the data created on:" ] }, { "cell_type": "code", "execution_count": 7, "id": "5d5bcbc6-f4af-418f-a9e2-1fe3c3df4d06", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "19 July 2024\n" ] } ], "source": [ "import datetime\n", "\n", "print(datetime.date.today().strftime('%d %B %Y'))" ] }, { "cell_type": "markdown", "id": "ea551fdd-4fc5-4c17-9986-4ee7f3de0c04", "metadata": {}, "source": [ "## All package versions\n", "\n", "The full list of packages used is provided in a conda environment.\n", "\n", "The packages are:" ] }, { "cell_type": "code", "execution_count": 1, "id": "98f27602-2f80-4cb5-abd5-bb8ba23b94c2", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "name: stroke-outcome\n", "channels:\n", " - defaults\n", " - conda-forge\n", "dependencies:\n", " - jupyterlab\n", " - matplotlib\n", " - numpy\n", " - pip\n", " - pandas\n", " - python=3.10\n", " - scikit-learn\n", " - pip:\n", " - geopandas\n", " - contextily\n", " - mapclassify\n", " - stroke-outcome\n", " - stroke_maps\n", " \n", "\n" ] } ], "source": [ "import os\n", "\n", "with open(os.path.join('..', 'environment.yml'), 'r') as f:\n", " print(f.read())" ] }, { "cell_type": "markdown", "id": "03d88700-0810-43dd-b9d7-78afc87d41df", "metadata": {}, "source": [ "## Custom package versions\n", "\n", "The versions of the custom packages used were:" ] }, { "cell_type": "code", "execution_count": 5, "id": "80d8f32d-25da-4fa1-9e2f-6376bfb865d9", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'0.1.6'" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import stroke_outcome\n", "\n", "stroke_outcome.__version__" ] }, { "cell_type": "code", "execution_count": 6, "id": "227ae155-fdd5-44f3-913e-ee7c7c8a03a7", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'0.5.0'" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import stroke_maps\n", "\n", "stroke_maps.__version__" ] }, { "cell_type": "markdown", "id": "f62a9c12-4ee1-476f-9c03-b77afa014f70", "metadata": {}, "source": [ "The code in the packages for those version numbers can be seen by:\n", "\n", "+ Downloading a specific version of the package. For example, instead of the usual: \n", " `pip install stroke-outcome` \n", " You could download: \n", " `pip install stroke-outcome==0.1.5` \n", " And continue to use the package as normal.\n", "\n", "+ GitHub: on the main repository page, the \"Releases\" section lists all of the versions. The tag with the version number opens the branch with a copy of the code at that time.\n", "\n", "![Screenshot of a GitHub repository with the \"Releases\" section highlighted.](./images/github_releases_annotated.png)\n", "![Screenshot of a GitHub \"Releases\" page with a package version number highlighted.](./images/github_version_annotated.png)\n", "\n", "+ PyPI: the main project page has a \"Release history\" section. In it there are links to all previous versions of the package.\n", "\n", "![Screenshot of a PyPI project page with the \"Release history\" section highlighted.](./images/pypi_project_page_annotated.png)\n", "![Screenshot of a PYPI project's \"Release history\" page with a package version number highlighted.](./images/pypi_release_history_annotated.png)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.16" } }, "nbformat": 4, "nbformat_minor": 5 }