Swiftpack.co - Package - eschenfeldt/stroke-swift


This package implements a Swift 4.1 version of the stroke pre-hospital triage model at https://github.com/namyaila/stroke, extended to allow comparisons of multiple primary stroke centers.


The StrokeModel package exposes the following classes:

  • StrokeModel, an encapsulating class that provides public functions for running the model
  • Inputs, a class containing all of the direct model inputs, and Sex, an enum for patient sex (one of the model inputs)
  • StrokeCenter, an open class storing information about a stroke center under consideration, including travel time(s)
  • SingleRunResults and MultiRunResults, encapsulating model outputs, along with the struct Strategy defining the possible triage decisions
  • Race, an enum namespace encapsulating several enums and the function scoreFrom for use in computing the RACE score, and static functions toNIHSS and fromNIHSS for converting between RACE and NIHSS.

The simplest way to run the model is to use the optional initializer

Inputs(sex: Sex, age: Int, race: Double, timeSinceSymptoms: Double,
       primaryTimes: [Double], transferTimes: [Double],
       comprehensiveTimes: [Double])

to generate model inputs (this will be nil if and only if primaryTimes and transferTimes are different lengths) then create a model object via StrokeModel(inputs) and run it using either StrokeModel.run or StrokeModel.runWithVariance. The results class exposes a string property that summarizes results, along with various constants for more details.

Linux support

The package was developed and tested on macOS, but should also run on Linux. In testing (on the Windows Subsystem for Linux), multithreading via Grand Central Dispatch worked only intermittently, so runWithVariance includes a useGCD argument that can revert all computations to a more stable but slower single-threaded mode which is safer on Linux. Tests on Linux do not use GCD.


Stars: 0
Help us keep the lights on


Used By



0.2.0 - Apr 4, 2018

0.1.0 - Apr 3, 2018