-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimportVSTrialTrackerDataFiles.r
executable file
·46 lines (37 loc) · 2.2 KB
/
importVSTrialTrackerDataFiles.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
source("TrackerDataFilesImport.r")
#################IMPORT TRACKER FILES # source Tracker Data Files###############################
groupsrcdatListPerDataSet <- list()
datAllSets <-list()
n <- 0
#### List Of Data files / and result label assuming organized in Directory Structure ###
for ( idxDataSet in firstDataSet:lastDataSet )
{
n <- n +1
d = strDataSetDirectories[[idxDataSet]]
groupsrcdatList = list()
strCondR <- "*.csv";
groupsrcdatList[["LE"]] <- list(getFileSet("LiveFed/Empty/",d),"-LiveFed-Empty")
groupsrcdatList[["LL"]] <- list(getFileSet("LiveFed/Live/",d),"-LiveFed-Vis. Stim.")
##OutPutFIleName
strDataSetIdentifier <- strsplit(d,"/")
strDataSetIdentifier <- strDataSetIdentifier[[1]][[ length(strDataSetIdentifier[[1]]) ]]
strDataFileName <- paste(strDataExportDir,"/setn1_Dataset_", strDataSetIdentifier,".RData",sep="") ##To Which To Save After Loading
strDataFileNameRDS <- paste(strDataExportDir,"/setn1_Dataset_", strDataSetIdentifier,".rds",sep="") ##To Which To Save After Loading
message(paste(" Importing to:",strDataFileName))
##RUN IMPORT FUNCTION
datAllFrames <-importTrackerFilesToFrame(groupsrcdatList,"extractFileNameParams_huntingExp") ##2nd param is funct. to extract data from filename
datAllFrames$dataSet <- idxDataSet ##Identify DataSet
datAllSets[[n]] <- datAllFrames
##CHeck If Exp Ids not found
stopifnot(NROW(datAllFrames[which(is.na(datAllFrames$expID)), ]) == 0)
groupsrcdatListPerDataSet[[idxDataSet]] <- groupsrcdatList
save(datAllFrames,groupsrcdatList,file=strDataFileName) ##Save With Dataset Idx Identifier
saveRDS(datAllFrames, file = strDataFileNameRDS)
#idxDataSet = idxDataSet + 1
} ##For Each DataSet Directory
#### END OF IMPORT TRACKER DATA ############
##Save the File Sources and all The Frames Combined - Just In case there are loading Problems Of the Individual RData files from each set
save(groupsrcdatListPerDataSet,file=paste(strDataExportDir,"/groupsrcdatListPerDataSet_Ds-",firstDataSet,"-",lastDataSet,".RData",sep=""))
#datAllFrames <- rbindlist(datAllSets);
datAllFrames = do.call(rbind,datAllSets);
save(datAllFrames,file=paste(strDataExportDir,"datAllFrames_Ds-",firstDataSet,"-",lastDataSet,".RData",sep=""))