## load a MRIaggr object
data("MRIaggr.Pat1_red", package = "MRIaggr")
#### 1- directly ####
res <- calcTableHypoReperf(MRIaggr.Pat1_red, param = c("TTP","MTT"), timepoint=c("t0","t1"),
mask="MASK_DWI_t0", numeric2logical = TRUE,
update.object = TRUE, overwrite = TRUE)
carto_TTP_t0 <- selectContrast(MRIaggr.Pat1_red, param = "TTP_t0")
carto_TTP_t1 <- selectContrast(MRIaggr.Pat1_red, param = "TTP_t1")
## hypoperfusion
sum( (carto_TTP_t0 >= 4) )
selectTable(MRIaggr.Pat1_red, "hypoperfusion")["4","Vhypo.TTP_t0"]
## mismatch
testN <- (selectContrast(MRIaggr.Pat1_red, param = "MASK_DWI_t0") == 0)
sum( (carto_TTP_t0 >= 4) * testN )
selectTable(MRIaggr.Pat1_red, "hypoperfusion")["4","Vmismatch.TTP"]
sum( (carto_TTP_t0 >= 4) * testN ) / sum( testN == FALSE )
selectTable(MRIaggr.Pat1_red, "hypoperfusion")["4","PCmismatch.TTP"]
## reperfusion
sum((carto_TTP_t0 >= 4) * (carto_TTP_t1 < 4))
selectTable(MRIaggr.Pat1_red, "reperfusion")["4","Vreperf.TTP"]
sum((carto_TTP_t0 >= 4) * (carto_TTP_t1 < 4)) / sum( (carto_TTP_t0>=4) )
selectTable(MRIaggr.Pat1_red, "reperfusion")["4","PCreperf.TTP"]
## W reperfusion
carto_TTPth_t0 <- carto_TTP_t0
carto_TTPth_t0[carto_TTPth_t0 > 10] <- 10
carto_TTPth_t0[carto_TTPth_t0 < 0] <- 0
carto_TTPth_t1 <- carto_TTP_t1
carto_TTPth_t1[carto_TTP_t1 > 10] <- 10
carto_TTPth_t1[carto_TTP_t1 < 0] <- 0
weight <- (carto_TTPth_t0 - carto_TTPth_t1) / carto_TTPth_t0
weight[ ((carto_TTPth_t0 == 0) + (carto_TTP_t0 < 4) + (carto_TTP_t1 >= 4)) > 0 ] <- 0
sum((carto_TTP_t0 >= 4) * (carto_TTP_t1 < 4) * weight)
selectTable(MRIaggr.Pat1_red, "reperfusion")["4","VreperfW.TTP"]
sum((carto_TTP_t0 >= 4) * (carto_TTP_t1 < 4) * weight) / sum( (carto_TTP_t0 >= 4) )
selectTable(MRIaggr.Pat1_red, "reperfusion")["4","PCreperfW.TTP"]
## deperfusion
sum((carto_TTP_t0 < 4) * (carto_TTP_t1 >= 4))
selectTable(MRIaggr.Pat1_red, "reperfusion")["4","Vdeperf.TTP"]
sum((carto_TTP_t0 < 4) * (carto_TTP_t1 >= 4)) / sum( (carto_TTP_t0 >= 4) )
selectTable(MRIaggr.Pat1_red, "reperfusion")["4","PCdeperf.TTP"]
## shift
sum((carto_TTPth_t0 - carto_TTPth_t1 >= 4))
selectTable(MRIaggr.Pat1_red, "reperfusion")["4","Vshift_reperf.TTP"]
sum((carto_TTPth_t0-carto_TTPth_t1 >= 4)) / sum( (carto_TTP_t0>=4) )
selectTable(MRIaggr.Pat1_red, "reperfusion")["4","PCshift_reperf.TTP"]
#### 2- via calcThresholdMRIaggr ####
## perform segmentation (call mritc)
## Not run:
# calcThresholdMRIaggr(MRIaggr.Pat1_red, param = c("TTP_t0","MTT_t0","TTP_t1","MTT_t1"),
# threshold=1:10, name_newparam = c("TTP.GR_t0","MTT.GR_t0","TTP.GR_t1","MTT.GR_t1"),
# rm.CSF=TRUE, hemisphere = "lesion",
# GRalgo=TRUE, seed = c("MASK_T2_FLAIR_t2","MASK_DWI_t0"), W.range = sqrt(2),
# update.object = TRUE, overwrite = TRUE)
#
# res <- calcTableHypoReperf(MRIaggr.Pat1_red, param = c("TTP.GR","MTT.GR"),
# timepoint = c("t0","t1"), mask = "MASK_DWI_t0", numeric2logical = TRUE,
# update.object = TRUE, overwrite = TRUE)
#
# ## display
# selectTable(MRIaggr.Pat1_red, "hypoperfusion")["4","Vhypo.TTP.GR_t0"]
#
# par(mfrow = c(2,4), mar = rep(1.5,4), mgp = c(2,0.5,0))
# multiplot(MRIaggr.Pat1_red, param = "TTP_t0", num = 1:3,
# palette = rainbow(10), window = NULL, main = "raw - slice ",
# breaks=(0:10)-10^{-10})
# multiplot(MRIaggr.Pat1_red, param = "TTP.GR_t0", num = 1:3,
# palette = rainbow(10), window = NULL, main = "GR - slice ",
# breaks=(0:10)-10^{-10})
# ## End(Not run)
Run the code above in your browser using DataLab