[Zooimage-commits] r199 - in pkg: phytoimage/inst/gui zooimage zooimage/R zooimage/inst/gui
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Jun 11 10:44:30 CEST 2012
Author: phgrosjean
Date: 2012-06-11 10:44:30 +0200 (Mon, 11 Jun 2012)
New Revision: 199
Modified:
pkg/phytoimage/inst/gui/Menus.txt
pkg/phytoimage/inst/gui/MenusZIDlgWin.txt
pkg/phytoimage/inst/gui/ToolbarsZIDlgWin.txt
pkg/zooimage/NAMESPACE
pkg/zooimage/R/RealTime.R
pkg/zooimage/R/ZIMan.R
pkg/zooimage/R/ZIRes.R
pkg/zooimage/R/ZITrain.R
pkg/zooimage/R/errorHandling.R
pkg/zooimage/R/gui.R
pkg/zooimage/R/misc.R
pkg/zooimage/R/utilities.R
pkg/zooimage/R/zic.R
pkg/zooimage/R/zid.R
pkg/zooimage/R/zie.R
pkg/zooimage/R/zim.R
pkg/zooimage/R/zip.R
pkg/zooimage/inst/gui/Menus.txt
pkg/zooimage/inst/gui/MenusZIDlgWin.txt
pkg/zooimage/inst/gui/ToolbarsZIDlgWin.txt
Log:
Some more work towards final zooimage version 3
Modified: pkg/phytoimage/inst/gui/Menus.txt
===================================================================
--- pkg/phytoimage/inst/gui/Menus.txt 2012-06-09 13:39:49 UTC (rev 198)
+++ pkg/phytoimage/inst/gui/Menus.txt 2012-06-11 08:44:30 UTC (rev 199)
@@ -7,7 +7,7 @@
||Assistant... ~~ ZIDlg()
||-
||Exit PhytoImage ~~ exitPgm()
-||About ... ~~ aboutZI()
+||About ... ~~ aboutZI()
# Add menu to the RGui console popup (Windows only)
$ConsolePopup
Modified: pkg/phytoimage/inst/gui/MenusZIDlgWin.txt
===================================================================
--- pkg/phytoimage/inst/gui/MenusZIDlgWin.txt 2012-06-09 13:39:49 UTC (rev 198)
+++ pkg/phytoimage/inst/gui/MenusZIDlgWin.txt 2012-06-11 08:44:30 UTC (rev 199)
@@ -5,121 +5,121 @@
$Tk.ZIDlgWin
|$Analyze
||&Acquire images... Ctrl+A ~~ acquireImg()
-||&Import images... Ctrl+I ~~ importImg()
+||&Import images... Ctrl+I ~~ importImg()
||&Process images... Ctrl+J ~~ processImg()
||Make .&zid files... Ctrl+Z ~~ makeZid()
||-
||&Make training set... Ctrl+M ~~ makeTrain()
-||Add vignettes to training set ~~ increaseTrain()
+||Add vignettes to training set ~~ increaseTrain()
||&Read training set.. Ctrl+T ~~ readTrain()
||Make &classifier... Ctrl+C ~~ makeClass()
||A&nalyze classifier... Ctrl+N ~~ analyzeClass()
-||Automatic classification of vignettes ~~ vignettesClass()
+||Automatic classification of vignettes ~~ vignettesClass()
||--
-||Edit samples &description... Ctrl+D ~~ editDescription()
+||Edit samples &description... Ctrl+D ~~ editDescription()
||Process &samples... Ctrl+S ~~ processSamples()
-||&View results... Ctrl+V ~~ viewResults()
+||&View results... Ctrl+V ~~ viewResults()
||&Export results... Ctrl+E ~~ exportResults()
||---
||$E&xit
|||From the &assistant Ctrl+X ~~ closeAssistant()
-|||From &PhytoImage ~~ closePhytoImage()
+|||From &PhytoImage ~~ closePhytoImage()
|$Real-time
||&Start process... ~~ realtimeStart()
||&Stop process... ~~ realtimeStop()
||&Export results... ~~ realtimeSave()
||&Remove data... ~~ realtimeReset()
|$Objects
-||&Load ~~ loadObjects()
-||&Save ~~ saveObjects()
+||&Load ~~ loadObjects()
+||&Save ~~ saveObjects()
||-
-||&List ~~ listObjects()
-||&Remove ~~ removeObjects()
+||&List ~~ listObjects()
+||&Remove ~~ removeObjects()
|$Apps
-||&R Console Ctrl+R ~~ focusR()
-||Active R &Graph Ctrl+G ~~ focusGraph()
+||&R Console Ctrl+R ~~ focusR()
+||Active R &Graph Ctrl+G ~~ focusGraph()
||-
-||Image &viewer (XnView) ~~ startPgm("ImageViewer")
-||Image &analyzer (ImageJ) ~~ startPgm("ImageEditor", switchdir = TRUE, iconize = TRUE)
-||&Metadata editor (Sc1) ~~ startPgm("ZIEditor", cmdline = selectFile("ZimZis"))
+||Image &viewer (XnView) ~~ startPgm("ImageViewer")
+||Image &analyzer (ImageJ) ~~ startPgm("ImageEditor", switchdir = TRUE, iconize = TRUE)
+||&Metadata editor (Sc1) ~~ startPgm("ZIEditor", cmdline = selectFile("ZimZis"))
||--
||Simple acquisition (&VueScan) ~~ startPgm("VueScan", switchdir = TRUE)
|$Functions
||$PhytoImage &Metadata (zim)
-|||zimCreate() ~~ guiDlgFunction("zimCreate")
-|||zimEdit() ~~ guiDlgFunction("zimEdit")
+|||zimCreate() ~~ guiDlgFunction("zimCreate")
+|||zimEdit() ~~ guiDlgFunction("zimEdit")
|||-
-|||zimMake() ~~ guiDlgFunction("zimMake")
-|||zimVerify() ~~ guiDlgFunction("zimVerify")
+|||zimMake() ~~ guiDlgFunction("zimMake")
+|||zimVerify() ~~ guiDlgFunction("zimVerify")
|||--
-|||zimE&xtractAll() ~~ guiDlgFunction("zimExtractAll")
-|||zimRefreshAll() ~~ guiDlgFunction("zimRefreshAll")
+|||zimE&xtractAll() ~~ guiDlgFunction("zimExtractAll")
+|||zimRefreshAll() ~~ guiDlgFunction("zimRefreshAll")
||$PhytoImage &Picture (zip)
-|||zipImg() ~~ guiDlgFunction("zipImg")
-|||zipImg&All() ~~ guiDlgFunction("zipImgAll")
+|||zipImg() ~~ guiDlgFunction("zipImg")
+|||zipImg&All() ~~ guiDlgFunction("zipImgAll")
|||-
-|||unzipImg() ~~ guiDlgFunction("unzipImg")
-|||u&nzipImgAll() ~~ guiDlgFunction("unzipImgAll")
+|||unzipImg() ~~ guiDlgFunction("unzipImg")
+|||u&nzipImgAll() ~~ guiDlgFunction("unzipImgAll")
||$PhytoImage &Data (zid)
-|||makeRData() ~~ guiDlgFunction("makeRData")
-|||zidRead() ~~ guiDlgFunction("zidRead")
-|||zidExtract() ~~ guiDlgFunction("zidExtract")
+|||zidDatMake() ~~ guiDlgFunction("zidDatMake")
+|||zidDatRead() ~~ guiDlgFunction("zidDatRead")
+|||zidExtract() ~~ guiDlgFunction("zidExtract")
|||-
-|||zidVerify() ~~ guiDlgFunction("zidVerify")
-|||zidVerify&All() ~~ guiDlgFunction("zidVerifyAll")
+|||zidVerify() ~~ guiDlgFunction("zidVerify")
+|||zidVerify&All() ~~ guiDlgFunction("zidVerifyAll")
|||--
-|||zidCompress() ~~ guiDlgFunction("zidCompress")
-|||zidC&ompressAll() ~~ guiDlgFunction("zidCompressAll")
+|||zidCompress() ~~ guiDlgFunction("zidCompress")
+|||zidC&ompressAll() ~~ guiDlgFunction("zidCompressAll")
|||---
-|||zidUncompress() ~~ guiDlgFunction("zidUncompress")
-|||zidU&ncompressAll() ~~ guiDlgFunction("zidUncompressAll")
+|||zidUncompress() ~~ guiDlgFunction("zidUncompress")
+|||zidU&ncompressAll() ~~ guiDlgFunction("zidUncompressAll")
||$PhytoImage &Samples Metadata (zis)
-|||zisCreate() ~~ guiDlgFunction("zisCreate")
-|||zisEdit() ~~ guiDlgFunction("zisEdit")
+|||zisCreate() ~~ guiDlgFunction("zisCreate")
+|||zisEdit() ~~ guiDlgFunction("zisEdit")
|||-
-|||readDescription() ~~ guiDlgFunction("readDescription")
+|||readDescription() ~~ guiDlgFunction("readDescription")
||--
||$PhytoImage &Training set
-|||prepare.ZITrain() ~~ guiDlgFunction("prepare.ZITrain")
-|||get.ZITrain() ~~ guiDlgFunction("get.ZITrain")
+|||prepare.ZITrain() ~~ guiDlgFunction("prepare.ZITrain")
+|||get.ZITrain() ~~ guiDlgFunction("get.ZITrain")
|||-
-|||read.ZITrain() ~~ guiDlgFunction("read.ZITrain")
-|||write.ZITrain() ~~ guiDlgFunction("write.ZITrain")
+|||read.ZITrain() ~~ guiDlgFunction("read.ZITrain")
+|||write.ZITrain() ~~ guiDlgFunction("write.ZITrain")
|||--
-|||zip.ZITrain() ~~ guiDlgFunction("zip.ZITrain")
-|||unzip.ZITrain() ~~ guiDlgFunction("unzip.ZITrain")
+|||zip.ZITrain() ~~ guiDlgFunction("zip.ZITrain")
+|||unzip.ZITrain() ~~ guiDlgFunction("unzip.ZITrain")
|||---
-|||re&code.ZITrain() ~~ guiDlgFunction("recode.ZITrain")
-|||ZIRecodeLevels() ~~ guiDlgFunction("ZIRecodeLevels")
+|||re&code.ZITrain() ~~ guiDlgFunction("recode.ZITrain")
+|||ZIRecodeLevels() ~~ guiDlgFunction("ZIRecodeLevels")
||$PhytoImage &Classifier
-|||ZIClass() ~~ guiDlgFunction("ZIClass")
-|||predict() ~~ guiDlgFunction("predict.ZIClass")
+|||ZIClass() ~~ guiDlgFunction("ZIClass")
+|||predict() ~~ guiDlgFunction("predict.ZIClass")
|||-
-|||confu() ~~ guiDlgFunction("confu")
-|||confusion&Map() ~~ guiDlgFunction("confusionMap")
+|||confu() ~~ guiDlgFunction("confu")
+|||confusion&Map() ~~ guiDlgFunction("confusionMap")
||$PhytoImage &Results
-|||sampleProcess() ~~ guiDlgFunction("sampleProcess")
-|||sampleP&rocessAll() ~~ guiDlgFunction("sampleProcessAll")
+|||sampleProcess() ~~ guiDlgFunction("sampleProcess")
+|||sampleP&rocessAll() ~~ guiDlgFunction("sampleProcessAll")
|||-
-|||sampleAbd() ~~ guiDlgFunction("sampleAbd")
-|||sampleBio() ~~ guiDlgFunction("sampleBio")
-|||sampleSpectrum() ~~ guiDlgFunction("sampleSpectrum")
+|||sampleAbd() ~~ guiDlgFunction("sampleAbd")
+|||sampleBio() ~~ guiDlgFunction("sampleBio")
+|||sampleSpectrum() ~~ guiDlgFunction("sampleSpectrum")
|$Utilities
||Calibrate grayscale (16bit) ~~ calib()
-||Biomass conversion specification ~~ startPgm("ZIEditor", cmdline = file.path(getTemp("ZIetc"), "Conversion.txt"))
+||Biomass conversion specification ~~ startPgm("ZIEditor", cmdline = file.path(getTemp("ZIetc"), "Conversion.txt"))
||-
||$R Graphs
-|||&New ~~ dev.new()
-|||&Activate next ~~ {dev.set(); if (isRgui()) bringToTop()}
-|||&Close all ~~ graphics.off()
+|||&New ~~ dev.new()
+|||&Activate next ~~ {dev.set(); if (isRgui()) bringToTop()}
+|||&Close all ~~ graphics.off()
|$Options
-||Change &active dir... ~~ setwd(dlgDir()$res)
+||Change &active dir... ~~ setwd(dlgDir()$res)
||-
||Define decimal separator... ~~ optInOutDecimalSep()
|$Help
-||&Online help ~~ help("phytoimage")
-||&Manual Ctrl+H ~~ viewManual()
-||&Web site... ~~ browseURL("http://www.sciviews.org/zooimage")
+||&Online help ~~ help("phytoimage")
+||&Manual Ctrl+H ~~ viewManual()
+||&Web site... ~~ browseURL("http://www.sciviews.org/zooimage")
||-
-||&About PhytoImage... ~~ AboutZI(graphical = TRUE)
+||&About PhytoImage... ~~ AboutZI(graphical = TRUE)
Modified: pkg/phytoimage/inst/gui/ToolbarsZIDlgWin.txt
===================================================================
--- pkg/phytoimage/inst/gui/ToolbarsZIDlgWin.txt 2012-06-09 13:39:49 UTC (rev 198)
+++ pkg/phytoimage/inst/gui/ToolbarsZIDlgWin.txt 2012-06-11 08:44:30 UTC (rev 199)
@@ -4,8 +4,8 @@
# Create a Tk toolbar (intended for a window called 'ZIDlgWin')
$Tk.ZIDlgWin
|$MainToolbar
-||[butCam]Acquire images... ~~ acquireImg()
-||[butFilm]Import images... ~~ importImg()
+||[butCam]Acquire images... ~~ acquireImg()
+||[butFilm]Import images... ~~ importImg()
||[butTools]Process images... ~~ processImg()
||[butBluecase]Make .zid files... ~~ makeZid()
||-
@@ -14,10 +14,10 @@
||[butDirectory]Make classifier... ~~ makeClass()
||[butGraph]Analyze classifier... ~~ analyzeClass()
||-
-||[butEdit]Edit samples description... ~~ editDescription()
+||[butEdit]Edit samples description... ~~ editDescription()
||[butCubist]Process samples... ~~ processSamples()
||[butGlasses]View results... ~~ viewResults()
||[butExport]Export results... ~~ exportResults()
||-
-#||[butBlueBook]Help ~~ browseURL(findhtmlhelp("phytoimage"))
-||[butBuoy]Manual ~~ viewManual()
+#||[butBlueBook]Help ~~ browseURL(findhtmlhelp("phytoimage"))
+||[butBuoy]Manual ~~ viewManual()
Modified: pkg/zooimage/NAMESPACE
===================================================================
--- pkg/zooimage/NAMESPACE 2012-06-09 13:39:49 UTC (rev 198)
+++ pkg/zooimage/NAMESPACE 2012-06-11 08:44:30 UTC (rev 199)
@@ -48,8 +48,9 @@
export(increaseTrain)
export(isTestFile)
export(is.zim)
-export(list.add)
-export(list.merge)
+export(listAdd)
+export(listMerge)
+export(listReduce)
export(listObjects)
export(listSamples)
export(loadObjects)
@@ -61,12 +62,11 @@
export(lvq)
export(makeClass)
export(makeId)
-export(makeRData)
export(makeTrain)
export(makeZid)
export(modalAssistant)
export(nnet2)
-export(noext)
+export(noExt)
export(optInOutDecimalSep)
export(parseIni)
export(plotAbdBio)
@@ -95,8 +95,8 @@
export(selectFile)
export(setKey)
export(startPgm)
-export(trimstring)
-export(underscore2space)
+export(trimString)
+export(underscoreToSpace)
export(unzipImg)
export(unzipImgAll)
export(unzip.ZITrain)
@@ -110,8 +110,9 @@
export(zidClean)
export(zidCompress)
export(zidCompressAll)
+export(zidDatMake)
+export(zidDatRead)
export(zidExtract)
-export(zidRead)
export(zidUncompress)
export(zidUncompressAll)
export(zidVerify)
@@ -195,8 +196,9 @@
# imagemagick_identify
# imageViewer
# jpgList
+# pngList
# listFilesExt
-# list.dir
+# listDirs
# misc
# misc_dcraw
# netpbm
@@ -217,6 +219,7 @@
# xite_pnm2biff
# xite_statistics
# zidList
+# zidbList
# zipList
# zip
# zipNoteAdd
Modified: pkg/zooimage/R/RealTime.R
===================================================================
--- pkg/zooimage/R/RealTime.R 2012-06-09 13:39:49 UTC (rev 198)
+++ pkg/zooimage/R/RealTime.R 2012-06-11 08:44:30 UTC (rev 199)
@@ -354,7 +354,7 @@
if (length(compare.smp) == 1) {
if(length(grep(pattern = ".[Zz][Ii][Dd]", x = compare.smp)) >= 1) {
## This a zid file
- Smp <- zidRead(compare.smp)
+ Smp <- zidDatRead(compare.smp)
} else {
## This is a list file
Smp <- lstRead(compare.smp)
@@ -362,14 +362,14 @@
Smp <- predict(ZIClass, Smp, calc.vars = FALSE, class.only = FALSE)
Smp <- calcBiomass(ZIDat = Smp, conv = conv.dir, realtime = TRUE)
List <- list(Smp)
- names(List) <- noext(basename(compare.smp))
+ names(List) <- noExt(basename(compare.smp))
} else {
List <- list()
if (length(grep(pattern = ".[Zz][Ii][Dd]", x = compare.smp)) >= 1) {
## This a zid file
for (i in 1 : length(compare.smp))
List[[i]] <- calcBiomass(ZIDat = predict(ZIClass,
- zidRead(compare.smp[i]), calc.vars = FALSE,
+ zidDatRead(compare.smp[i]), calc.vars = FALSE,
class.only = FALSE), conv = conv.dir, realtime = TRUE)
} else {
## This is a list file
@@ -378,7 +378,7 @@
lstRead(compare.smp[i]), calc.vars = FALSE,
class.only = FALSE), conv = conv.dir, realtime = TRUE)
}
- names(List) <- noext(basename(compare.smp))
+ names(List) <- noExt(basename(compare.smp))
}
compare.smp <- List
} else compare.smp <- FALSE
Modified: pkg/zooimage/R/ZIMan.R
===================================================================
--- pkg/zooimage/R/ZIMan.R 2012-06-09 13:39:49 UTC (rev 198)
+++ pkg/zooimage/R/ZIMan.R 2012-06-11 08:44:30 UTC (rev 199)
@@ -21,7 +21,7 @@
Filter = NULL)
{
DirName <- dirname(zidfile)
- ZidName <- noext(zidfile)
+ ZidName <- noExt(zidfile)
ZidDir <- file.path(DirName, ZidName)
## Check if Directory with the same names as ZIdfile
@@ -73,7 +73,7 @@
if (isTRUE(ContinueProcess)) {
## Do we use a ZIDat object allready recognized?
if (is.null(ZIDat)) {
- Zid <- zidRead(zidfile)
+ Zid <- zidDatRead(zidfile)
} else Zid <- ZIDat
## Code for suspect detection!
Modified: pkg/zooimage/R/ZIRes.R
===================================================================
--- pkg/zooimage/R/ZIRes.R 2012-06-09 13:39:49 UTC (rev 198)
+++ pkg/zooimage/R/ZIRes.R 2012-06-11 08:44:30 UTC (rev 199)
@@ -29,7 +29,7 @@
stop("'ZIClass' must be a 'ZIClass' object")
## Get ZIDat from the ZidFile
- ZIDat <- zidRead(ZidFile)
+ ZIDat <- zidDatRead(ZidFile)
## By default, we have to predict ZidFile with a classifier
MakePredictions <- TRUE
@@ -44,7 +44,7 @@
AllSamples <- attr(ZIMan, "Samples")
## Check if manual validation exists for this zid file
- if (noext(ZidFile) %in% AllSamples) {
+ if (noExt(ZidFile) %in% AllSamples) {
## The ZidFile was manually validated
## --> use Class column for identification
## Subtable of ZidFile vignettes
Modified: pkg/zooimage/R/ZITrain.R
===================================================================
--- pkg/zooimage/R/ZITrain.R 2012-06-09 13:39:49 UTC (rev 198)
+++ pkg/zooimage/R/ZITrain.R 2012-06-11 08:44:30 UTC (rev 199)
@@ -125,7 +125,7 @@
if (!keep_) res <- grep("^[^_]", res, value = TRUE)
## 'Id' is the name of the vignettes, minus the extension
- Id <- noext(basename(res))
+ Id <- noExt(basename(res))
## 'Path' is the directory path
Path <- dirname(res)
Modified: pkg/zooimage/R/errorHandling.R
===================================================================
--- pkg/zooimage/R/errorHandling.R 2012-06-09 13:39:49 UTC (rev 198)
+++ pkg/zooimage/R/errorHandling.R 2012-06-11 08:44:30 UTC (rev 199)
@@ -121,7 +121,8 @@
"zidVerifyAll" = "path",
"zidClean" = "path",
"zidUncompressAll" = "zidfiles",
- "zidRead" = "zidfile",
+ "zidDatMake" = "zidir",
+ "zidDatRead" = "zidfile",
## --------------------------------------- utilities.R
"sampleInfo" = "filename",
@@ -143,7 +144,6 @@
"get.ZITrain" = "dir",
"forceDirCreate" = "path",
"checkEmptyDir" = "dir",
- "makeRData" = "zidir",
"processSample" = "Sample",
"processSampleAll" = "Samples"
)
Modified: pkg/zooimage/R/gui.R
===================================================================
--- pkg/zooimage/R/gui.R 2012-06-09 13:39:49 UTC (rev 198)
+++ pkg/zooimage/R/gui.R 2012-06-11 08:44:30 UTC (rev 199)
@@ -1315,7 +1315,7 @@
if (length(zid) > 1) {
classVignettesAll(zidfiles = zid, Dir = "_manuValidation", ZIClass = zicObj)
} else {
- classVignettes(zidfile = zid, Dir = noext(zid), ZIClass = zicObj)
+ classVignettes(zidfile = zid, Dir = noExt(zid), ZIClass = zicObj)
}
}
@@ -1327,7 +1327,7 @@
if (!length(zidFile)) return(invisible(NULL))
## Read the zid file
- zid <- zidRead(zidFile)
+ zid <- zidDatRead(zidFile)
## Select a parameter to use for the threshold
threshold <- createThreshold(ZIDat = zid)
@@ -1357,7 +1357,7 @@
if (!length(finalDir)) return(invisible(NULL))
## Read the zid file
- ZIDat <- zidRead(zid)
+ ZIDat <- zidDatRead(zid)
## Select a parameter to use for the threshold
threshold <- createThreshold(ZIDat = ZIDat)
Modified: pkg/zooimage/R/misc.R
===================================================================
--- pkg/zooimage/R/misc.R 2012-06-09 13:39:49 UTC (rev 198)
+++ pkg/zooimage/R/misc.R 2012-06-11 08:44:30 UTC (rev 199)
@@ -58,8 +58,7 @@
pattern = extensionPattern(extension), ... )
{
checkDirExists(dir)
- out <- list.files(dir, pattern = pattern , ...)
- return(out)
+ list.files(dir, pattern = pattern , ...)
}
zimList <- function (zidir, ...)
@@ -73,9 +72,15 @@
zidList <- function (zidir, ...)
listFilesExt(zidir, extension = "zid", ...)
+
+zidbList <- function (zidir, ...)
+ listFilesExt(zidir, extension = "zidb", ...)
jpgList <- function (dir, ...)
listFilesExt(dir, extension = "jpg", ...)
+
+pngList <- function (dir, ...)
+ listFilesExt(dir, extension = "png", ...)
## Transforms a file extension to a pattern for ignore.case matching of the
## extension: extension (with or without the dot at the beginning)
@@ -159,11 +164,11 @@
}
## Checks the first line of a file against some expected content
-checkFirstLine <- function (file, expected = "ZI1",
-message = 'file "%s" is not a valid ZooImage version 1 file', stop = FALSE)
+checkFirstLine <- function (file, expected = c("ZI1", "ZI2", "ZI3"),
+message = 'file "%s" is not a valid ZooImage version <= 3 file', stop = FALSE)
{
Line1 <- scan(file, character(), nmax = 1, quiet = TRUE)
- res <- Line1 == expected
+ res <- Line1 %in% expected
if (!res && stop) {
message <- sprintf(message, file)
stop(message)
@@ -171,7 +176,7 @@
return(invisible(res))
}
-list.dir <- function (dir, ...)
+listDirs <- function (dir, ...)
{
out <- list.files(dir)
out[file.info(file.path(dir, basename(out)))$isdir]
@@ -234,8 +239,8 @@
comment <- !is.null(comment.file) && file.exists(comment.file)
## Build the list of parameters for zip
- zippar <- sprintf("-rq9%s%s", if(delete.source) "m" else "",
- if(comment) "z" else "")
+ zippar <- sprintf("-rq9%s%s", if (delete.source) "m" else "",
+ if (comment) "z" else "")
## Create the basic command
cmd <- sprintf('"%s" %s "%s" "%s"', ZIpgm("zip", "misc"), zippar,
Modified: pkg/zooimage/R/utilities.R
===================================================================
--- pkg/zooimage/R/utilities.R 2012-06-09 13:39:49 UTC (rev 198)
+++ pkg/zooimage/R/utilities.R 2012-06-11 08:44:30 UTC (rev 199)
@@ -55,15 +55,15 @@
}
## Convert underscores into spaces
-underscore2space <- function (char)
+underscoreToSpace <- function (char)
return(gsub("_", " ", char))
## Trim leading and trailing white spaces and tabs
-trimstring <- function (char)
+trimString <- function (char)
return(sub("\\s+$", "", sub("^\\s+", "", char)))
## Get the name of a file, without its extension
-noext <- function (file)
+noExt <- function (file)
return(sub("\\.[^.]+$", "", basename(file)))
## Get information about a sample, given its name
@@ -184,11 +184,11 @@
# Is str a section?
is.section <- function (str)
- as.logical(length(grep("^\\[.+\\]$", trimstring(str)) > 0))
+ as.logical(length(grep("^\\[.+\\]$", trimString(str)) > 0))
## Get the name of a section
get.section.name <- function (str)
- sub("^\\[", "", sub("\\]$", "", trimstring(str)))
+ sub("^\\[", "", sub("\\]$", "", trimString(str)))
## Transform a vector of characters into a data frame,
## possibly with type conversion
@@ -199,10 +199,10 @@
return(character(0))
## Trim leading and trailing white spaces
- data <- trimstring(data)
+ data <- trimString(data)
## Convert underscore to space
- data <- underscore2space(data)
+ data <- underscoreToSpace(data)
## Eliminate empty lines
data <- data[data != ""]
@@ -222,8 +222,8 @@
## Make sure we have a section for the first entries (otherwise, use [.])
if (!is.section(data[1, 1]))
data <- rbind(c("[.]", "[.]"), data)
- Names <- as.vector(trimstring(data[, 1]))
- Dat <- as.vector(trimstring(data[, 2]))
+ Names <- as.vector(trimString(data[, 1]))
+ Dat <- as.vector(trimString(data[, 2]))
## Determine which is a section header
Sec <- grep("\\[.+\\]$", Names)
@@ -258,7 +258,7 @@
}
## Merge two lists of data frames
-list.merge <- function (x, y)
+listMerge <- function (x, y)
{
if (!inherits(x, "list") || !inherits(y, "list"))
stop("'x' and 'y' must both be 'list' objects")
@@ -282,10 +282,10 @@
}
## Add items across two lists (names must be the same)
-list.add <- function (..., .list = list(...))
- list.reduce(.list= .list, FUN = "+")
+listAdd <- function (..., .list = list(...))
+ listReduce(.list= .list, FUN = "+")
-list.reduce <- function (..., .list = list(...), FUN = "+" )
+listReduce <- function (..., .list = list(...), FUN = "+")
{
.list <- Filter(Negate(is.null), .list)
if (length(.list) == 1) return(.list[[1]])
@@ -385,7 +385,7 @@
pathpgm <- system.file(subdir, "bin", paste(pgm, ext, sep = "."),
package = "zooimage")
if (!file.exists(pathpgm)) return("") else
- return(shortPathName(pathpgm))
+ return(pathpgm)
} else {
## Change nothing: should be directly executable
if (pgm == "dc_raw") pgm <- "dcraw"
@@ -471,34 +471,34 @@
zidUncompress(path.zid[i])
## Calculate new Rdata
path.sample <- sub("[.][zZ][iI][dD]", "", path.zid[i])
- makeRData(path.sample, replace = replace)
+ zidDatMake(path.sample, replace = replace)
## Compress new zid file
zidCompress(path.sample, replace = replace)
}
}
## Function to create a batch file for FlowCAM image analysis
-createBatchFile <- function (ctx, fil = FALSE, largest = FALSE,
+createBatchFile <- function (ctxfile, fil = FALSE, largest = FALSE,
vignettes = TRUE, scalebar = TRUE, enhance = FALSE, outline = FALSE,
masks = FALSE, verbose = TRUE, txt = TRUE,
import.name = "batchExampleParameters")
{
## Check arguments
- if (!is.character(ctx)) stop("You must provide a context file")
+ if (!is.character(ctxfile)) stop("You must provide a context file")
## Create the table of importation
- ContextList <- ctxReadAll(ctx = ctx, fil = fil, largest = largest,
+ ContextList <- ctxReadAll(ctxfile = ctxfile, fil = fil, largest = largest,
vignettes = vignettes, scalebar = scalebar, enhance = enhance,
outline = outline, masks = masks, verbose = verbose)
## Write the table of importation in the sample directory
if (isTRUE(txt)) { # Export table as txt format
- write.table(ContextList, file = paste(dirname(dirname(ctx)),
+ write.table(ContextList, file = paste(dirname(dirname(ctxfile)),
paste(import.name, ".txt", sep = ""), sep = "/"), quote = TRUE,
sep = "\t", dec = ".", row.names = FALSE, col.names = TRUE)
} else { # Export table as csv format
- write.csv(ContextList, file = paste(dirname(dirname(ctx)),
+ write.csv(ContextList, file = paste(dirname(dirname(ctxfile)),
paste(import.name, ".csv", sep = ""), sep = "/"), row.names = FALSE)
}
- cat(paste("Your import table has been created in", dirname(dirname(ctx)),
+ cat(paste("Your import table has been created in", dirname(dirname(ctxfile)),
" : your samples directory", "\n", sep = " "))
}
Modified: pkg/zooimage/R/zic.R
===================================================================
--- pkg/zooimage/R/zic.R 2012-06-09 13:39:49 UTC (rev 198)
+++ pkg/zooimage/R/zic.R 2012-06-11 08:44:30 UTC (rev 199)
@@ -16,16 +16,16 @@
## along with ZooImage. If not, see <http://www.gnu.org/licenses/>.
## Check that the file is a zic file
-zicCheck <- function (file)
+zicCheck <- function (zicfile)
{
## This should be a .zic file directly
- checkFileExists(file)
+ checkFileExists(zicfile)
- ## First line of the file must be "ZI1"
- checkFirstLine(file)
+ ## First line of the file must be "ZI1", "ZI2", or "ZI3"
+ checkFirstLine(zicfile)
## Second line must be [path]
- Line2 <- scan(file, character(), skip = 1, nmax = 1, quiet = TRUE)
+ Line2 <- scan(zicfile, character(), skip = 1, nmax = 1, quiet = TRUE)
if (tolower(Line2) != "[path]")
- stop("not a ZooImage1 .zic file, or corrupted!")
+ stop("not a ZooImage .zic file, or corrupted!")
}
Modified: pkg/zooimage/R/zid.R
===================================================================
--- pkg/zooimage/R/zid.R 2012-06-09 13:39:49 UTC (rev 198)
+++ pkg/zooimage/R/zid.R 2012-06-11 08:44:30 UTC (rev 199)
@@ -1,4 +1,4 @@
-## Copyright (c) 2004-2010, Ph. Grosjean <phgrosjean at sciviews.org>
+## Copyright (c) 2004-2012, Ph. Grosjean <phgrosjean at sciviews.org>
##
## This file is part of ZooImage
##
@@ -15,22 +15,23 @@
## You should have received a copy of the GNU General Public License
## along with ZooImage. If not, see <http://www.gnu.org/licenses/>.
-## Check consistancy of a zoo image directory
+## Check consistency of a zoo image directory
## zidir: the directory to check
-## type: must be ZI1
+## type: must be ZI1, ZI2 or ZI3
## check.vignettes: do we check vignettes as well
## show.log: do we show a log at the end
-zidVerify <- function (zidir, type = "ZI1", check.vignettes = TRUE,
-show.log = TRUE)
+zidVerify <- function (zidir, type = c("ZI1", "ZI2", "ZI3"),
+check.vignettes = TRUE, show.log = TRUE)
{
## Check the format of the file
- ## This should be a directory containing XXX+YY_dat1.zim files + .jpg files
- if (type != "ZI1")
- stop("only 'ZI1' is currently supported for 'type'!")
+ ## This should be a directory containing XXX+YY_dat1.zim files
+ ## + .jpg or .png files (vignettes)
+ if (any(!type %in% c("ZI1", "ZI2", "ZI3")))
+ stop("only 'ZI1', 'ZI2' or 'ZI3' are currently supported for 'type'")
## Check the list of _dat1.zim
dat1files <- zimDatList(zidir)
- if(length(dat1files) == 0)
+ if (length(dat1files) == 0)
stop("no '_dat1.zim' file!")
## Check the content of all these "_dat1.zim" files
@@ -38,8 +39,7 @@
dat1files <- sort(dat1files)
## Default to -1 for corrupted dat1 files
nitems <- sapply(dat1files, function(x) {
- tryCatch(
- zimVerify(file.path(zidir, x), is.dat1 = TRUE ),
+ tryCatch(zimVerify(file.path(zidir, x), is.dat1 = TRUE ),
zooImageError = function (e) {
logError(e)
return(-1)
@@ -49,32 +49,35 @@
## Check the vignettes
if (check.vignettes) {
- ## Check that we have corresponding vignettes (XXX+YY_ZZZ.jpg files)
+ ## Check that we have corresponding vignettes (XXX+YY_ZZZ.jpg/png files)
samples <- sub("_dat1[.]zim$", "", dat1files)
- ## Check the content of the directory for .jpg files
- for (i in 1:length(samples)) {
-
+ ## Check the content of the directory for .jpg or .png files
+ for (i in 1:length(samples)) {
## List the jpegs
regex <- gsub("[+]", "[+]", samples[i])
regex <- gsub("[.]", "[.]", regex)
regex2 <- paste("^", regex, "_[0-9]+[.]jpg$", sep = "")
- jpgs <- dir(zidir, pattern = regex2)
+ vigstype <- "jpg"
+ vigs <- dir(zidir, pattern = regex2)
+ if (!length(vigs)) { # Try also for .png vignettes
+ regex2 <- paste("^", regex, "_[0-9]+[.]png$", sep = "")
+ vigstype <- "png"
+ vigs <- dir(zidir, pattern = regex2)
+ }
- ## Get their numbers, sort them, and make sure none are missing
+ ## Get their numbers, sort them, and make sure none is missing
n <- nitems[i]
- if (n < 1) {
- ## If impossible to know how many items, just count vignettes
- n <- length(jpgs)
- }
+ ## If impossible to know how many items, just count vignettes
+ if (n < 1) n <- length(vigs)
## Construct a vector with names of vignettes as they should be
- chkjpgs <- paste(samples[i], "_", 1:n, ".jpg", sep = "")
- if (length(jpgs) == 0 && length(chkjpgs) > 0) {
+ chkvigs <- paste(samples[i], "_", 1:n, ".", vigstype, sep = "")
+ if (length(vigs) == 0 && length(chkvigs) > 0) {
warning(paste(" no vignettes for", samples[i]))
ok <- FALSE
- } else if (length(chkjpgs) != length(jpgs) ||
- !all(sort(chkjpgs) == sort(jpgs))) {
+ } else if (length(chkvigs) != length(vigs) ||
+ !all(sort(chkvigs) == sort(vigs))) {
warning(paste(" mismatch vignettes for", samples[i]))
ok <- FALSE
}
@@ -88,22 +91,23 @@
logProcess("Errors found", zidir, show.log = show.log)
}
- ## TODO: we should not return ok here ?
+ ## TODO: we should not return ok here?
return(invisible(ok))
}
-zidVerifyAll <- function(path = ".", samples = NULL, type = "ZI1",
-check.vignettes = TRUE, show.log = TRUE, bell = FALSE)
+zidVerifyAll <- function (path = ".", samples = NULL,
+type = c("ZI1", "ZI2", "ZI3"), check.vignettes = TRUE, show.log = TRUE,
+bell = FALSE)
{
## Verify all of these directories
- if (type != "ZI1")
- stop("only 'ZI1' is currently supported for 'type'!")
+ if (any(!type %in% c("ZI1", "ZI2", "ZI3")))
+ stop("only 'ZI1', 'ZI2' or 'ZI3' are currently supported for 'type'")
## First, switch to that directory
inidir <- getwd()
checkDirExists(path)
- setwd(path)
on.exit(setwd(inidir))
+ setwd(path)
path <- "." # Indicate we are now in the right path
## Process the list of samples
@@ -118,188 +122,35 @@
## Start the process
smax <- length(samples)
+ logClear()
cat("Verification...\n")
+ logProcess("\nVerification...")
- ok <- sapply( samples, function(s) {
- tryCatch(zidVerify( s, type = type,
+ ok <- sapply(samples, function(s) {
+ tryCatch(zidVerify(s, type = type,
check.vignettes = check.vignettes, show.log = FALSE),
zooImageError = function (e) return(-1))
})
## Clean up
- finishLoop(all(ok) , bell = bell, show.log = show.log)
+ finishLoop(all(ok), bell = bell, show.log = show.log)
}
-## Make a .RData file that collates together data from all the "_dat1.zim" files
-## of a given sample
-makeRData <- function (zidir, type = "ZI1", replace = FALSE, show.log = TRUE)
-{
- if (type != "ZI1")
- stop("only 'ZI1' is currently supported for 'type'!")
- RDataFile <- file.path(zidir, paste(basename(zidir), "_dat1.RData",
- sep = ""))
-
- ## File already exists
- if (file.exists(RDataFile) && !replace)
- return(invisible(TRUE))
- ok <- TRUE
- dat1files <- zimDatList(zidir)
-
- ## modif to create zidat1zim files
- ## Create dat1zim if ity is missing (Special treatment for FlowCAM data)
- if (length(dat1files) == 0){
- ## Try to create them
- SmpDir <- dirname(zidir)
- ZimFile <- file.path(SmpDir, paste(basename(zidir), ".zim", sep = ""))
- zimDatMake(ZimFile)
- dat1files <- zimDatList(zidir)
- if (length(dat1files) == 0){
- stop("no '_dat1.zim' file!")
- }
- }
-
- dat1files <- sort(dat1files)
- fractions <- sampleInfo(dat1files, "fraction")
-
- ## Avoid collecting duplicate informations about fractions
- fracdup <- duplicated(fractions)
- results <- lapply(seq.int(1, length(dat1files)), function(i) {
- dat1path <- file.path(zidir, dat1files[i])
- iszim <- tryCatch(is.zim(dat1path), zooImageError = function(e) {
- logError(e)
- return(FALSE)
- })
- if (!iszim)
- return(NULL)
-
- ## Read the header
- Lines <- scan(dat1path, character(), sep = "\t", skip = 1,
- blank.lines.skip = FALSE, flush = TRUE, quiet = TRUE,
- comment.char = "#")
- if (length(Lines) < 1) {
- logProcess("is empty, or is corrupted", dat1files[i])
- return(NULL)
- }
-
- ## Trim leading and trailing spaces in Lines
- Lines <- trimstring(Lines)
-
- ## Convert underscore to space
- Lines <- underscore2space(Lines)
-
- ## Determine start of the measurements table (it is '[Data]' header)
- endhead <- tail(which(Lines == "[Data]"), 1)
- if (!is.null(endhead))
- Lines <- if (endhead > 1)
- Lines[seq.int(1, endhead - 1)]
-
- ## Decrypt all lines, that is, split on first occurrence
- ## of "=" into 'tag', 'value' and separate into sections
-## Bug meta is not calculated if fracdup[i] = TRUE and thus there is no meta calculated
-## meta <- if (!fracdup[i] && !is.null(Lines))
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/zooimage -r 199
More information about the Zooimage-commits
mailing list