We're Hiring!

setting physical pixel size

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

setting physical pixel size

Postby ebbwdan » Thu Aug 28, 2014 11:23 pm

Hello,

I'm probably missing this in the documentation but I was just wondering how I can set the physical pixel size when creating an image from scratch on the server. So, writing an image using 'createImageFromNumpySeq' when a parent image doesn't exist.

Many thanks!

Dan.
ebbwdan
 
Posts: 61
Joined: Wed Aug 29, 2012 4:46 am

Re: setting physical pixel size

Postby wmoore » Fri Aug 29, 2014 10:08 am

Hi Dan,

Here you go...
Code: Select all
from omero.rtypes import rdouble

conn = BlitzGateway('will', 'ome', host="localhost", port=4064)
conn.connect()

# createImage (details not shown)
i = conn.createImageFromNumpySeq (.....)

# reload the image (also reloads pixels)
image = conn.getObject("Image", i.getId())

# Get the BlitzGateway wrapped pixels and unwrap it
pixelsWrapper = image.getPrimaryPixels()
pixels = pixelsWrapper._obj

# Update and save
pixSize = rdouble(1.1)      # in microns

pixels.setPhysicalSizeX( pixSize )
pixels.setPhysicalSizeY( pixSize )

conn.getUpdateService().saveObject(pixels)
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Re: setting physical pixel size

Postby ebbwdan » Mon Sep 01, 2014 2:36 am

Hi Will,

Thanks! Don't know how I missed that.

Cheers,

Dan.
ebbwdan
 
Posts: 61
Joined: Wed Aug 29, 2012 4:46 am

Re: setting physical pixel size

Postby markmendell » Thu Apr 14, 2016 8:06 am

Heads up to anyone reading this now - the setPhysicalSize functions expect a "Length"-type argument instead of an "rdouble", so the line

Code: Select all
pixSize = rdouble(1.1)

should be replaced with

Code: Select all
pixSize = omero.model.LengthI(1.1, omero.model.enums.UnitsLength.MICROMETER)

Reference
markmendell
 
Posts: 2
Joined: Thu Apr 14, 2016 7:01 am

Re: setting physical pixel size

Postby wmoore » Fri Apr 15, 2016 11:03 am

Thanks for the heads up.

The docs on this also show the current usage of Units to set pixel size:
https://www.openmicroscopy.org/site/sup ... eate-image

Cheers,

Will.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm


Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 0 guests