Miscellaneous-constLatex: Constructor for Latex report

Description Usage Arguments Details Value Examples

Description

Construct a Latex report that includes plots generated by the multiplot function.

Usage

1
2
3
4
5
constLatex(directory, filename = NULL, identifier = NULL, param = NULL, tabular = NULL,
         extra_text = NULL, subsection = NULL, label = NULL,
         width = 0.9, trim = c(0,0,0,0), plotPerPage = 3,
         width.legend = 0.35, trim.legend=  c(0,0,0,0),
         title = "", date="", author = "", verbose = TRUE)

Arguments

directory

the path to the root directory. This directory should contains subsdirectories themself containing the image files. character.

filename

the name of the latex file that should be generated. character or NULL.

identifier

the identifiers of the patients for which the graphics should be displayed. character vector or NULL leading to use all patients.

param

the names of subdirectories containing the images. character vector or NULL leading to use all subdirectories.

tabular

a list of data.frame to display in the table format. list of data.frame or NULL if there is no table to display.

extra_text

additionnal text to display. list of character vector or NULL if there is no extra text to display.

subsection

the names of subsections for the latex document. character vector or NULL leading to use param for naming the subsections.

label

the legend that will be displayed under each figure of a given parameter. character vector or NULL leading to use param for the legend.

verbose

should the execution of the function be traced ? logical.

width

the width of each image relative to the linewidth. positive numeric.

trim

the length in mm with which the imported images will be cropped (left, bottom, right top). numeric vector of size 4.

plotPerPage

the number of image that should be displayed on the same page. strictly positive interger.

width.legend

the width of the legend image relative to the linewidth. numeric between 0 and 1.

trim.legend

the length in mm with which the legend of the images will be cropped. numeric vector of size 4.

title

the title of the latex document. character.

date

the date on the latex document. character.

author

the author of the latex document. character.

Details

ARGUMENTS:
tabular must contains in its first column the patient identifiers. This column will not be display.

FUNCTION:
Patient identifiers are read from the file names : it is the character string preceding the first underscore ("_").

The function generate latex code that reads the images using the includegraphicx latex function. In particular arguments width, trim, width.legend and trim.legend are used by this function to adjust the display of the images.

The latex files require the following (latex) packages to compile: inputenc, amssymb, amsmath, titlesec, geometry, enumitem, graphicx, color, space, hyperref and caption. If filename is set to NULL the latex file will not be created.

Value

A list containing :

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
## Not run: 
## generate MRIaggr objects
data("MRIaggr.Pat1_red", package = "MRIaggr")

path.Pat2 <- system.file("anlz", package = "oro.nifti")
analyse.avg <- readMRI(file.path(path.Pat2, "avg152T1"), format = "analyze")
# analyse.avg@descrip
MRIaggr.Pat2 <- constMRIaggr(analyse.avg, param = "T1_t0", identifier = "Pat2")

path.Pat3 <- system.file("nifti", package = "oro.nifti")
nifti.ffd <- readMRI(file.path(path.Pat3, "filtered_func_data"), format = "nifti")
# nifti.ffd@descrip
MRIaggr.Pat3 <- constMRIaggr(lapply(1:5, function(x){nifti.ffd[,,,x, drop = FALSE]}),
                             param=paste("T2_GRE_t", 0:4, sep = ""),identifier = "Pat3")

## create directories			
path <- "."
dir.create(file.path(path, "Display"))
dir.create(file.path(path, "Display/T1_t0"))
dir.create(file.path(path, "Display/T2_GRE_t0"))
dir.create(file.path(path, "Display/MASK_DWI_t0"))

## export images 
multiplot(MRIaggr.Pat1_red, param = "T1_t0",
          mfrow = c(2,4), axes = FALSE, mar = c(0,0,1.5,0),
          window = "png", path = "Display/T1_t0/")
multiplot(MRIaggr.Pat2, param = "T1_t0",
          mfrow = c(3,6), axes = FALSE, mar = c(0,0,1.5,0), legend = FALSE,
          window = "png", path = "Display/T1_t0/")

multiplot(MRIaggr.Pat1_red, param = "T2_GRE_t0",
          mfrow = c(2,4), axes = FALSE, mar = c(0,0,1.5,0),
          window = "png", path = "Display/T2_GRE_t0/")
multiplot(MRIaggr.Pat3, param = "T2_GRE_t0",
          mfrow = c(2,4), axes = FALSE, mar = c(0,0,1.5,0),
          window = "png", path = "Display/T2_GRE_t0/")

multiplot(MRIaggr.Pat1_red, param = "MASK_DWI_t0",
          mfrow = c(2,4), axes = FALSE, mar = c(0,0,1.5,0),
          window = "png", path = "Display/MASK_DWI_t0/")

## create latex file (default)
res <- constLatex(directory = "Display/", filename = "sweaveDisplay")

## create latex file (personalized)
res <- constLatex(directory = "Display/", filename = "sweaveDisplay",
                  param = c("T1_t0","T2_GRE_t0","MASK_DWI_t0"),
                  tabular = list(data.frame(cbind(Id = c("Pat1","Pat2","Pat3"),
                                                  Age = c(28,54,32),
                                                  Gender = c("Male","Female","Male")))
                              ),
                   label = c("T1 sequence","T2 gradient echo sequence","lesion mask"),
                   extra_text = list("Patient 1 suffers from stroke diseases ...",
                                     "Patient 2 has ...",
                                     "Patient 3 has ...")
)

## End(Not run)

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