#### 1- array method ####
## load a NIFTI file
path.Pat1 <- system.file(file.path("nifti"), package = "MRIaggr")
nifti.Pat1_DWI_t0 <- readMRI(file.path(path.Pat1, "DWI_t0"), format = "nifti")
## before filtering
graphics::image(nifti.Pat1_DWI_t0[,,1,1])
## after median filtering
niftiF.Pat1_DWI_t0 <- calcFilter(nifti.Pat1_DWI_t0[,,,1], filter = "2D_M3")$res
graphics::image(niftiF.Pat1_DWI_t0[,,1])
#### 2- MRIaggr method ####
## load a MRIaggr object
data("MRIaggr.Pat1_red", package = "MRIaggr")
## compute and allocate filtered parameter to the MRIaggr object
# gaussian filter
calcFilter(MRIaggr.Pat1_red, param = c("T2_FLAIR_t2","DWI_t0","TTP_t0"),
filter = "2D_G3", bilateral = FALSE, na.rm = FALSE,
update.object = TRUE, overwrite = TRUE)
selectParameter(MRIaggr.Pat1_red)
# median filter
calcFilter(MRIaggr.Pat1_red, param = c("T2_FLAIR_t2","DWI_t0","TTP_t0"),
filter = "2D_M3", na.rm = FALSE, update.object = TRUE, overwrite = TRUE)
## display
par(mfrow = c(2,2), mar = c(2,2,2,2))
multiplot(MRIaggr.Pat1_red, param = "T2_FLAIR_t2",
num.main = FALSE, main = "raw",
num = 1, window = NULL, breaks = c(-100,seq(0, 450),601))
multiplot(MRIaggr.Pat1_red, param = "T2_FLAIR_t2_2D_G3",
num.main = FALSE, main = "2D_G3",
num = 1, legend = FALSE, window = NULL, breaks = c(-100,seq(0,450),601))
multiplot(MRIaggr.Pat1_red, param = "T2_FLAIR_t2_2D_M3",
num.main = FALSE, main = "2D_M3",
num = 1, legend = FALSE, window = NULL, breaks = c(-100,seq(0, 450),601))
## see the results of the different filters
# G : Gaussian filter
resG <- calcFilter(MRIaggr.Pat1_red, param = "T2_FLAIR_t2",
filter = "2D_G3")
# M : median filter
resM <- calcFilter(MRIaggr.Pat1_red, param = "T2_FLAIR_t2",
filter = "2D_M3")
# S : Sobel filter
resS <- calcFilter(MRIaggr.Pat1_red, param = "T2_FLAIR_t2",
filter = "2D_Sx")
# I
resI.T <- calcFilter(MRIaggr.Pat1_red, param = "MASK_T2_FLAIR_t2",
filter = "2D_I3", norm.filter = TRUE)
resI.F <- calcFilter(MRIaggr.Pat1_red, param = "MASK_T2_FLAIR_t2",
filter = "2D_I3", norm.filter = FALSE)
# N
resN.T <- calcFilter(MRIaggr.Pat1_red, param = "MASK_T2_FLAIR_t2",
filter = "3D_N10", norm.filter = TRUE)
resN.F <- calcFilter(MRIaggr.Pat1_red, param = "MASK_T2_FLAIR_t2",
filter = "3D_N10", norm.filter = FALSE)
## display
par(mfrow = c(2,2), mar = rep(2,4), mgp = c(2,0.75,0))
breaks <- seq(-50,500,1)
multiplot(MRIaggr.Pat1_red, param = "T2_FLAIR_t2", num = 3,
breaks = breaks, window = NULL, legend = FALSE,
main = "no filtering", num.main = FALSE, main.legend = "")
multiplot(resS$res[,c("i","j","k")], contrast = resS$res[,4],
num = 1, window = NULL, legend = FALSE,
palette = "cm.colors", breaks = seq(-100, 100),
main = "sobelX filtering", num.main = FALSE)
multiplot(resG$res[,c("i","j","k")], contrast = resG$res[,4],
num = 3, window = NULL, legend = FALSE, breaks = breaks,
main = "gaussian filtering", num.main = FALSE)
multiplot(resM$res[,c("i","j","k")], contrast = resM$res[,4],
num = 3, window = NULL, legend = FALSE, breaks = breaks,
main = "median filtering", num.main = FALSE)
layout(matrix(1:6, nrow = 3, ncol = 2, byrow = TRUE), widths = c(2,1), heights = rep(1,3))
par(mar = rep(2,4), mgp = c(2,0.75,0))
multiplot(MRIaggr.Pat1_red, param = "MASK_T2_FLAIR_t2", num = 3,
window = NULL, legend = TRUE, main = "raw", num.main = FALSE, main.legend = "")
multiplot(resI.T$res[,c("i","j","k")], contrast = resI.T$res[,4],
num = 3, window = NULL, legend = TRUE,
main = "Influence filtering - norm = TRUE", num.main = FALSE)
multiplot(resI.F$res[,c("i","j","k")], contrast = resI.F$res[,4],
num = 3, window = NULL, legend = TRUE,
main = "Influence filtering - norm = FALSE", num.main = FALSE)
layout(matrix(1:6, nrow = 3, ncol = 2, byrow = TRUE), widths = c(2,1), heights = rep(1,3))
par(mar = rep(2,4), mgp = c(2,0.75,0))
multiplot(MRIaggr.Pat1_red, param = "MASK_T2_FLAIR_t2", num = 3,
window = NULL, legend = TRUE, main = "raw", num.main = FALSE, main.legend = "")
multiplot(resN.T$res[,c("i","j","k")], contrast = resN.T$res[,4],
num = 3, window = NULL, legend = TRUE,
main = "Neighborhood3D filtering - norm = TRUE", num.main = FALSE)
multiplot(resN.F$res[,c("i","j","k")], contrast = resN.F$res[,4],
num = 3, window = NULL, legend = TRUE,
main = "Neighborhood3D filtering - norm = FALSE", num.main = FALSE)
Run the code above in your browser using DataLab