2.5 Importing Everything

Given the structured nature of individual core section scans, it might be helpful to import everything into a single data object (list()). This is particularly helpful when dealing with large numbers of core sections. However, some care should be taken here, as it is easy to end up holding large quantities of data in memory, particularly where images are included. The structure of this can be adapted to your needs, but could look something like the following example. These are the data that will be used elsewhere in this guide.

CD166_19_S1 <- list(metadata   = itrax_meta("CD166_19_S1/CD166_19_S1/document.txt"),
                    xrf        = itrax_import("CD166_19_S1/CD166_19_S1/Results.txt", 
                                              depth = 0, 
                                              parameters = "all"),
                    image      = itrax_image(file = "CD166_19_S1/CD166_19_S1/optical.tif",
                                             meta = "CD166_19_S1/CD166_19_S1/document.txt"),
                    radiograph = itrax_radiograph(file = "CD166_19_S1/CD166_19_S1_RAD/radiograph0.tif",
                                                  meta = "CD166_19_S1/CD166_19_S1_RAD/document.txt",
                                                  trim = as.numeric(itrax_meta("CD166_19_S1/CD166_19_S1/document.txt")[6:7,2])))

CD166_19_S2 <- list(metadata   = itrax_meta("CD166_19_S2/CD166_19_S2/document.txt"),
                    xrf        = itrax_import("CD166_19_S2/CD166_19_S2/Results.txt", 
                                              depth = max(CD166_19_S1$xrf$depth), 
                                              parameters = "all"),
                    image      = itrax_image(file = "CD166_19_S2/CD166_19_S2/optical.tif",
                                             meta = "CD166_19_S2/CD166_19_S2/document.txt"),
                    radiograph = itrax_radiograph(file = "CD166_19_S2/CD166_19_S2_RAD/radiograph0.tif",
                                                  meta = "CD166_19_S2/CD166_19_S2_RAD/document.txt",
                                                  trim = as.numeric(itrax_meta("CD166_19_S2/CD166_19_S2/document.txt")[6:7,2])))

CD166_19_S3 <- list(metadata   = itrax_meta("CD166_19_S3/CD166_19_S3/document.txt"),
                    xrf        = itrax_import("CD166_19_S3/CD166_19_S3/Results.txt", 
                                              depth = max(CD166_19_S2$xrf$depth), 
                                              parameters = "all"),
                    image      = itrax_image(file = "CD166_19_S3/CD166_19_S3/optical.tif",
                                             meta = "CD166_19_S3/CD166_19_S3/document.txt"),
                    radiograph = itrax_radiograph(file = "CD166_19_S3/CD166_19_S3_RAD/radiograph0.tif",
                                                  meta = "CD166_19_S3/CD166_19_S3_RAD/document.txt",
                                                  trim = as.numeric(itrax_meta("CD166_19_S3/CD166_19_S3/document.txt")[6:7,2])))

CD166_19_xrf <- itrax_join(list(S1 = CD166_19_S1$xrf, S2 = CD166_19_S2$xrf, S3 = CD166_19_S3$xrf))