[Zooimage-commits] r255 - in pkg/zooimage: . R inst/gui/errorcorrection man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Oct 9 17:46:50 CEST 2015


Author: phgrosjean
Date: 2015-10-09 17:46:49 +0200 (Fri, 09 Oct 2015)
New Revision: 255

Modified:
   pkg/zooimage/DESCRIPTION
   pkg/zooimage/NAMESPACE
   pkg/zooimage/NEWS
   pkg/zooimage/R/ZIRes.R
   pkg/zooimage/R/gui.R
   pkg/zooimage/TODO
   pkg/zooimage/inst/gui/errorcorrection/server.R
   pkg/zooimage/man/ZIRes.Rd
   pkg/zooimage/man/gui.Rd
   pkg/zooimage/man/zooimage.package.Rd
Log:
Cells counting per colonies

Modified: pkg/zooimage/DESCRIPTION
===================================================================
--- pkg/zooimage/DESCRIPTION	2015-10-01 08:16:26 UTC (rev 254)
+++ pkg/zooimage/DESCRIPTION	2015-10-09 15:46:49 UTC (rev 255)
@@ -1,8 +1,8 @@
 Package: zooimage
 Type: Package
 Title: Analysis of Numerical Zooplankton Images
-Version: 5.4-2
-Date: 2015-10-01
+Version: 5.4-3
+Date: 2015-10-09
 Author: Philippe Grosjean [aut, cre],
   Kevin Denis [aut], Guillaume Wacquet [aut]
 Authors at R: c(person("Philippe", "Grosjean", role = c("aut", "cre"),

Modified: pkg/zooimage/NAMESPACE
===================================================================
--- pkg/zooimage/NAMESPACE	2015-10-01 08:16:26 UTC (rev 254)
+++ pkg/zooimage/NAMESPACE	2015-10-09 15:46:49 UTC (rev 255)
@@ -172,6 +172,7 @@
 export(optInOutDecimalSep)
 export(processImg)
 export(processSamples)
+export(processSamplesWithCells)
 export(removeObjects)
 export(saveObjects)
 export(validClass)

Modified: pkg/zooimage/NEWS
===================================================================
--- pkg/zooimage/NEWS	2015-10-01 08:16:26 UTC (rev 254)
+++ pkg/zooimage/NEWS	2015-10-09 15:46:49 UTC (rev 255)
@@ -1,5 +1,10 @@
 = zooimage News
 
+== Changes in zooimage 5.4-3
+
+* Cells counting per colonies (per particles) is now provided.
+
+
 == Changes in zooimage 5.4-2
 
 * Correction of one bug in the function addVigsToTrain().

Modified: pkg/zooimage/R/ZIRes.R
===================================================================
--- pkg/zooimage/R/ZIRes.R	2015-10-01 08:16:26 UTC (rev 254)
+++ pkg/zooimage/R/ZIRes.R	2015-10-09 15:46:49 UTC (rev 255)
@@ -103,33 +103,12 @@
 }
 
 ## Calculate abundances, biomasses and size spectra per class in a sample
-#processSample <- function (x, sample, keep = NULL, detail = NULL, classes = "both",
-#header = c("Abd", "Bio"), cells = NULL, biomass = NULL, breaks = NULL)
 processSample <- function (x, sample, keep = NULL, detail = NULL, classes = "both",
-header = c("Abd", "Bio"), biomass = NULL, breaks = NULL)
+header = c("Abd", "Bio"), cells = NULL, biomass = NULL, breaks = NULL)
 {
 	## Fix ECD in case of FIT_VIS data
 	if ("FIT_Area_ABD" %in% names(x)) x$ECD <- ecd(x$FIT_Area_ABD)
-	
-	## Do we compute the number of cells and the ECD per cell?
-	## But see version hereunder!
-#### TODO: compute ECD using number of cells per colonies!
-####	if (!is.null(cells)) {
-####		x$Nb_cells <- computeNbCells(x, cells)
-####		x$ECD_cells <- ecd(x$FIT_Area_ABD, x$Nb_cells)
-####	}
-#### PhG: here, computation before argument checking is not good!
-#### PhG: cells points to a file. Not good! We ask for a specific object instead
-		
-	## Do we compute the number of cells and the ECD per cell?
-	## PhG: should not rely on a filehere!
-####	if (!is.null(cells) && file.exists(cells)) {
-####		## Must be a ZICell model here! predict() iterates on all items
-####		## of the list to compute cells for all classes!
-####		x$Nb_cells <- predict(cells, x)
-####		x$ECD_cells <- ecd(x$FIT_Area_ABD, x$Nb_cells)
-####}
-		
+			
 	## Check arguments
 	if (missing(sample)) {
 		sample <- unique(sampleInfo(x$Label, type = "sample", ext = ""))
@@ -157,6 +136,16 @@
 		return(NULL)
 	}
 	
+	## Do we compute the number of cells and the ECD per cell?
+	## TODO: should not rely on a file here (use a predict() method of a ZICell object)!
+	if (!is.null(cells) && file.exists(cells)) {
+####		## Must be a ZICell model here! predict() iterates on all items
+####		## of the list to compute cells for all classes!
+####		x$Nb_cells <- predict(cells, x)
+		x$Nbr_cells <- cellCompute(x, cells) 
+		x$ECD_cells <- ecd(x$FIT_Area_ABD, x$Nb_cells)
+	}
+	
 	## Extract only data for a given sample
 	allSamples <- unique(sampleInfo(x$Label, type = "sample", ext = ""))
 	if (!sample %in% allSamples){
@@ -330,7 +319,7 @@
 			'[total]' = apply(spectrum, 2, sum))	
 		}
 		
-		## Eliminate all ine except total if detail is not provided
+		## Eliminate all lines except total if detail is not provided
 		if (!length(detail))
 			spectrum <- spectrum[NROW(spectrum), , drop = FALSE]
 
@@ -344,8 +333,8 @@
 }
 
 processSampleAll <- function (path = ".", zidbfiles, ZIClass = NULL, keep = NULL,
-detail = NULL, classes = "both", header = c("Abd", "Bio"), biomass = NULL,
-breaks = NULL)
+detail = NULL, classes = "both", header = c("Abd", "Bio"), cells = NULL,
+biomass = NULL, breaks = NULL)
 {
 	## First, switch to that directory                                       
 	if (!checkDirExists(path)) return(invisible(FALSE))
@@ -382,8 +371,8 @@
 
 		## Process that one sample and merge with the rest
 		res <- rbind(res, processSample(dat, keep = keep, detail = detail,
-			classes = classes, header = header, biomass = biomass,
-			breaks = breaks))
+			classes = classes, header = header, cells = cells,
+			biomass = biomass, breaks = breaks))
 	}
 	progress(101) # Clear progression indicator
 	message(" -- Done! --")

Modified: pkg/zooimage/R/gui.R
===================================================================
--- pkg/zooimage/R/gui.R	2015-10-01 08:16:26 UTC (rev 254)
+++ pkg/zooimage/R/gui.R	2015-10-09 15:46:49 UTC (rev 255)
@@ -30,8 +30,8 @@
 	menuAddItem(ZIname, "Interactive UI", "ZIUI()")
 	menuAddItem(ZIname, "--", "")
 	menuAddItem(ZIname, "Online help", 'help("zooimage")')
-	menuAddItem(ZIname, "Manual (English version)", "viewManual()")
-	menuAddItem(ZIname, "Manual (French version)", "viewFrenchManual()")
+	menuAddItem(ZIname, "Manual (English version)", "viewManual()")
+	menuAddItem(ZIname, "Manual (French version)", "viewFrenchManual()")
 	menuAddItem(ZIname,
 		"Web site", 'browseURL("http://www.sciviews.org/zooimage")')
 	menuAddItem(ZIname, "--", "")
@@ -48,7 +48,7 @@
 	menuAddItem("Analyze", "-", "")
 	menuAddItem("Analyze", "Make training set...", "makeTrain()")
 	menuAddItem("Analyze", "Add vignettes to training set", "addVigsToTrain()")
- 	menuAddItem("Analyze", "Differences between two training sets", "compTrain()")
+ 	menuAddItem("Analyze", "Differences between two training sets", "compTrain()")
 	menuAddItem("Analyze", "Count cells in colonies...", "countCellsGUI()")
 	menuAddItem("Analyze", "Read training set...", "collectTrain()")
 	menuAddItem("Analyze", "Make classifier...", "makeClass()")
@@ -60,6 +60,7 @@
 	menuAddItem("Analyze", "--", "")
 	menuAddItem("Analyze", "Edit samples description", "editDescription()")
 	menuAddItem("Analyze", "Process samples...", "processSamples()")
+	menuAddItem("Analyze", "Process samples with cells counting...", "processSamplesWithCells()")
 	menuAddItem("Analyze", "View results...", "viewResults()")
 	menuAddItem("Analyze", "Export results...", "exportResults()")
 	
@@ -234,20 +235,20 @@
 	} else browseURL(manual)
 }
 
-viewFrenchManual <- function ()
-{
-  manual <- file.path(getTemp("ZIetc"), "ZooImageManual_french.pdf")
-  pdfviewer <- getOption( "pdfviewer" )
-  if (!is.null(pdfviewer)) {
-    if (.Platform$OS.type == "windows") {
-      shell.exec(manual)
-    } else {
-      system(paste(shQuote(getOption("pdfviewer")), shQuote(manual)),
-             wait = FALSE)
-    }
-  } else browseURL(manual)
-}
-
+viewFrenchManual <- function ()
+{
+  manual <- file.path(getTemp("ZIetc"), "ZooImageManual_french.pdf")
+  pdfviewer <- getOption( "pdfviewer" )
+  if (!is.null(pdfviewer)) {
+    if (.Platform$OS.type == "windows") {
+      shell.exec(manual)
+    } else {
+      system(paste(shQuote(getOption("pdfviewer")), shQuote(manual)),
+             wait = FALSE)
+    }
+  } else browseURL(manual)
+}
+
 focusR <- function ()
 {
 	## Switch the focus to the R console
@@ -590,7 +591,7 @@
 	if (!length(subdir)) return(invisible(NULL))
 
 	## Ask for the .zid files
-    zidfiles <- selectFile(type = "ZidZidb", multiple = TRUE, quote = FALSE)
+    zidfiles <- selectFile(type = "ZidZidb", multiple = TRUE, quote = FALSE)
 	if (!length(zidfiles)) return(invisible(NULL))
 
 	## Prepare the training set
@@ -758,7 +759,7 @@
 			if (ChgVigs[i] %in% RedundantVigs1) {
 				status <- "Redundant"
 				pathTrain1 <- Paths1[which(Vigs1 == ChgVigs[i])]
-				pathTrain2 <- ""
+				pathTrain2 <- ""
 				ChgToSave <- rbind(ChgToSave, cbind(nameChg, status,
 					pathTrain1, pathTrain2))
 			}
@@ -1145,19 +1146,19 @@
 	if (!length(ZIT) || (length(ZIT) == 1 && ZIT == ""))
 		return(invisible(NULL))
   
-	## Call activeLearning (for augmentation of training set)
-	train <- activeLearning(train = get(ZIT, envir = .GlobalEnv),
-	                        add.mode = "SV+NSV", threshold = NA)
-# 	## Call contextSelection (for selection of contextual samples)
-# 	CtxSmp <- contextSelection()
-# 	if (length(CtxSmp) < 1) {
-# 		warning("No contextual samples selected! Initial training set will be used...")
-# 	} else {
-# 		## Call addItemsToTrain (for augmentation of the training set)
-# 		train <- addItemsToTrain(train = get(ZIT, envir = .GlobalEnv),
-# 			CtxSmp = CtxSmp, add.mode = "SV+NSV", threshold = NA,
-# 			dropItemsToTrain = dropItemsToTrain)
-# 	}
+	## Call activeLearning (for augmentation of training set)
+	train <- activeLearning(train = get(ZIT, envir = .GlobalEnv),
+	                        add.mode = "SV+NSV", threshold = NA)
+# 	## Call contextSelection (for selection of contextual samples)
+# 	CtxSmp <- contextSelection()
+# 	if (length(CtxSmp) < 1) {
+# 		warning("No contextual samples selected! Initial training set will be used...")
+# 	} else {
+# 		## Call addItemsToTrain (for augmentation of the training set)
+# 		train <- addItemsToTrain(train = get(ZIT, envir = .GlobalEnv),
+# 			CtxSmp = CtxSmp, add.mode = "SV+NSV", threshold = NA,
+# 			dropItemsToTrain = dropItemsToTrain)
+# 	}
 	#.assignGlobal(ZIT, train)
 	classifier <- ZIClass(Class ~ ., data = train[!(names(train) %in% "AddedItems")], 
         method = "mlRforest", calc.vars = calcVars, ntree = 200, cv.k = 10)
@@ -1219,10 +1220,47 @@
     assignTemp("ZI.LastZIS", zisfile)
 }
 
-processSamples <- function()
+processSamplesWithCells <- function()
 {
+	## Ask for a "cells" file with data required to compute the number of cells
+	## per colonies (per particles)
+	cells <- getTemp("ZI.LastCells")
+	if (is.null(cells) || !file.exists(cells))
+		cells <- ""
+	## Ask for the cells file
+	if (cells != "") {	
+		cells <- dlgOpen(default = cells, title = "Select a cells counting RDS file",
+			filters = matrix(c("Cells counting RDS file", ".rds"),
+			ncol = 2, byrow = TRUE))$res	
+	} else if (file.exists(file.path(getwd(), "cells.rds"))) {
+		zisfile <- dlgOpen(default = file.path(getwd(), "cells.RData"),
+			title = "Select a cells counting RDS file",
+			filters = matrix(c("Cells counting file", ".rds"),
+			ncol = 2, byrow = TRUE))$res	
+	} else {
+		zisfile <- dlgOpen(title = "Select a cells counting RDS file",
+			filters = matrix(c("Cells counting file", ".rds"),
+			ncol = 2, byrow = TRUE))$res	
+	}
+	if (!length(cells)) return(invisible(NULL))
+	
+	## Remember last file used
+	assignTemp("ZI.LastCells", cells)
+		
+	## Call .processSamples() using this file...
+	.processSamples(cells)
+}
+
+## Just delegate to .processSamples() without providing a cells file to do
+## the computation without cells counting
+processSamples <- function ()
+	.processSamples()
+
+.processSamples <- function(cells = NULL)
+{
 	## Ask for a description.zis file, look at all samples described there
-	## Calculate abundances, total and partial size spectra and possibly biomasses
+	## Calculate abundances, total and partial size spectra and possibly number
+	## of cells per colonies (per particles) and biomasses
 	## Get the last edited description.zis file
 	## Get a possibly saved directory as default one
 	zisfile <- getTemp("ZI.LastZIS")

Modified: pkg/zooimage/TODO
===================================================================
--- pkg/zooimage/TODO	2015-10-01 08:16:26 UTC (rev 254)
+++ pkg/zooimage/TODO	2015-10-09 15:46:49 UTC (rev 255)
@@ -1,3 +1,5 @@
 = zooimage - TODO list
 
 * There is a calibrate() method in vegan => use a different name here
+
+* Check authors everywhere and adjust (in particular for Guillaume Wacquet)

Modified: pkg/zooimage/inst/gui/errorcorrection/server.R
===================================================================
--- pkg/zooimage/inst/gui/errorcorrection/server.R	2015-10-01 08:16:26 UTC (rev 254)
+++ pkg/zooimage/inst/gui/errorcorrection/server.R	2015-10-09 15:46:49 UTC (rev 255)
@@ -82,7 +82,7 @@
 #                 .ZI$Train <- addItemsToTrain(.ZI$Train, CtxSmp,
 #                     dropItemsToTrain = dropItemsToTrain)
 #             }
-            .ZI$Train <- activeLearning(.ZI$Train)
+            .ZITrain <- activeLearning(.ZITrain)
             assign(.ZIClass, eval(parse(text = .ZI$classifcmd)))
             if (file.exists(DemoFile)) { # Run in demo mode
                 res <- load(DemoFile)
@@ -173,7 +173,7 @@
             #assign(ResData, processSample(dat2, keep = NULL, detail = detail,
             #    biomass = .ZI$biovolume, breaks = .ZI$breaks, classes = "Class"))
             ## With cellModels...
-            assign(ResData, processSample(dat2, keep = NULL, detail = detail, cellModels = .ZI$cellModelsfile,
+            assign(ResData, processSample(dat2, keep = NULL, detail = detail, cells = .ZI$cellModelsfile,
                 biomass = .ZI$biovolume, breaks = .ZI$breaks, classes = "Class"))
             ## Save it
             save(list = ResData, file = ResFile)

Modified: pkg/zooimage/man/ZIRes.Rd
===================================================================
--- pkg/zooimage/man/ZIRes.Rd	2015-10-01 08:16:26 UTC (rev 254)
+++ pkg/zooimage/man/ZIRes.Rd	2015-10-09 15:46:49 UTC (rev 255)
@@ -11,10 +11,12 @@
   and they collect them together in a 'ZIRes' object.
 }
 \usage{
-processSample(x, sample, keep = NULL, detail = NULL, classes = "both",
-    header = c("Abd", "Bio"), biomass = NULL, breaks = NULL)
-processSampleAll(path = ".", zidbfiles, ZIClass = NULL, keep = NULL, detail = NULL,
-    classes = "both", header = c("Abd", "Bio"), biomass = NULL, breaks = NULL)
+processSample(x, sample, keep = NULL,
+    detail = NULL, classes = "both", header = c("Abd", "Bio"),
+    cells = NULL, biomass = NULL, breaks = NULL)
+processSampleAll(path = ".", zidbfiles, ZIClass = NULL, keep = NULL,
+    detail = NULL, classes = "both", header = c("Abd", "Bio"),
+    cells = NULL, biomass = NULL, breaks = NULL)
 
 \method{print}{ZIRes}(x, \dots)
 \method{rbind}{ZIRes}(\dots, deparse.level = 1)
@@ -38,6 +40,8 @@
     defined. One can also specify the name of another factor variable in \code{x}. }
   \item{header}{ a character vector with one or two strings to use as headers for,
     respectively, abundances and biomasses. }
+  \item{cells}{ the path to an .rds file containing cells counting models, as used
+    by \code{cellCompute()}. }
   \item{biomass}{ a specification for biomass conversion. Can be \code{NULL} (by
     default) for turning off biomass calculation, or a numeric vector of three
     values P1, P2 and P3 (same biomass for all classes with Bio = P1 * ECD^P3 + P2),

Modified: pkg/zooimage/man/gui.Rd
===================================================================
--- pkg/zooimage/man/gui.Rd	2015-10-01 08:16:26 UTC (rev 254)
+++ pkg/zooimage/man/gui.Rd	2015-10-09 15:46:49 UTC (rev 255)
@@ -26,6 +26,7 @@
 \alias{validClass}
 \alias{editDescription}
 \alias{processSamples}
+\alias{processSamplesWithCells}
 \alias{viewResults}
 \alias{exportResults}
 \alias{loadObjects}
@@ -70,6 +71,7 @@
 validClass()
 editDescription()
 processSamples()
+processSamplesWithCells()
 viewResults()
 exportResults
 loadObjects()

Modified: pkg/zooimage/man/zooimage.package.Rd
===================================================================
--- pkg/zooimage/man/zooimage.package.Rd	2015-10-01 08:16:26 UTC (rev 254)
+++ pkg/zooimage/man/zooimage.package.Rd	2015-10-09 15:46:49 UTC (rev 255)
@@ -16,8 +16,8 @@
   \tabular{ll}{
     Package: \tab zooimage\cr
     Type: \tab Package\cr
-    Version: \tab 5.4-2\cr
-    Date: \tab 2015-10-01\cr
+    Version: \tab 5.4-3\cr
+    Date: \tab 2015-10-09\cr
     License: \tab GPL 2 or above at your convenience.\cr
   }
 }



More information about the Zooimage-commits mailing list