<jupyter_start><jupyter_text>Demonstration of thrombolysis (IVT) + thromebctomy (MT) clinical outcome model Import libraries<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
from clinical_outcome import Clinical_outcome<jupyter_output><empty_output><jupyter_text>Example using a single group/patientThe model takes input for patients or groups identically. Inputs are probabilibilites for that patient or group having different stroke types, and probabilities of being eligable for treatment. The group must have the same times to treatment (e.g. predicting outcome for a group of patients in a small area, all with the same time from onset to arrival at hospital). Create a clinical outcome model object<jupyter_code>outcome = Clinical_outcome()<jupyter_output><empty_output><jupyter_text>Define inputs.<jupyter_code>mimic = np.array([0]) # No mimics
ich = np.array([0.16]) # 16% ICH
nlvo = np.array([0.52]) # 52% NLVO
lvo = np.array([0.32]) # 32% LVO
onset_to_needle = np.array([100]) # 100 min onset to IVT
onset_to_puncture = np.array([150]) # 150 min onset to MT
nlvo_eligible_for_treatment = np.array([0.194]) # 19.4% NLVO treatable
lvo_eligible_for_treatment = np.array([0.313]) # 31.3% LVO treatable
prop_thrombolysed_lvo_receiving_thrombectomy = np.array([1]) # All MT have IVT<jupyter_output><empty_output><jupyter_text>Get probabilities of good outcome.<jupyter_code>outcomes=outcome.calculate_outcome_for_all(
    mimic,
    ich,
    nlvo,
    lvo,
    onset_to_needle,
    onset_to_puncture,
    nlvo_eligible_for_treatment,
    lvo_eligible_for_treatment,
    prop_thrombolysed_lvo_receiving_thrombectomy)
outcomes<jupyter_output><empty_output><jupyter_text>Example using multiple groups or single patientsThe model can prvide results for an array of patients/groups with different characteristics.The model takes input for patients or groups identically. Inputs are probabilibilites for that patient or group having different stroke types, and probabilities of being eligable for treatment. The group must have the same times to treatment (e.g. predicting outcome for a group of patients in a small area, all with the same time from onset to arrival at hospital). Create a clinical outcome model object<jupyter_code>outcome = Clinical_outcome()<jupyter_output><empty_output><jupyter_text>Define inputs. Here we will vary time of onset to IVT from 0 to 600 minutes, with MT (for eligable patients with LVO) being carried out 60 minutes later.<jupyter_code>mimic = np.array([0]*21)
ich = np.array([0.16]*21)
nlvo = np.array([0.52]*21)
lvo = np.array([0.32]*21)
onset_to_needle = np.linspace(0,600,21)
onset_to_puncture = onset_to_needle + 60 
nlvo_eligible_for_treatment = np.array([1]*21)
lvo_eligible_for_treatment = np.array([1]*21)
prop_thrombolysed_lvo_receiving_thrombectomy = np.array([1]*21)<jupyter_output><empty_output><jupyter_text>Get probabilities of good outcome.<jupyter_code>outcomes=outcome.calculate_outcome_for_all(
    mimic,
    ich,
    nlvo,
    lvo,
    onset_to_needle,
    onset_to_puncture,
    nlvo_eligible_for_treatment,
    lvo_eligible_for_treatment,
    prop_thrombolysed_lvo_receiving_thrombectomy)
outcomes<jupyter_output><empty_output><jupyter_text>Plot outcomes<jupyter_code>fig, ax = plt.subplots(figsize=(5,5))
ax.plot(onset_to_needle, outcomes)
ax.set(xlabel='time to IVT (mins)', ylabel='probability of good outcome',
       title='Effect of time to IVT on stroke outcomes')
ax.grid()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08614768174012594, 'fraction_numerical': 0.024613623354321695, 'mean_word_length': 6.221074380165289, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '260321', 'license': 'MIT', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1149, 'n_words': 319, 'path': 'demo.ipynb', 'repo_name': 'MichaelAllen1966/stroke_outcome_algorithm', 'size': '3494'}