annotate nmr_preprocessing/ReadFids.R @ 2:7304ec2c9ab7 draft

Uploaded
author marie-tremblay-metatoul
date Mon, 30 Jul 2018 10:33:03 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
1 ################################################################################################
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
2 #
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
3 # Read FIDs in Bruker format
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
4 #
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
5 #
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
6 ################################################################################################
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
7
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
8 # ReadFid ==============================================================================
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
9 ReadFid <- function(path) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
10
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
11 # Read 1D FID using Bruker XWinNMR and TopSpin format. It is inspired of the
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
12 # matNMR matlab library which deals with 2D FID and also other formats
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
13 # Read also the parameters in the acqus file
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
14
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
15 paramFile <- file.path(path, "acqus")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
16 # BYTEORDA: 0 -> Little Endian 1 -> Big Endian
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
17 params <- readParams(paramFile, c("TD", "BYTORDA", "DIGMOD", "DECIM", "DSPFVS",
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
18 "SW_h", "SW", "O1"))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
19
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
20 if (params[["DSPFVS"]] >= 20) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
21 # The group delay first order phase correction is given directly from version 20
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
22 grpdly <- readParams(paramFile, c("GRPDLY"))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
23 params[["GRPDLY"]] <- grpdly[["GRPDLY"]]
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
24 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
25 TD <- params[["TD"]]
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
26 endianness <- if (params$BYTORDA)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
27 "big" else "little"
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
28 if (TD%%2 != 0) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
29 stop(paste("Only even numbers are allowed for size in TD because it is complex
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
30 data with the real and imaginary part for each element.",
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
31 "The TD value is in the", paramFile, "file"))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
32 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
33
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
34 # Interpret params Dwell Time, time between 2 data points in the FID
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
35 params[["DT"]] <- 1/(2 * params[["SW_h"]])
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
36
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
37 # Read fid
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
38 fidFile <- file.path(path, "fid")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
39 fidOnDisk <- readBin(fidFile, what = "int", n = TD, size = 4L, endian = endianness)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
40
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
41 # Real size that is on disk (it should be equal to TD2, except for TopSpin/Bruker
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
42 # (which is our case) according to matNMR as just discussed
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
43 TDOnDisk <- length(fidOnDisk)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
44 if (TDOnDisk < TD) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
45 warning("Size is smaller than expected, the rest is filled with zero so the size is the same for every fid")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
46 fidGoodSize <- sapply(vector("list", length = TD), function(x) 0)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
47 fidGoodSize[1:TDOnDisk] <- fidOnDisk
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
48
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
49 } else if (TDOnDisk > TD) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
50 warning("Size is bigger than expected, the rest ignored so the size is the same for every fid")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
51 fidGoodSize <- fidOnDisk(1:TD)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
52
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
53 } else {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
54 fidGoodSize <- fidOnDisk
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
55 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
56
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
57 fidRePart <- fidGoodSize[seq(from = 1, to = TD, by = 2)]
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
58 fidImPart <- fidGoodSize[seq(from = 2, to = TD, by = 2)]
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
59 fid <- complex(real = fidRePart, imaginary = fidImPart)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
60
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
61 return(list(fid = fid, params = params))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
62 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
63
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
64
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
65
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
66
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
67 # getDirsContainingFid ==============================================================================
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
68 getDirsContainingFid <- function(path) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
69 subdirs <- dir(path, full.names = TRUE)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
70 if (length(subdirs) > 0) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
71 cond <- sapply(subdirs, function(x) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
72 content <- dir(x)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
73 # subdirs must contain fid, acqu and acqus files
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
74 return("fid" %in% content && "acqu" %in% content && "acqus" %in% content)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
75 })
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
76 subdirs <- subdirs[cond]
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
77 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
78 return(subdirs)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
79 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
80
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
81
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
82
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
83
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
84
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
85
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
86 # beginTreatment ==============================================================================
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
87
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
88 beginTreatment <- function(name, Signal_data = NULL, Signal_info = NULL,
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
89 force.real = FALSE) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
90
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
91 cat("Begin", name, "\n")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
92
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
93
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
94 # Formatting the Signal_data and Signal_info -----------------------
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
95
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
96 vec <- is.vector(Signal_data)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
97 if (vec) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
98 Signal_data <- vec2mat(Signal_data)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
99 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
100 if (is.vector(Signal_info)) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
101 Signal_info <- vec2mat(Signal_info)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
102 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
103 if (!is.null(Signal_data)) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
104 if (!is.matrix(Signal_data)) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
105 stop("Signal_data is not a matrix.")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
106 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
107 if (!is.complex(Signal_data) && !is.numeric(Signal_data)) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
108 stop("Signal_data contains non-numerical values.")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
109 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
110 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
111 if (!is.null(Signal_info) && !is.matrix(Signal_info)) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
112 stop("Signal_info is not a matrix.")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
113 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
114
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
115
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
116 Original_data <- Signal_data
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
117
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
118 # Extract the real part of the spectrum ---------------------------
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
119
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
120 if (force.real) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
121 if (is.complex(Signal_data)) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
122 Signal_data <- Re(Signal_data)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
123 } else {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
124 # The signal is numeric Im(Signal_data) is zero anyway so let's avoid
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
125 # using complex(real=...,imaginary=0) which would give a complex signal
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
126 # in endTreatment()
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
127 force.real <- FALSE
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
128 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
129 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
130
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
131
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
132 # Return the formatted data and metadata entries --------------------
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
133
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
134 return(list(start = proc.time(), vec = vec, force.real = force.real,
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
135 Original_data = Original_data, Signal_data = Signal_data, Signal_info = Signal_info))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
136 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
137
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
138
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
139 # endTreatment ==============================================================================
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
140
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
141 endTreatment <- function(name, begin_info, Signal_data) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
142 end_time = proc.time() # record it as soon as possible
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
143 start_time = begin_info[["start"]]
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
144 delta_time = end_time - start_time
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
145 delta = delta_time[]
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
146 cat("End", name, "\n")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
147 cat("It lasted",
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
148 round(delta["user.self"], 3), "s user time,",
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
149 round(delta["sys.self"] , 3), "s system time and",
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
150 round(delta["elapsed"] , 3), "s elapsed time.\n")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
151 if (begin_info[["force.real"]]) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
152 # The imaginary part is left untouched
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
153 i <- complex(real=0, imaginary=1)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
154 Signal_data = Signal_data + i * Im(begin_info[["Original_data"]])
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
155 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
156 if (begin_info[["vec"]]) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
157 Signal_data = Signal_data[1,]
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
158 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
159 return(Signal_data)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
160 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
161
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
162
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
163 # checkArg ==============================================================================
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
164
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
165 checkArg <- function(arg, checks, can.be.null=FALSE) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
166 check.list <- list(bool=c(is.logical, "a boolean"),
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
167 int =c(function(x){x%%1==0}, "an integer"),
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
168 num =c(is.numeric, "a numeric"),
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
169 str =c(is.character, "a string"),
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
170 pos =c(function(x){x>0}, "positive"),
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
171 pos0=c(function(x){x>=0}, "positive or zero"),
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
172 l1 =c(function(x){length(x)==1}, "of length 1")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
173 )
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
174 if (is.null(arg)) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
175 if (!can.be.null) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
176 stop(deparse(substitute(arg)), " is null.")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
177 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
178 } else {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
179 if (is.matrix(arg)) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
180 stop(deparse(substitute(arg)), " is not scalar.")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
181 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
182 for (c in checks) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
183 if (!check.list[[c]][[1]](arg)) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
184 stop(deparse(substitute(arg)), " is not ", check.list[[c]][[2]], ".")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
185 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
186 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
187 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
188 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
189
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
190
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
191 # getArg ==============================================================================
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
192
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
193 getArg <- function(arg, info, argname, can.be.absent=FALSE) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
194 if (is.null(arg)) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
195 start <- paste("impossible to get argument", argname, "it was not given directly and");
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
196 if (!is.matrix(info)) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
197 stop(paste(start, "the info matrix was not given"))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
198 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
199 if (!(argname %in% colnames(info))) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
200 if (can.be.absent) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
201 return(NULL)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
202 } else {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
203 stop(paste(start, "is not in the info matrix"))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
204 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
205 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
206 if (nrow(info) < 1) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
207 stop(paste(start, "the info matrix has no row"))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
208 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
209 arg <- info[1,argname]
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
210 if (is.na(arg)) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
211 stop(paste(start, "it is NA in the info matrix"))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
212 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
213 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
214 return(arg)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
215 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
216
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
217
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
218
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
219 # getTitle ==============================================================================
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
220
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
221 # Get the name of the signal from the title file or fromt the name of the subdirectory
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
222 # Get the name of the signal from the title file or fromt the name of the subdirectory
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
223
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
224 getTitle <- function(path, l, subdirs) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
225 title <- NULL
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
226 title_file <- file.path(file.path(file.path(path, "pdata"), "1"), "title")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
227 if (file.exists(title_file)) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
228 lines <- readLines(title_file, warn = FALSE)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
229 if (length(lines) >= 1) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
230 first_line <- gsub("^\\s+|\\s+$", "", lines[l])
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
231 if (nchar(first_line) >= 1) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
232 title <- first_line
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
233 } else {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
234 warning(paste("The first line of the title file is blank for directory ",
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
235 path))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
236 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
237 } else {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
238 warning(paste("The title file is empty for directory ", path))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
239 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
240 } else {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
241 warning(paste("Title file doesn't exists for directory ", path, "\n the repertory name is used instead"))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
242 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
243 if (is.null(title)) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
244 if(subdirs) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
245 separator <- .Platform$file.sep
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
246 path_elem <- strsplit(path,separator)[[1]]
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
247 title <- paste(path_elem[length(path_elem)-1], path_elem[length(path_elem)], sep = "_")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
248 } else{title <- basename(path)}
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
249 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
250 return(title)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
251 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
252
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
253
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
254
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
255 # readParams ==============================================================================
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
256 # Read parameter values for Fid_info in the ReadFids function
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
257
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
258 readParams <- function(file, paramsName) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
259
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
260 isDigit <- function(c) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
261 return(suppressWarnings(!is.na(as.numeric(c))))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
262 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
263 lines <- readLines(file)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
264 params <- sapply(paramsName, function(x) NULL)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
265
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
266 for (paramName in paramsName) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
267 # Find the line with the parameter I add a '$' '=' in the pattern so that for
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
268 # example 'TD0' is not found where I look for 'TD' and LOCSW and WBSW when I look
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
269 # for 'SW'
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
270 pattern <- paste("\\$", paramName, "=", sep = "")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
271 occurences <- grep(pattern, lines)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
272 if (length(occurences) == 0L) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
273 stop(paste(file, "has no field", pattern))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
274 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
275 if (length(occurences) > 1L) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
276 warning(paste(file, "has more that one field", pattern, " I take the first one"))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
277 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
278 line <- lines[occurences[1]]
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
279
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
280 # Cut beginning and end of the line '##$TD= 65536' -> '65536'
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
281 igual = as.numeric(regexpr("=", line))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
282
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
283 first <- igual
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
284 while (first <= nchar(line) & !isDigit(substr(line, first, first))) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
285 first <- first + 1
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
286 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
287 last <- nchar(line)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
288 while (last > 0 & !isDigit(substr(line, last, last))) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
289 last <- last - 1
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
290 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
291 params[paramName] <- as.numeric(substr(line, first, last))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
292 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
293 return(params)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
294 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
295
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
296
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
297
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
298 # ReadFids ==============================================================================
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
299 ReadFids <- function(path, l = 1, subdirs = FALSE) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
300
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
301 # Data initialisation and checks ----------------------------------------------
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
302 begin_info <- beginTreatment("ReadFids")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
303 checkArg(path, c("str"))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
304 checkArg(l, c("pos"))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
305 if (file.exists(path) == FALSE) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
306 stop(paste("Invalid path:", path))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
307 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
308
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
309
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
310 # Extract the FIDs and their info ----------------------------------------------
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
311
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
312 if (subdirs == FALSE) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
313 fidDirs <- getDirsContainingFid(path)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
314 n <- length(fidDirs)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
315 if (n == 0L) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
316 stop(paste("No valid fid in", path))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
317 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
318 fidNames <- sapply(X = fidDirs, FUN = getTitle, l = l, subdirs = subdirs, USE.NAMES = F)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
319 for (i in 1:n) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
320 fidList <- ReadFid(fidDirs[i])
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
321 fid <- fidList[["fid"]]
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
322 info <- fidList[["params"]]
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
323 m <- length(fid)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
324 if (i == 1) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
325 Fid_data <- matrix(nrow = n, ncol = m, dimnames = list(fidNames,
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
326 info[["DT"]] * (0:(m - 1))))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
327 Fid_info <- matrix(nrow = n, ncol = length(info), dimnames = list(fidNames,
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
328 names(info)))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
329 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
330 Fid_data[i, ] <- fid
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
331 Fid_info[i, ] <- unlist(info)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
332 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
333
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
334 } else {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
335 maindirs <- dir(path, full.names = TRUE)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
336 Fid_data <- numeric()
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
337 Fid_info <- numeric()
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
338
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
339 fidDirs <- c()
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
340 for (j in maindirs) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
341 fd <- getDirsContainingFid(j)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
342 n <- length(fd)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
343 if (n > 0L) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
344 fidDirs <- c(fidDirs, fd)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
345 } else {warning(paste("No valid fid in",j ))}
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
346 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
347
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
348 fidNames <- sapply(X = fidDirs, FUN = getTitle, l = l, subdirs = subdirs, USE.NAMES = F)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
349 for (i in 1:length(fidNames)) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
350 fidList <- ReadFid(fidDirs[i])
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
351 fid <- fidList[["fid"]]
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
352 info <- fidList[["params"]]
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
353 m <- length(fid)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
354 if (i == 1) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
355 Fid_data <- matrix(nrow = length(fidNames), ncol = m, dimnames = list(fidNames,
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
356 info[["DT"]] * (0:(m - 1))))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
357 Fid_info <- matrix(nrow = length(fidNames), ncol = length(info), dimnames = list(fidNames,
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
358 names(info)))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
359 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
360 Fid_data[i, ] <- fid
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
361 Fid_info[i, ] <- unlist(info)
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
362 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
363
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
364
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
365 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
366
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
367 # Check for non-unique IDs ----------------------------------------------
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
368 NonnuniqueIds <- sum(duplicated(row.names(Fid_data)))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
369 cat("dim Fid_data: ", dim(Fid_data), "\n")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
370 cat("IDs: ", rownames(Fid_data), "\n")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
371 cat("non-unique IDs?", NonnuniqueIds, "\n")
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
372 if (NonnuniqueIds > 0) {
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
373 warning("There are duplicated IDs: ", Fid_data[duplicated(Fid_data)])
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
374 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
375
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
376
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
377 # Return the results ----------------------------------------------
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
378 return(list(Fid_data = endTreatment("ReadFids", begin_info, Fid_data), Fid_info = Fid_info))
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
379
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
380 }
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
381
7304ec2c9ab7 Uploaded
marie-tremblay-metatoul
parents:
diff changeset
382