Last active
January 23, 2020 14:29
-
-
Save will-moore/68cccecf9646571fa1d96a981eac0cce to your computer and use it in GitHub Desktop.
For testing images with different pixel sizes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from omero.model.enums import UnitsLength | |
import omero | |
from omero.rtypes import rstring | |
from omero.gateway import BlitzGateway | |
conn = BlitzGateway('user', 'password', port=4064, host='localhost') | |
conn.connect() | |
units = [ | |
UnitsLength.PICOMETER, | |
UnitsLength.ANGSTROM, | |
UnitsLength.NANOMETER, | |
UnitsLength.MICROMETER, | |
UnitsLength.MILLIMETER, | |
UnitsLength.CENTIMETER, | |
UnitsLength.METER, | |
UnitsLength.KILOMETER, | |
UnitsLength.MEGAMETER, | |
] | |
values = [1, 2, 5, 10, 100] | |
dataset_id = 9 | |
dataset = conn.getObject("Dataset", dataset_id) | |
for idx, i in enumerate(dataset.listChildren()): | |
value = values[idx % (len(values))] | |
unit = units[idx % len(units)] | |
print(idx, i.id, value, unit) | |
i = conn.getObject("Image", i.getId()) | |
i.setName("%s %s" % (value, unit)) | |
i.save() | |
u = omero.model.LengthI(value, unit) | |
p = i.getPrimaryPixels()._obj | |
p.setPhysicalSizeX(u) | |
p.setPhysicalSizeY(u) | |
conn.getUpdateService().saveObject(p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment