Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge #1

Open
wants to merge 440 commits into
base: matt
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
440 commits
Select commit Hold shift + click to select a range
b36bb69
add dim reductions script
sbhattacharyay Apr 24, 2020
c549428
add R files
sbhattacharyay Apr 24, 2020
5dd1161
add R files
sbhattacharyay Apr 24, 2020
e06ca50
add glm classification
sbhattacharyay Apr 25, 2020
fadd034
add glm classification
sbhattacharyay Apr 25, 2020
84e8315
update glm classification
sbhattacharyay Apr 26, 2020
ab45bd5
update glm classification
sbhattacharyay Apr 26, 2020
6eb9742
add 12 month prediction
sbhattacharyay Apr 26, 2020
bcb70ad
add 12 month prediction
sbhattacharyay Apr 26, 2020
345d86b
added auc plots
Apr 27, 2020
733b08e
added auc plots
Apr 27, 2020
ceef735
added auc plots
Apr 27, 2020
1f9e0c9
added auc plots
Apr 27, 2020
27642ba
new auc plots
Apr 27, 2020
6c5e430
new auc plots
Apr 27, 2020
27088b1
new auc plots
Apr 27, 2020
9f36c81
new auc plots
Apr 27, 2020
c47a051
new auc plots
Apr 27, 2020
a265114
new auc plots
Apr 27, 2020
cfebc5c
add original recording scripts
sbhattacharyay Apr 28, 2020
ef39420
add original recording scripts
sbhattacharyay Apr 28, 2020
6826bb2
rename master script files
sbhattacharyay Apr 28, 2020
37627be
rename master script files
sbhattacharyay Apr 28, 2020
b3b4976
Add LDA, kNN, and SVM classification
sbhattacharyay Apr 29, 2020
c3183d2
Add LDA, kNN, and SVM classification
sbhattacharyay Apr 29, 2020
7d93afa
new auc plots
Apr 30, 2020
f2731d7
new auc plots
Apr 30, 2020
9f167e3
new auc plots
Apr 30, 2020
cf49909
new auc plots
Apr 30, 2020
db2fcac
adding tables
Apr 30, 2020
92baf5c
adding tables
Apr 30, 2020
e54eab2
adding tables
Apr 30, 2020
f45ff83
adding tables
Apr 30, 2020
99a09e0
add AUC barplots
sbhattacharyay Apr 30, 2020
60fc472
add AUC barplots
sbhattacharyay Apr 30, 2020
646b22e
adding prc plots
May 1, 2020
79c8ab7
adding prc plots
May 1, 2020
84e3a9b
adding prc plots
May 1, 2020
41aa0e3
adding prc plots
May 1, 2020
5ad978f
better color distinction
May 1, 2020
ac09d39
better color distinction
May 1, 2020
f835804
added shiny app
May 5, 2020
788e376
added shiny app
May 5, 2020
386eb8a
add prediction function capability to Shiny app
sbhattacharyay May 6, 2020
429b519
add prediction function capability to Shiny app
sbhattacharyay May 6, 2020
02d179f
updates
sbhattacharyay May 7, 2020
84ede66
updates
sbhattacharyay May 7, 2020
b86522a
fix shiny classification fxn
sbhattacharyay May 7, 2020
5bf544c
fix shiny classification fxn
sbhattacharyay May 7, 2020
2c59a38
some changes to app
May 7, 2020
e338660
some changes to app
May 7, 2020
a78aba5
modified app
May 7, 2020
26ef206
modified app
May 7, 2020
1587fda
added functions
May 7, 2020
c708631
added functions
May 7, 2020
7c9d096
update classification function to code outcomes as numeric
sbhattacharyay May 7, 2020
15ecb60
update classification function to code outcomes as numeric
sbhattacharyay May 7, 2020
f1fb83d
changes to app
May 7, 2020
1c712e8
changes to app
May 7, 2020
c8a83e8
changes to classification and stratified CV
sbhattacharyay May 8, 2020
d54f017
changes to classification and stratified CV
sbhattacharyay May 8, 2020
8999c47
check apache prediction
mwang103 May 9, 2020
fd09246
check apache prediction
mwang103 May 9, 2020
f3060a1
add grid search code
May 14, 2020
36952b7
add grid search code
May 14, 2020
67768ee
add grid search code
May 14, 2020
14def59
add grid search code
May 14, 2020
2355042
add grid search code
May 14, 2020
eb67879
add grid search code
May 14, 2020
459daee
Merge branch 'master' of https://github.com/sbhattacharyay/bims
May 14, 2020
f570564
add grid search code
May 14, 2020
057bff2
add grid search code
May 14, 2020
d776b23
add grid search
May 14, 2020
f1209fc
Delete hi.png
ejoshi1 May 14, 2020
e6ac531
remove large files
sbhattacharyay May 20, 2020
3ee7b86
add placeholder READMEs
sbhattacharyay May 20, 2020
8fe0b32
rename TOD files
sbhattacharyay May 21, 2020
2a2fbcb
MARCC updates
sbhattacharyay May 21, 2020
9c93589
new SLURM outputs
May 21, 2020
06496fb
update bash scripts
sbhattacharyay May 21, 2020
4040ff9
minor update to bash scripts
sbhattacharyay May 21, 2020
2d718b3
clean plots
sbhattacharyay May 22, 2020
200c224
complete upscale of sample size
sbhattacharyay May 23, 2020
798c4c6
updates to classification scripts
sbhattacharyay May 24, 2020
d880987
updates to classification
sbhattacharyay May 24, 2020
af7f2e1
updates to classification
sbhattacharyay May 24, 2020
b9bb20b
add new classification script
sbhattacharyay May 24, 2020
0221b2d
updating master09
May 25, 2020
45a3e06
updates to master 9
sbhattacharyay May 25, 2020
5176668
updates to master9
sbhattacharyay May 25, 2020
283e4e7
update master09 to fix minor error
sbhattacharyay May 25, 2020
e1c6080
add neural net models
sbhattacharyay May 25, 2020
e0ae030
add performance metric calculations
sbhattacharyay May 26, 2020
1c0f5c7
add metric plotting capability
sbhattacharyay May 26, 2020
b22d6a1
revise metric plotting
sbhattacharyay May 27, 2020
6fad2a1
Update README.md
sbhattacharyay May 27, 2020
700532a
updatedd R scripts
sbhattacharyay May 28, 2020
41f7a16
commit MARCC script changes
sbhattacharyay May 28, 2020
89f5b45
commit MARCC script changes
sbhattacharyay May 28, 2020
52cf162
add bash scripts for grid search
sbhattacharyay May 28, 2020
02a6a78
debug train model script
sbhattacharyay May 29, 2020
9535db3
upload fail slurm outputs
May 29, 2020
28096d3
Update README.md
sbhattacharyay May 29, 2020
db4463a
precrec plots added
May 29, 2020
0febc0e
update grid search script for intermittent saving functionality
Jun 1, 2020
efee831
DOS 2 UNIX conversion of R script
Jun 1, 2020
dc5f2c1
new grid search changes
Jun 5, 2020
14783e2
add sensor time info
Jun 6, 2020
ec58334
new motion feature extraction script
Jun 6, 2020
84e55a0
edits
mwang103 Jun 9, 2020
8869f5c
updates to imputation and data saving strategy
Jun 9, 2020
beea0f0
new bed correction information
Jun 10, 2020
7f31983
AUC and PR plots in MATLAB
Jun 12, 2020
534c551
Delete .DS_Store
sbhattacharyay Jun 17, 2020
8ee8115
Delete .Rhistory
sbhattacharyay Jun 17, 2020
0cc98b5
clean repo
Jun 17, 2020
e0f99a1
Merge branch 'master' of https://github.com/sbhattacharyay/bims
Jun 17, 2020
cb7bbdd
add segmentation classification files to repo
Jun 20, 2020
2373f39
transfer old files to archives
Jun 20, 2020
d860911
update marcc files
Jun 21, 2020
9349da7
updates for marcc
Jun 22, 2020
60c6b9d
updates
Jun 23, 2020
f04f08f
updates for MARCC
Jun 23, 2020
6f73007
ML updates for MARCC
Jun 23, 2020
c8a7424
updates for eshan
Jun 24, 2020
24b9503
add outerfolds to git repo
Jun 24, 2020
8ea30e9
clean functions folder
Jun 24, 2020
2457b22
add clinical variable info
Jun 24, 2020
0407b64
housekeeping repo
Jun 24, 2020
e525e3f
merge save for marcc
Jun 24, 2020
034f69c
Merge branch 'master' of https://github.com/sbhattacharyay/bims
Jun 24, 2020
9aa6944
updates to master01
Jun 24, 2020
70902ec
additional housekeeping of repo
Jun 24, 2020
8af5634
MARCC job for ML tuning
Jun 25, 2020
6a50f16
Merge branch 'master' of https://github.com/sbhattacharyay/bims
Jun 25, 2020
af7bc8f
edits
mwang103 Jun 25, 2020
542a017
minor change to master06
Jun 25, 2020
eb51cd3
Merge branch 'master' of https://github.com/sbhattacharyay/bims
Jun 25, 2020
512ac36
add missing data and recording time calculation
mwang103 Jun 26, 2020
a8e7d31
uMerge branch 'master' of https://github.com/sbhattacharyay/bims
Jun 26, 2020
48bbf3c
updates to clinical data examination
Jun 26, 2020
a9317b3
updates to finish MARCC task
Jun 26, 2020
e1fdab3
Merge branch 'master' of https://github.com/sbhattacharyay/bims
Jun 26, 2020
8043312
5 and 10 min ML tuning scripts
Jun 26, 2020
7830071
Merge branch 'master' of https://github.com/sbhattacharyay/bims
Jun 26, 2020
8c0c673
dos2unix updates
Jun 26, 2020
c2e863e
update finish script
Jun 26, 2020
faf8312
finish 30 min MARCC
Jun 27, 2020
90ae9a7
run pure data organization
Jul 5, 2020
fcb7b04
UNIX2DOS
Jul 5, 2020
def8ff2
reverse run
Jul 5, 2020
6364d0c
Merge branch 'master' of https://github.com/sbhattacharyay/bims
Jul 5, 2020
50fd028
plotting functions updated
Jul 5, 2020
6b76507
edits
mwang103 Jul 6, 2020
580a19a
GCS table
mwang103 Jul 6, 2020
e1fda8e
find x min before gcs noted
mwang103 Jul 6, 2020
ed57664
edits
mwang103 Jul 6, 2020
436e84a
edits
mwang103 Jul 7, 2020
89f5aa2
edits
mwang103 Jul 7, 2020
5d162c9
edits
mwang103 Jul 8, 2020
269e167
add new accel file
Jul 14, 2020
1152b6e
Merge branch 'master' of https://github.com/sbhattacharyay/bims
Jul 14, 2020
be648b8
Merge branch 'master' of https://github.com/sbhattacharyay/bims
Jul 17, 2020
3789881
MARCC housekeeping
Jul 17, 2020
0bbd3ea
housekeeping changes
sbhattacharyay Sep 2, 2020
c3c1581
marcc changes
Sep 2, 2020
db8e52c
Merge branch 'master' of https://github.com/sbhattacharyay/bims
Sep 2, 2020
0e4f569
add python script
sbhattacharyay Sep 4, 2020
8285913
Merge branch 'master' of https://github.com/sbhattacharyay/bims
sbhattacharyay Sep 4, 2020
2f15b24
repo housekeeping
sbhattacharyay Sep 12, 2020
4e239b5
repo housekeeping
sbhattacharyay Sep 12, 2020
f114beb
Update README.md
sbhattacharyay Sep 12, 2020
2a1465b
clean repo
sbhattacharyay Sep 13, 2020
fdc5fee
update scripts
sbhattacharyay Oct 6, 2020
a632c3e
nonconsequential update
Oct 6, 2020
0e8106f
Merge branch 'master' of https://github.com/sbhattacharyay/bims
Oct 6, 2020
73d1e9e
update changes to accel imp script
sbhattacharyay Oct 9, 2020
65bc5eb
Merge branch 'master' of https://github.com/sbhattacharyay/bims
Oct 9, 2020
a87e050
add checkpoint to impuitation
sbhattacharyay Oct 9, 2020
c4b70d3
Merge branch 'master' of https://github.com/sbhattacharyay/bims
Oct 9, 2020
e29a62f
finish Amelia
sbhattacharyay Oct 9, 2020
60a9a65
save changes on marcc
Oct 9, 2020
1dfe782
Merge branch 'master' of https://github.com/sbhattacharyay/bims
Oct 9, 2020
a00acea
Dos2UNIX
Oct 9, 2020
ca5d26c
correction to finish script
sbhattacharyay Oct 9, 2020
28ad1c7
changes to finish amelia
Oct 10, 2020
c043912
update to amelia
Oct 10, 2020
ff733d7
add master 8
sbhattacharyay Oct 14, 2020
63fd114
Merge branch 'master' of https://github.com/sbhattacharyay/bims
sbhattacharyay Oct 14, 2020
6a9ba4a
save finish amelia
Oct 14, 2020
adcecc2
Merge branch 'master' of https://github.com/sbhattacharyay/bims
Oct 14, 2020
90cc8cd
marcc to local transfer
Oct 15, 2020
809171a
edits to master8
sbhattacharyay Oct 15, 2020
5abde41
updates to master 8
Oct 18, 2020
71321ef
first pass of detection ML
sbhattacharyay Oct 20, 2020
21b3c69
updates to master9
sbhattacharyay Oct 20, 2020
1e39d0f
update files
sbhattacharyay Oct 24, 2020
c09bae2
save local changes
Oct 24, 2020
4b7dcb2
Merge branch 'master' of https://github.com/sbhattacharyay/bims
Oct 24, 2020
65a14c0
update repo files from marcc
Oct 26, 2020
1e24da0
marcc updates
Oct 28, 2020
6a9ca79
local to marcc
sbhattacharyay Oct 30, 2020
334ae7c
marcc changes to merge
Oct 30, 2020
76848f3
Merge branch 'master' of https://github.com/sbhattacharyay/bims
Oct 30, 2020
2dd24e5
marcc changes
Oct 30, 2020
77f2db2
local changes
sbhattacharyay Oct 30, 2020
c918181
failsafe master 10
sbhattacharyay Oct 30, 2020
4b0b6f7
commit changes to master10
sbhattacharyay Oct 31, 2020
3b17e09
updates
sbhattacharyay Jan 28, 2021
3e54178
update file names
sbhattacharyay Jan 29, 2021
8723f2d
update all changes
sbhattacharyay Jan 29, 2021
fb98df9
Delete 20-news-group-classification.ipynb
sbhattacharyay Jan 29, 2021
3804e37
clean repo
sbhattacharyay Jan 29, 2021
a7d4127
clean repo
sbhattacharyay Jan 29, 2021
fe5d804
Merge branch 'master' of https://github.com/sbhattacharyay/bims
sbhattacharyay Jan 29, 2021
6f84b05
changes
sbhattacharyay Feb 12, 2021
61dfd93
cleanup
sbhattacharyay Feb 19, 2021
88093d6
commented files
Mar 24, 2021
52fa287
add figures
sbhattacharyay Apr 5, 2021
75c902f
clean
sbhattacharyay Apr 5, 2021
193734c
Merge pull request #3 from sbhattacharyay/eshan
sbhattacharyay Apr 14, 2021
0ee8eff
Delete accel_time_info.xlsx
sbhattacharyay Apr 16, 2021
3f2278c
Delete validation_resampling directory
sbhattacharyay Apr 16, 2021
3502c66
Delete scripts/eshan_scripts directory
sbhattacharyay Apr 16, 2021
10fc3f8
Delete .DS_Store
sbhattacharyay Apr 16, 2021
9f57dab
add readme
sbhattacharyay Apr 17, 2021
ee886bd
Update README.md
sbhattacharyay Apr 17, 2021
9c47d08
features/README.md
sbhattacharyay Apr 17, 2021
1112132
features/README.md
sbhattacharyay Apr 17, 2021
8752df8
Update README.md
sbhattacharyay Apr 17, 2021
368f5f0
clean
sbhattacharyay Apr 17, 2021
a2341ca
Update README.md
sbhattacharyay Apr 17, 2021
62d44cd
Update README.md
sbhattacharyay Apr 18, 2021
9a1246b
overhaul of repo
sbhattacharyay May 13, 2021
753cd47
Merge branch 'master' of https://github.com/sbhattacharyay/bims
sbhattacharyay May 13, 2021
cce1b85
Update 03_bed_movement_correction.R
sbhattacharyay May 13, 2021
18452fc
Update README.md
sbhattacharyay May 13, 2021
103efc3
Update README.md
sbhattacharyay May 13, 2021
b59a608
Update README.md
sbhattacharyay May 13, 2021
6e62a3e
Update README.md
sbhattacharyay May 13, 2021
2325dac
changes to scripts files
sbhattacharyay May 15, 2021
2d4c456
housekeeping
sbhattacharyay May 16, 2021
413abe0
Update README.md
sbhattacharyay May 16, 2021
0d6dc93
Update README.md
sbhattacharyay May 16, 2021
be5f20e
Update README.md
sbhattacharyay May 16, 2021
52f9ac7
Update README.md
sbhattacharyay May 19, 2021
2123c66
local changes
sbhattacharyay May 21, 2021
5bc85e2
update to precision recall
sbhattacharyay May 24, 2021
5b44bf6
Update README.md
sbhattacharyay Dec 8, 2021
cf93aaa
update metric calculation function
sbhattacharyay Jun 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
42 changes: 21 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
MIT License

Copyright (c) 2020 sbhattacharyay

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License
Copyright (c) 2020 Shubhayu Bhattacharyay, Matthew Wang, Eshan Joshi, and Robert Stevens
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
72 changes: 63 additions & 9 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,63 @@
# Decoding Quantitative Motor Features for Classification and Prediction in Severe Acquired Brain Injury

Brain Injury Motion Sensing (BIMS) Project

NOTE: Running MATLAB scripts will require installation of the Financial Toolbox.

Johns Hopkins University

This project is licensed under the terms of the MIT license.
[![DOI](https://zenodo.org/badge/236843680.svg)](https://zenodo.org/badge/latestdoi/236843680)

# Decoding accelerometry for classification and prediction of critically ill patients with severe brain injury
A pilot study of the Neurological Injury Motion Sensing (NIMS) project

Bhattacharyay, S., Rattray, J., Wang, M. _et al._ Decoding accelerometry for classification and prediction of critically ill patients with severe brain injury. _Sci Rep_ 11, 23654 (2021). https://doi.org/10.1038/s41598-021-02974-w

## Contents

- [Overview](#overview)
- [Abstract](#abstract)
- [Code](#code)
- [License](./LICENSE)
- [Citation](#citation)

## Overview

This repository contains the code underlying the article entitled **Decoding accelerometry for classification and prediction of critically ill patients with severe brain injury** from the Johns Hopkins University [Laboratory of Computational Intensive Care Medicine](https://lcicm.jhmi.edu/). In this file, we present the abstract, to outline the motivation for the work and the findings, and then a brief description of the code with which we generate these finding and achieve this objective.\
\
The code on this repository is commented throughout to provide a description of each step alongside the code which achieves it.

## Abstract

The goal of this research is to explore quantitative motor features in critically ill patients with severe brain injury (SBI). We hypothesized that computational decoding of these features would yield important information on underlying neurological states and clinical outcomes. Using wearable microsensors placed on all extremities, we recorded 1,701 hours of continuous, high-frequency accelerometry data from a prospective cohort of patients (n = 69) admitted to the ICU with SBI. Models were trained using time-, frequency-, and wavelet-domain motion features and levels of responsiveness and outcome as labels. The two primary tasks were detection of levels of responsiveness assessed by motor sub-score of the Glasgow Coma Scale (GCSm), and prediction of functional outcome at hospital discharge measured with the Glasgow Outcome Scale–Extended (GOSE). Detection models achieved significant (AUC: 0.70 [95% CI: 0.53–0.85]) and consistent (observation windows: 12 min – 9 hours) discrimination of SBI patients capable of purposeful movement (GCSm > 4). Prediction models accurately discriminated SBI patients of upper moderate disability or better (GOSE > 5) with 2–6 hours of observation (AUC: 0.82 [95% CI: 0.75–0.90]). Results suggest that computational analysis of time series motor activity in patients with SBI yields clinically important insights on underlying neurologic states and short-term clinical outcomes.

## Code
All of the code used in this work can be found in the `./scripts` directory as MATLAB (`.m`) files, R (`.R`) files, or Jupyter notebooks (`.ipynb`). Moreover, generalised functions have been saved in the `./scripts/functions` sub-directory and `.py` scripts used to record accelerometry data from the bedside are available in the `./scripts/accel_recording_scripts` sub-directory.

### 1. [Complete Motion Feature Extraction](scripts/01_motion_feature_extraction.m)
In this `.m` script, we iterate through compiled triaxial accelerometry information from each patient, filter each axis with a high-pass (_f_c_ = 0.2 Hz) 4th-order Butterworth filter, and extract 7 different motion features from non-overlapping 5 second windows. Outputs are saved as `.csv` feature tables. We also plot short examples of the accelerometry processing pipeline for Figure 1 in this script.

### 2. [Multiple Imputation of Missing Accelerometery Values](scripts/02_missing_feature_imputation.R)
In this `.R` script, we apply our multiple missing feature imputation algorithm. In the event of totally missing recordings (_n_ = 10/483), we impute upper extremity recordings with linear regression from ipsilateral upper extremity sensors, we impute lower extremity recordings with linear regression from contralateral upper extremity sensors, and bed sensors are imputed with sampling with replacement from the total distribution of bed sensor values. Then, the large majority of missing values were imputed with multiple, normalized time-series imputation with the `Amelia II` package. We create 9 imputations, each stored in a separate `.csv` file.

### 3. [Bed Motion Correction and Collection of Multiple Imputations](scripts/03_bed_movement_correction.R)
In this `.R` script, we correct gross-external movements by properly adjusting for the motion features calculated from the sensor placed at the foot of each patient's bed. Based on a literature-sourced threshold of SMA for human dynamic activity, we define distributions for each feature correspodning to static activity, and correct bed sensoer feature values from extremity sensors accordingly. As a result, we have 9 bed-corrected, imputed feature sets, each stored in a separate `.csv` file.

### 4. [Resampling of GCS data for classification](scripts/04_create_repeated_cv_folds.R)
In this `.R` file, we create repeated cross-validation (5 repeats of 5-fold CV) for each tested observation window based on the available GCS observations for each observation window. We principally use the `createMultiFolds` function from the `caret` package to stratify folds by outcome labels. Folds for each observation window are stored in a `.csv` file in a newly created directory.

### 5. [LOL embedding for dimensionality reduction](scripts/05_dim_reduction.R)
In this `.R` file, we train Linear Optimal Low Rank Projections [(LOL)](https://neurodata.io/lol/) on model training sets and reduce both training and validation sets to low-dimensional spaces prior to model training. Prior to LOL, we normalize feature spaces per the distribution of feature type and sensor combinations. This enables us to use LOL coefficients to compare feature type and sensor significance.

### 6. [Train and evaluate prediction models and measure feature significance scores](scripts/06_prediction_models.R)
In this `.R` file, we train and validate logistic regression models (GLM) for threshold-level GCSm detection, threshold-level GOSE at discharge prediction, and threshold-level GOSE at 12 months prediction. We train and evaluate models of varying observation windows and target dimensionalities. In this script, we also calculate our feature significance scores. This is equiavalent to the absolute LOL coefficient weighted by the trained linear coefficients of the corresponding logistic regression model.

### 7. [Calculate bootstrapping bias-corrected cross-validation (BBC-CV) area under the receiver operating characteristic curve (AUC) and classification metrics](scripts/07_calculate_metrics.ipynb)
In this `.ipynb` notebook, we calculate AUCs, ROC curves, and classification metrics for each observation window based on the validation set predictions returned by our models. We use bias-corrected bootstrapping for repeated cross-validation [(Repeated BBC-CV)](https://doi.org/10.1007/s10994-018-5714-4) to calculate 95% confidence intervals for the metrics and the ROC curve. This script is programmed to perform bootstrapping in parallel on 10 cores.

### 8. [Calculate model calibration on validation set predictions](scripts/08_model_calibration_calculation.R)
In this `.R` file, we calculate probability calibration curves and associated calibration metrics for each observation window based on the validation set predictions returned by our models. We use bias-corrected bootstrapping for repeated cross-validation [(Repeated BBC-CV)](https://doi.org/10.1007/s10994-018-5714-4) to calculate 95% confidence intervals for the metrics and the calibration curve. This script is programmed to perform bootstrapping in parallel on 10 cores.

### 9. [Case study exploration](scripts/09_case_study_exploration.R)
In this `.R` file, we retrospectively examine predictions of _Pr_(GCSm > 4) in patients (_n_ = 6) who experienced neurological transitions across this threshold to visually determine potential clinical utility of the accelerometry-based system. For each of the 6 patients, we train optimally discriminating detection models (one with a shorter observation window of 27 minutes and one with a longer observation window of 6 hours) on the remaining patient set and validate predictions on the case study patients specifically over a large, continuously overlapping observation window set. We bootstrap across imputations to produce 95% confidence intervals that account for variation due to imputation on the predictions. Then, we prepare the probability trajectories for plotting.

### 10. [Create manuscript tables and perform statistical analyses](scripts/10_tables_and_statistics.R)
In this `.R` file, we construct manuscript tables and perform miscellaneous statistical analyses for different parts (including figures) of the manuscript and supplementary materials. In addition to the classification metrics calculated in script no. 7, we also calculate classification accuracy with repeated BBC-CV in this script.

### 11. [Plot figures for the manuscript](scripts/11_manuscript_figures.R)
In this `.R` file, we produce the figures for the manuscript and the supplementary figures. The large majority of the quantitative figures in the manuscript are produced using the `ggplot` package.

## Citation
Bhattacharyay, S., Rattray, J., Wang, M. _et al._ Decoding accelerometry for classification and prediction of critically ill patients with severe brain injury. _Sci Rep_ 11, 23654 (2021). https://doi.org/10.1038/s41598-021-02974-w
37 changes: 37 additions & 0 deletions accel_sensor_data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Unfiltered triaxial accelerometry (10 Hz) for NIMS

## Data access instructions
The data corresponding to this directory can be found at the following citation link:
> Bhattacharyay, Shubhayu; Wang, Matthew; Rattray, John; Etienne-Cummings, Ralph; Kudela, Pawel; Stevens, Robert David, 2021, "Unfiltered triaxial accelerometry (10 Hz) for NIMS", https://doi.org/10.7910/DVN/SXNBGB, Harvard Dataverse, V1

You will be asked to submit a request to access the data.

## Description
Raw accelerometry (10 Hz, unit: g) file names are formatted as: `‘accel_’ + unique patient identifier (UPI) + ‘.mat’`. For patients for whom we collected data too large to fit into one file, data is split into one file per sensor (7 sensors total), and file names are formatted as follows: `‘accel_’ + unique patient identifier (UPI) + ‘_C’ + sensor number (1 – 7) + ‘.mat’`.

For complete `.mat` files, each file contains a MATLAB cell array (12 x 7) called `data`. The columns of this cell array correspond to the different sensors (in order: Bed [control sensor], Left Ankle, Left Elbow, Left Wrist, Right Ankle, Right Elbow, Right Wrist) and the rows of the cell array correspond to the different channels of the sensors. For this study, only rows 5-7 (x-,y-, and z-axes respectively) and row 12 (time of day stamps) are used, and thus rows 1-4 and 8-11 can be removed.

For sensor-specific `.mat` files (ending in `_C#.mat`), each file contains a MATLAB cell array (1 x 12) called `C#`. This corresponds to the different channels of the sensor. For this study, only cells 5-7 (x-,y-, and z-axes respectively) and cell 12 (time of day stamps) are used, and thus cells 1-4 and 8-11 can be removed. The C# correspond to sensors as follows: C1 - Bed [control sensor], C2 - Left Ankle, C3 - Left Elbow, C4 - Left Wrist, C5 - Right Ankle, C6 - Right Elbow, and C7 - Right Wrist. To concatenate these channels into a 'data' cell array, as seen in complete `.mat` files, load all the `_C#.mat` for a specific patient, and run the following line of MATLAB code: `data = [C1;C2;C3;C4;C5;C6;C7]';`

## Data format
### For complete `.mat` files:
`data` is a 12 x 7 cell array that can be labeled as follows:
| Bed | LA | LE | LW | RA | RE | RW |
|-----------------|----------------|----------------|----------------|----------------|----------------|----------------|
| Blank | Blank | Blank | Blank | Blank | Blank | Blank |
| Blank | Blank | Blank | Blank | Blank | Blank | Blank |
| Blank | Blank | Blank | Blank | Blank | Blank | Blank |
| Blank | Blank | Blank | Blank | Blank | Blank | Blank |
| x-axis (Bed) | x-axis (LA) | x-axis (LE) | x-axis (LW) | x-axis (RA) | x-axis (RE) | x-axis (RW) |
| y-axis (Bed) | y-axis (LA) | y-axis (LE) | y-axis (LW) | y-axis (RA) | y-axis (RE) | y-axis (RW) |
| z-axis (Bed) | z-axis (LA) | z-axis (LE) | z-axis (LW) | z-axis (RA) | z-axis (RE) | z-axis (RW) |
| Blank | Blank | Blank | Blank | Blank | Blank | Blank |
| Blank | Blank | Blank | Blank | Blank | Blank | Blank |
| Blank | Blank | Blank | Blank | Blank | Blank | Blank |
| Blank | Blank | Blank | Blank | Blank | Blank | Blank |
| TimeOfDay (Bed) | TimeOfDay (LA) | TimeOfDay (LE) | TimeOfDay (LW) | TimeOfDay (RA) | TimeOfDay (RE) | TimeOfDay (RW) |

### For sensor-specific `.mat` files (ending in `_C#.mat`):
`C#` is a 1 x 12 cell array that can be labeled as follows:
| Blank | Blank | Blank | Blank | x-axis | y-axis | z-axis | Blank | Blank | Blank | Blank | TimeOfDay |
|-----------------|----------------|----------------|----------------|----------------|----------------|----------------|----------------|----------------|----------------|----------------|----------------|
Binary file removed clinical_data/Final_QMACP.xlsx
Binary file not shown.
Loading