liud4 / rVMAP

Data Management code for VMAC-MAP study
Other
3 stars 0 forks source link

Update derivation of reactivity regions #79

Open robbwh opened 4 months ago

robbwh commented 4 months ago

Currently the derivation of ASL reactivity regions is a long list: ~300 lines of code and doesn't include all brain regions.

https://github.com/liud4/rVMAP/blob/a620dbe01c9ddeb6ef812c7144e980b1231642f1/R/derive_automated_3T.R#L72

These 300 lines could be simplified into this code block:

for (rest_var in asl_rest_variables) {
  # Construct the corresponding chall and reac variable names
  chall_var <- gsub("asl.rest", "asl.chall", rest_var)
  reac_var <- gsub("asl.rest", "asl.reac", rest_var)
  # Calculate the reac variable
  data[[reac_var]] <- 100 * (data[[chall_var]] - data[[rest_var]]) / data[[rest_var]] / data[["asl.3t.change.etco2"]]
}
panpanzhang99299 commented 1 month ago

Panpan will edit this function after the data freeze (June 2024).