omero/helpers.py
General helper functions for writing OMERO utilities.
force_image_wrapper(conn, img_or_rps)
Forces a RawPixelsStore or ImageWrapper to be an ImageWrapper object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img_or_rps | Object to be forced to ImageWrapper | required | |
conn | Connection object for the OMERO server | required |
Returns:
| Type | Description |
|---|---|
ImageWrapper | ImageWrapper object |
Source code in lavlab/omero/helpers.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |
force_rps(img_or_rps, bypass=True)
Forces an ImageWrapper or RawPixelsStore to be an RawPixelsStore object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img_or_rps | Union[BlitzObjectWrapper, ProxyObjectWrapper] | Object to be forced to RPS | required |
Returns:
| Type | Description |
|---|---|
RawPixelsStore | RawPixelsStore object |
bool | Whether or not a RawPixelsStore was created, useful for closing. |
Source code in lavlab/omero/helpers.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
get_closest_resolution_level(img, dim)
Finds the closest resolution to desired resolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img | ImageWrapper | Omero Image object from conn.getObjects() or initialized rps | required |
dim | tuple[int, int] | tuple containing desired x,y dimensions. | required |
Returns:
| Type | Description |
|---|---|
int | resolution level to be used in rps.setResolution() |
tuple[int, int, int, int] | height, width, tilesize_y, tilesize_x of closest resolution |
Source code in lavlab/omero/helpers.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
get_downsampled_xy_dimensions(img, downsample_factor)
Returns XY (rows,columns) dimensions of given image at the downsample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img | ImageWrapper | Omero Image object from conn.getObjects(). | required |
downsample_factor | int | Takes every nth pixel from the base resolution. | required |
Returns:
| Type | Description |
|---|---|
float | img.getSizeX() / downsample_factor |
float | img.getSizeY() / downsample_factor |
Source code in lavlab/omero/helpers.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
get_rps_xy(rps)
Gets the XY dimensions that the RPS is set for
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rps | ProxyObjectWrapper | OMERO RawPixelsStore. | required |
Returns:
| Type | Description |
|---|---|
tuple[int, int] | XY dimensions. |
Source code in lavlab/omero/helpers.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
ids_to_image_ids(conn, dtype, raw_ids)
Gathers Image ids from given OMERO objects. For Project and Dataset ids. Takes Image ids too for compatibility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn | BlitzGateway | An Omero BlitzGateway with a session. | required |
dtype | str | String data type, should be one of: 'Image','Dataset', or 'Project' | required |
raw_ids | list[int] | ids for datatype | required |
return | List of all found Image ids | required |
Source code in lavlab/omero/helpers.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
is_rps(rps)
checks if param is a RawPixelsStore, otherwise it's typically assumed you got a BlitzObject
:param rps: Potential Omero RawPixelsStore :type rps: omero.gateway.BlitzObjectWrapper :return: description :rtype: type
Source code in lavlab/omero/helpers.py
220 221 222 223 224 225 226 227 228 229 230 | |
match_group(obj)
Switch current context to that of the object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj | BlitzObjectWrapper | Any omero object. | required |
Returns:
| Type | Description |
|---|---|
int | The group ID. |
Source code in lavlab/omero/helpers.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
use_group(obj)
Uses the object's group and then switches back to the original group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj | BlitzObjectWrapper | Any OMERO object. | required |
Returns:
| Type | Description |
|---|---|
None | |
Source code in lavlab/omero/helpers.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |