EBImage / problem in running the code via Rscript
1
0
Entering edit mode
@kevinnagel-12650
Last seen 7.1 years ago

Hello,

 

I have tested the following lines of codes in an R interactive session (linux box) successfully

 

library(EBImage)

library(dplyr)

i = readImage("tmp.png")

r = as.vector(channel(i, 'red'))

g = as.vector(channel(i, 'green'))

b = as.vector(channel(i, 'blue'))

. = rgb2hsv(r, g, b) %>% t %>% as.data.frame %>% mutate(dgci=(((h-0.1666667)/0.1666667) + (1-s) + (1-v))/3)

 

But when I use the code in my test.R script I get an error with Rscript:

 

Rscript   test.R

Error in asub.default(x, i, 3) : could not find function "Quote"
Calls: channel -> selectChannel -> asub -> asub.default
Execution halted

 

 

The problem seems to be

 

channel(i, 'red')

 

Can someone explain, and give me an alternate solution to get this run?

 

Thanks

Kevin

 

 

ebimage image processing • 1.1k views
ADD COMMENT
0
Entering edit mode
@martin-morgan-1513
Last seen 5 days ago
United States

I think a work-around is to add 

library(methods)

to your script. What is the output of sessionInfo() ?

ADD COMMENT
0
Entering edit mode

Thanks Martin, I basically came to similar conclusions.

I was wondering what would be the best way of fixing this on our side. The problem seems to be related to the fact that methods package needs to be attached in order to manipulate S4 objects by abind, as running the following in Rscript also fails.

arraySubclass <- methods::setClass ("arraySubclass", contains = "array")
x <- methods::new("arraySubclass", array(0, c(3,3,3)))

abind::asub(x, 1, 3)

Error in eval(expr, envir, enclos) : could not find function "getGeneric"
Calls: <Anonymous> -> asub.default -> eval -> eval
Execution halted

Adding import("methods") to abind's NAMESPACE seems to fix the issue. Should this be communicated to the maintainer? I think the only other way of fixing this for EBImage would be to add Depends: methods to DESCRIPTION.

 

ADD REPLY
0
Entering edit mode

Yes it seems like an upstream issue and the abind maintainer should fix it, rather than trying to come up with work-arounds down-stream.

ADD REPLY

Login before adding your answer.

Traffic: 685 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6