MRIaggr-calcFilter: Image filtration

Description Usage Arguments Details Value See Also Examples

Description

Apply a filter to an image.

Usage

1
2
3
4
5
6
7
## S4 method for signature 'array'
calcFilter(object, filter, norm.filter = TRUE, bilateral = FALSE, na.rm = FALSE)

## S4 method for signature 'MRIaggr'
calcFilter(object, param, filter, norm.filter = TRUE, bilateral = FALSE,
     na.rm = FALSE, name_newparam = NULL,
	 verbose = optionsMRIaggr("verbose"), update.object = FALSE, overwrite = FALSE)

Arguments

object

an array or an object of class MRIaggr. REQUIRED.

param

the contrast parameter to be filtered. character vector. REQUIRED.

filter

the filter to use. Can be a matrix or an array, or a name indicating which filter should be used. REQUIRED.

norm.filter

should the filtered correspond to a weighted mean over site ? (or a weighted sum). logical.

bilateral

should the influence of each neighbor be ponderated by the difference in signal with the considered observation ? logical.

na.rm

should observations with missing values in their neighbourhood be set to NA ? Otherwise the ponderation is adjusted. logical.

name_newparam

the name of the new parameters. character vector.

verbose

should the execution of the function be traced ? logical.

update.object

should the resulting filtered parameters be stored in object ? logical.

overwrite

if contrast parameters with the same names are already stored in object@data, can they be overwritten ? logical.

Details

ARGUMENTS:
Several types of pre-stored filters are availables and can be called by their name:

norm.filter should be set to TRUE for gaussian, median or sobel filters to correct edge effects. This lead to weight the neighboring value in order to offset the incomplete neighbourhood.

Value

An list containing :

See Also

selectContrast to select the filtered parameter(s). initFilter or codeinitNeighborhood to select pre-stored filters.

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
#### 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)

bozenne/MRIaggr documentation built on May 13, 2019, 1:39 a.m.