-
Notifications
You must be signed in to change notification settings - Fork 1
/
paths.r
76 lines (66 loc) · 2.74 KB
/
paths.r
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
### Support functions for paths an package loading
### This program is part of RoLDSIS
###
### Copyright (C) 2020 Rafael Laboissière
### Copyright (C) 2020 Adrielle de Carvalho Santana
### Copyright (C) 2020 Hani Camille Yehia
###
### This program is free software: you can redistribute it and/or modify it
### under the terms of the GNU General Public License as published by the
### Free Software Foundation, either version 3 of the License, or (at your
### option) any later version.
###
### This program is distributed in the hope that it will be useful, but
### WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
### General Public License for more details.
###
### You should have received a copy of the GNU General Public License along
### with this program. If not, see <http://www.gnu.org/licenses/>.
### * Load local library
source ("dwt-parameters.r")
### * Force creation of directories
force.dir.create <- function (dir)
suppressWarnings (dir.create (dir, recursive = TRUE))
### * Needed directories
data.dir <- "../data"
figures.dir <- "../figures"
force.dir.create (figures.dir)
results.dir <- "../results"
force.dir.create (results.dir)
exp.dir <- file.path (data.dir, "Experimento")
id.dir <- file.path (data.dir, "identification")
dwt.dir <- file.path (data.dir,
sprintf ("%s-%d-%d",
dwt.filter,
dwt.length,
dwt.nb.levels))
force.dir.create (dwt.dir)
axes.dir <- file.path (dwt.dir, sprintf ("start-W%d", dwt.start.level))
force.dir.create (axes.dir)
### * Get name of subject specific directory
subject.dirname <- function (exp.feat, exp.type, subject) {
feat.dir <- file.path (dwt.dir, exp.feat)
type.dir <- file.path (feat.dir, exp.type)
subj.label <- sprintf ("S%02d", subject)
subj.dir <- file.path (type.dir, subj.label)
force.dir.create (subj.dir)
return (subj.dir)
}
### * Get name of the DWT results directory
dwt.coefs.stem <- "dwt-coefs"
dwt.coefs.filename <- function (exp.feat, exp.type, subject)
file.path (subject.dirname (exp.feat, exp.type, subject),
sprintf ("%s.dat", dwt.coefs.stem))
### * Get name of the cross-validation directory
cv.stem <- "cross-validation"
cv.filename <- function (exp.feat, exp.type, subject)
file.path (subject.dirname (exp.feat, exp.type, subject),
sprintf ("%s.dat", cv.stem))
### * Utility function for Loading R pakcages, installing them if necessary
load.pkgs <- function (list.of.pkgs)
for (pkg in list.of.pkgs)
if (! require (pkg, character.only = TRUE)) {
install.packages (pkg)
require (pkg, character.only = TRUE)
}