[Zooimage-commits] r124 - pkg/zooimage/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon May 4 13:51:05 CEST 2009


Author: romain
Date: 2009-05-04 13:51:05 +0200 (Mon, 04 May 2009)
New Revision: 124

Modified:
   pkg/zooimage/R/ZIClass.r
   pkg/zooimage/R/gui.r
   pkg/zooimage/R/utilities.r
   pkg/zooimage/R/zid.r
   pkg/zooimage/R/zim.r
Log:
ixed minor proble?\195?\185ms

Modified: pkg/zooimage/R/ZIClass.r
===================================================================
--- pkg/zooimage/R/ZIClass.r	2009-04-27 14:16:57 UTC (rev 123)
+++ pkg/zooimage/R/ZIClass.r	2009-05-04 11:51:05 UTC (rev 124)
@@ -47,9 +47,9 @@
 	# algorithm
 	algorithm <- algorithm[1]
 	algo.fun  <- match.fun( algorithm )
-	ZI.class <- algo.fun(Formula, data = df, ...),
+	ZI.class <- algo.fun(Formula, data = df, ...)
 	ZI.class <- structure( ZI.class, 
-		class     = c("ZIClass", class(ZI.class))
+		class     = c("ZIClass", class(ZI.class)), 
 		algorithm = algorithm,
 		package   = package, 
 		calc.vars = CV, 

Modified: pkg/zooimage/R/gui.r
===================================================================
--- pkg/zooimage/R/gui.r	2009-04-27 14:16:57 UTC (rev 123)
+++ pkg/zooimage/R/gui.r	2009-05-04 11:51:05 UTC (rev 124)
@@ -290,11 +290,10 @@
 # }}}
 
 # {{{ Img
-"acquireImg" <-
-	function() {
-	# Show an assitant dialog box allowing to choose between VueScan and a different
-	# acquisition program... remember that setting in the registry under Windows
-
+#' Show an assitant dialog box allowing to choose between VueScan and a different
+#' acquisition program... remember that setting in the registry under Windows
+"acquireImg" <- function() {
+	
 	# First read the registry to determine which software in recorded there...
  	Asoft <- getKey("AcquisitionSoftware", "VueScan")
 	if (Asoft == "VueScan") {
@@ -352,33 +351,46 @@
 	# Get a list of 'ZIEimport' objects currently loaded in memory
 	
 	### TODO... Rework everything. What follows is old code!
-	ImgFilters <- as.matrix(data.frame(title = c("Tiff image files (*.tif)",
-		"Jpeg image files (*.jpg)", "Zooimage import extensions (Import_*.zie)", "Table and ImportTemplate.zie (*.txt)"), #, "FlowCAM zipped files (*.zfc)"),
+	ImgFilters <- as.matrix(data.frame(
+		title   = c(
+			"Tiff image files (*.tif)", 
+			"Jpeg image files (*.jpg)", 
+			"Zooimage import extensions (Import_*.zie)", 
+			"Table and ImportTemplate.zie (*.txt)"), #, "FlowCAM zipped files (*.zfc)"),
 		pattern = c("*.tif", "*.jpg", "Import_*.zie", "*.txt"))) #, "*.zfc")))
+	
 	# Get last image type that was selected
 	Index <- as.numeric(getKey("ImageIndex", "1"))
+	
 	# Get a list of images
     Images <- choose.files(caption = "Select data to import...",
 		multi = TRUE, filters = ImgFilters, index = Index)
+	
 	# Look if there is at least one image selected
-	if (length(Images) == 0) return(invisible())
+	if (length(Images) == 0) {
+		return(invisible())
+	}
     dir <- dirname(Images[1])
 	Images <- basename(Images)
+	
+	has <- function( extension, pattern = extensionPattern(extension) ){
+		grepl( pattern, Images[1])
+	}
+	
 	# Determine which kind of data it is
-    if (regexpr("[.][zZ][fF][cC]$", Images[1]) > 0) {
-        setKey("ImageIndex", "5")
+    if ( has( ".zfc" ) ){
+	    setKey("ImageIndex", "5")
 		return(importFlowCamFiles(path = dir, ZFCfiles = Images, check = FALSE, show.log = TRUE))
-	} else if (regexpr("^Import_.*[.]zie$", Images[1]) > 0) {
-		pattern <- "[.][zZ][iI][eE]$"
-        setKey("ImageIndex", "3")
-        return(make.zie(path = dir, Filemap = Images[1], check = TRUE, show.log = TRUE))
-    } else if (regexpr("[.][tT][xX][tT]$", Images[1]) > 0) {
-		pattern <- "[.][tT][xX][tT]$"
-        setKey("ImageIndex", "4")
-        logProcess("Creating .zie file...")
-        cat("Creating .zie file...\n")
-        ziefile <- compile.zie(path = dir, Tablefile = Images[1])
-        cat("...OK!\n")
+	} else if ( has( pattern = "^Import_.*[.]zie$") ) {
+		setKey("ImageIndex", "3")
+		return(make.zie(path = dir, Filemap = Images[1], check = TRUE, show.log = TRUE))
+    } else if ( has( "txt" ) ) {
+		pattern <- extensionPattern( ".txt" )
+		setKey("ImageIndex", "4")
+		logProcess("Creating .zie file...")
+		cat("Creating .zie file...\n")
+		ziefile <- compile.zie(path = dir, Tablefile = Images[1])
+		cat("...OK!\n")
 		res <- make.zie(path = dirname(ziefile), Filemap = basename(ziefile), check = TRUE, show.log = TRUE)
 		if (res) { # Everything is fine...
 			# Move the table and copy the template to the '_raw' subdirectory too
@@ -386,27 +398,30 @@
 			tplfile <- file.path(path, Images[1])
 			file.rename(tplfile, file.path(path, "_raw", basename(tplfile)))
 			# Move also possibly the .xls equivalent
-			xlsfile <- sub("\\.[tT][xX][tT]$", ".xls", tplfile)
-			if (xlsfile != tplfile && file.exists(xlsfile))
+			xlsfile <- sub( pattern, ".xls", tplfile)
+			if (xlsfile != tplfile && file.exists(xlsfile)){
 			    file.rename(xlsfile, file.path(path, "_raw", basename(xlsfile)))
+			}
 			file.rename(file.path(path, "ImportTemplate.zie"), file.path(path, "_raw", "ImportTemplate.zie"))
 		}
 		return(res)
-	} else if (regexpr("[.][tT][iI][fF]$", Images[1]) > 0) {
-		pattern <- "[.][tT][iI][fF]$"
+	} else if ( has( ".tif" ) ){
+		pattern <- extensionPattern (".tif" )
         setKey("ImageIndex", "1")
-	} else if (regexpr("[.][jJ][pP][gG]$", Images[1]) > 0) {
-        pattern <- "[.][jJ][pP][gG]$"
+	} else if ( has( "jpg") ) {
+        pattern <- extensionPatter( "jpg" )
         setKey("ImageIndex", "2")
 	} else stop("Unrecognized data type!")
+	
 	# If there is no special treatment, just make all required .zim files for currently selected images
 	make.zim(dir = dir, pattern = pattern, images = Images, show.log = TRUE)
 }
 
+# TODO: call the batch version of imagej zooimage plugins
 "processImg" <- function() {
 	# Display a dialog box telling how to process images using ImageJ
 	# When the user clicks on 'OK', ImageJ is started... + the checkbox 'close R'
-     res <- modalAssistant(paste(getTemp("ZIname"), "picture processing"),
+	res <- modalAssistant(paste(getTemp("ZIname"), "picture processing"),
 		c(paste("Once images are acquired and imported into", getTemp("ZIname")),
 		"(they have correct associated metadata), they must be",
 		"processed.",
@@ -421,8 +436,9 @@
 	# Analyze result
 	if (res == "ID_CANCEL") return(invisible())
  	# Start ImageJ
-	if (!is.null(getOption("ImageEditor")))
+	if (!is.null(getOption("ImageEditor"))){
 		startPgm("ImageEditor", switchdir = TRUE, iconize = TRUE)
+	}
 	# Do we have to close R?
 	if (res == "1") q()
 }
@@ -1060,5 +1076,19 @@
 }
 # }}}
 
+# {{{ ijplugin
+ijplugin <- function( zimfile, 
+	ij.plugin = c("Scanner_Gray16", "MacroPhoto_Gray16", "Scanner_Color", "Microscope_Color" ) ){
+	
+	cmd <- sprintf( 'java -Xmx900m -cp .:"%s":"%s" org.sciviews.zooimage.ZooImage %s "%s"', 
+		system.file( "imagej", "ij.jar", package = "zooimage" ), 
+		system.file( "imagej", "plugins", "_zooimage.jar", package = "zooimage" ), 
+		ij.plugin, 
+		zimfile )
+	# system( cmd, intern = TRUE )
+	cmd
+}
+# }}}
+
 # :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1:
 

Modified: pkg/zooimage/R/utilities.r
===================================================================
--- pkg/zooimage/R/utilities.r	2009-04-27 14:16:57 UTC (rev 123)
+++ pkg/zooimage/R/utilities.r	2009-05-04 11:51:05 UTC (rev 124)
@@ -405,7 +405,7 @@
 combine <- function( ..., .list = list(...) ){
 	force(.list)
 	mergefun <- function(x,y){
-		if(all( sort(names(x)) == sort(names(y)) ){
+		if( all( sort(names(x)) == sort(names(y) ) ) ) {
 			rbind( x,y )
 		} else{
 			merge( x, y, all = TRUE )

Modified: pkg/zooimage/R/zid.r
===================================================================
--- pkg/zooimage/R/zid.r	2009-04-27 14:16:57 UTC (rev 123)
+++ pkg/zooimage/R/zid.r	2009-05-04 11:51:05 UTC (rev 124)
@@ -174,7 +174,6 @@
 	
 	# Avoid collecting duplicate informations about fractions
 	fracdup <- duplicated(fractions)
-	
 	results <- lapply( seq.int( 1, length(dat1files) ), function(i){
 		
 		dat1path <- file.path(zidir, dat1files[i])

Modified: pkg/zooimage/R/zim.r
===================================================================
--- pkg/zooimage/R/zim.r	2009-04-27 14:16:57 UTC (rev 123)
+++ pkg/zooimage/R/zim.r	2009-05-04 11:51:05 UTC (rev 124)
@@ -282,7 +282,7 @@
 	# Note: use only the fraction, that is, SCS.xxxx-xx-xx.SS+F from SCS.xxxx-xx-xx.SS+Fnn)
 	# If there are duplicates, only extract first one
 	zimfiles <- sprintf( "%s.zim", 
-		get.sampleinfo(zipfiles, "fraction", ext = extensionPattern(".zip") )
+		get.sampleinfo(zipfiles, "fraction", ext = extensionPattern(".zip") ) )
 	keep <- !duplicated(zimfiles)
 	zimfiles <- zimfiles[keep]
 	zipfiles <- zipfiles[keep]



More information about the Zooimage-commits mailing list