cytoscape / py4cytoscape

Python library for calling Cytoscape Automation via CyREST
https://Py4Cytoscape.readthedocs.io
Other
69 stars 15 forks source link

add_image_annotation only works https #131

Open carissableker opened 5 months ago

carissableker commented 5 months ago

Hi,

I am trying to load a background annotation (image) to my network. Using

p4c.add_annotation_image(url="https://www.ucsd.edu/_resources/img/logo_UCSD.png", network)

works: the logo is loaded, I can also view it in the ImageManager, the output is as expected

{'edgeThickness': '1.0',
 'canvas': 'foreground',
 'rotation': '0.0',
 'type': 'org.cytoscape.view.presentation.annotations.ImageAnnotation',
 'uuid': '5105cc4c-9dcd-4121-bd22-4c7631652ed9',
 'URL': 'https://www.ucsd.edu/_resources/img/logo_UCSD.png',
 'shapeType': 'RECTANGLE',
 'edgeColor': '#000000',
 'brightness': '0',
 'edgeOpacity': '100.0',
 'contrast': '0',
 'name': 'Image 5',
 'x': '140.44609144134952',
 'width': '500.0',
 'y': '-87.37795634841291',
 'z': '1',
 'opacity': '1.0',
 'height': '100.0'}

using

p4c.add_annotation_image(url="http://www.ucsd.edu/_resources/img/logo_UCSD.png", network) or (after downloading the image) p4c.add_annotation_image(url="images/logo_UCSD.png", network) or p4c.add_annotation_image(url="file:images/logo_UCSD.png", network) or p4c.add_annotation_image(url="/absolute/path/images/logo_UCSD.png", network)

creates an empty rectangle in the network with the output:

{'edgeThickness': '1.0',
 'canvas': 'foreground',
 'rotation': '0.0',
 'type': 'org.cytoscape.view.presentation.annotations.ImageAnnotation',
 'uuid': '74c2b263-fcd4-4def-bf94-fdffad2b55fa',
 'shapeType': 'RECTANGLE',
 'edgeColor': '#000000',
 'brightness': '0',
 'edgeOpacity': '100.0',
 'contrast': '0',
 'name': 'Image 5',
 'x': '-28.22070147718013',
 'width': '100.0',
 'y': '-99.1472863452772',
 'z': '1',
 'opacity': '1.0',
 'height': '100.0'}

is missing the URL.

Using Cytoscape 3.10 or 3.10.2 with py4cytoscape 1.9.0 on Ubuntu.

Not sure if this is a local issue or not.

bdemchak commented 5 months ago

Hi, Carissa --

I tried this in the Cytoscape GUI ... and chose the background layer, which I assume you mean to do (??).

With a little work, I got Cytoscape to show a logo file (UCSD-Jacobs School) as a background annotation.

The URL I used was file:///C:/Users/bdemc/Desktop/UCSD-Jacobs.png ... note the "file:///" preceding the path.

Confession: I didn't use py4cytoscape to do this ... I directly edited the session file and reloaded the session. (If you'd like to know the exact mechanics, I can burden you.) Still, I'd expect the same result by using py4cytoscape.

What do you think??