References
Convert source images to OME-TIFF or OME-Zarr, with RO-Crate metadata.
DbReader
DbReader
Reads and queries a SQLite database, returning results as dictionaries.
Source code in src/biomero_converter/DbReader.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
conn = sqlite3.connect(db_file)
instance-attribute
__init__(db_file)
Initialize DBReader with a database file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db_file
|
str
|
Path to the SQLite database file. |
required |
Source code in src/biomero_converter/DbReader.py
9 10 11 12 13 14 15 16 17 | |
close()
Closes the database connection.
Source code in src/biomero_converter/DbReader.py
60 61 62 63 64 | |
dict_factory(cursor, row)
staticmethod
Converts a database row to a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cursor
|
SQLite cursor object. |
required | |
row
|
Row data. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Mapping column names to values. |
Source code in src/biomero_converter/DbReader.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
fetch_all(query, params=[], return_dicts=True)
Executes a query and fetches all results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
SQL query string. |
required |
params
|
list
|
Query parameters. |
[]
|
return_dicts
|
bool
|
If True, returns list of dicts; else, returns first column values. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
Query results. |
Source code in src/biomero_converter/DbReader.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
list_tables()
Source code in src/biomero_converter/DbReader.py
57 58 | |
DicomSource
IMAGECODECS_DECODERS = {'1.2.840.10008.1.2.4.57': 'ljpeg_decode', '1.2.840.10008.1.2.4.70': 'ljpeg_decode', '1.2.840.10008.1.2.4.80': 'jpegls_decode', '1.2.840.10008.1.2.4.81': 'jpegls_decode', '1.2.840.10008.1.2.4.90': 'jpeg2k_decode', '1.2.840.10008.1.2.4.91': 'jpeg2k_decode'}
module-attribute
DicomSource
Bases: ImageSource
ImageSource subclass for reading DICOM files using pydicom.
A folder (or the folder of a DICOMDIR) can hold several series: each series is an image, selected by its SeriesInstanceUID (image_uuid), its files the slices in order of position.
Source code in src/biomero_converter/DicomSource.py
29 30 31 32 33 34 35 36 37 38 39 40 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 178 179 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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 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 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
dicom = dcmread(self.filenames[0])
instance-attribute
nseries = len(series)
instance-attribute
series_uid = image_uuid
instance-attribute
__init__(uri, metadata={}, image_uuid=None, **kwargs)
Initialize DicomSource.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
Path to a DICOM file, a folder of DICOM files or a DICOMDIR. |
required |
metadata
|
dict
|
Optional metadata dictionary. |
{}
|
image_uuid
|
str
|
SeriesInstanceUID of the series to read (default: the first). |
None
|
Source code in src/biomero_converter/DicomSource.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
get_acquisition_datetime()
Source code in src/biomero_converter/DicomSource.py
269 270 | |
get_acquisition_metadata()
Source code in src/biomero_converter/DicomSource.py
275 276 277 | |
get_acquisitions()
Source code in src/biomero_converter/DicomSource.py
300 301 | |
get_channels()
Source code in src/biomero_converter/DicomSource.py
249 250 251 252 253 254 255 | |
get_columns()
Source code in src/biomero_converter/DicomSource.py
291 292 | |
get_data(dim_order, level=0, well_id=None, field_id=None, **kwargs)
Source code in src/biomero_converter/DicomSource.py
303 304 305 306 307 308 309 310 311 312 313 | |
get_dim_order()
Source code in src/biomero_converter/DicomSource.py
246 247 | |
get_dtype()
Source code in src/biomero_converter/DicomSource.py
240 241 | |
get_fields()
Source code in src/biomero_converter/DicomSource.py
297 298 | |
get_name()
Source code in src/biomero_converter/DicomSource.py
231 232 | |
get_nchannels()
Source code in src/biomero_converter/DicomSource.py
257 258 | |
get_pixel_size_um()
Source code in src/biomero_converter/DicomSource.py
260 261 | |
get_position_um(well_id=None)
Source code in src/biomero_converter/DicomSource.py
263 264 265 266 267 | |
get_rows()
Source code in src/biomero_converter/DicomSource.py
288 289 | |
get_scales()
Source code in src/biomero_converter/DicomSource.py
243 244 | |
get_series(uri)
staticmethod
Find the series in a DICOM file, folder or DICOMDIR.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Per SeriesInstanceUID, its filenames in order of slice position. |
Source code in src/biomero_converter/DicomSource.py
63 64 65 66 67 68 69 70 71 | |
get_shape()
Source code in src/biomero_converter/DicomSource.py
234 235 | |
get_shapes()
Source code in src/biomero_converter/DicomSource.py
237 238 | |
get_significant_bits()
Source code in src/biomero_converter/DicomSource.py
272 273 | |
get_source_metadata()
Source code in src/biomero_converter/DicomSource.py
279 280 281 | |
get_time_points()
Source code in src/biomero_converter/DicomSource.py
283 284 285 286 | |
get_wells()
Source code in src/biomero_converter/DicomSource.py
294 295 | |
init_metadata()
Source code in src/biomero_converter/DicomSource.py
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 178 179 | |
is_rgb()
Source code in src/biomero_converter/DicomSource.py
228 229 | |
is_screen()
Source code in src/biomero_converter/DicomSource.py
224 225 226 | |
GenericSource
GenericSource
Bases: ImageSource
Source code in src/biomero_converter/GenericSource.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
data_func = im.read
instance-attribute
format = os.path.splitext(uri)[1].lower().lstrip('.')
instance-attribute
metadata = im.metadata()
instance-attribute
__init__(uri, **kwargs)
Source code in src/biomero_converter/GenericSource.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
get_data(**kwargs)
Source code in src/biomero_converter/GenericSource.py
36 37 | |
init_metadata()
Source code in src/biomero_converter/GenericSource.py
33 34 | |
ISyntaxSource
OME_DIR = 'OME'
module-attribute
OME_FILE = 'METADATA.ome.xml'
module-attribute
PYRAMID_DOWNSCALE = 2
module-attribute
PYRAMID_LEVELS = 6
module-attribute
RETRY_ATTEMPTS = 3
module-attribute
TIFF_COMPRESSION = 'LZW'
module-attribute
TILE_SIZE = 1024
module-attribute
VERSION = get_version()
module-attribute
ZARR_CHUNK_SIZE = TILE_SIZE
module-attribute
ZARR_SHARD_MULTIPLIER = 10
module-attribute
ISyntaxSource
Bases: ImageSource
Loads image and metadata from ISyntax format files.
Source code in src/biomero_converter/ISyntaxSource.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 178 179 180 181 182 183 184 185 186 | |
close()
Source code in src/biomero_converter/ISyntaxSource.py
184 185 186 | |
get_acquisition_datetime()
Source code in src/biomero_converter/ISyntaxSource.py
178 179 | |
get_acquisitions()
Source code in src/biomero_converter/ISyntaxSource.py
175 176 | |
get_channels()
Source code in src/biomero_converter/ISyntaxSource.py
145 146 147 148 149 150 151 152 | |
get_columns()
Source code in src/biomero_converter/ISyntaxSource.py
163 164 | |
get_data(dim_order, level=0, well_id=None, field_id=None, **kwargs)
Source code in src/biomero_converter/ISyntaxSource.py
96 97 98 | |
get_data_as_dask(dim_order, level=0, **kwargs)
Source code in src/biomero_converter/ISyntaxSource.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
get_data_as_generator(dim_order, **kwargs)
Source code in src/biomero_converter/ISyntaxSource.py
117 118 119 120 121 122 123 124 125 126 127 128 | |
get_dim_order()
Source code in src/biomero_converter/ISyntaxSource.py
133 134 | |
get_dtype()
Source code in src/biomero_converter/ISyntaxSource.py
139 140 | |
get_fields()
Source code in src/biomero_converter/ISyntaxSource.py
172 173 | |
get_name()
Source code in src/biomero_converter/ISyntaxSource.py
130 131 | |
get_nchannels()
Source code in src/biomero_converter/ISyntaxSource.py
154 155 | |
get_pixel_size_um()
Source code in src/biomero_converter/ISyntaxSource.py
136 137 | |
get_position_um(well_id=None)
Source code in src/biomero_converter/ISyntaxSource.py
142 143 | |
get_rows()
Source code in src/biomero_converter/ISyntaxSource.py
160 161 | |
get_scales()
Source code in src/biomero_converter/ISyntaxSource.py
87 88 | |
get_shape()
Source code in src/biomero_converter/ISyntaxSource.py
81 82 | |
get_shapes()
Source code in src/biomero_converter/ISyntaxSource.py
84 85 | |
get_significant_bits()
Source code in src/biomero_converter/ISyntaxSource.py
181 182 | |
get_time_points()
Source code in src/biomero_converter/ISyntaxSource.py
169 170 | |
get_wells()
Source code in src/biomero_converter/ISyntaxSource.py
166 167 | |
init_metadata()
Source code in src/biomero_converter/ISyntaxSource.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 69 70 71 72 73 74 75 76 | |
is_rgb()
Source code in src/biomero_converter/ISyntaxSource.py
157 158 | |
is_screen()
Source code in src/biomero_converter/ISyntaxSource.py
78 79 | |
read_array(x, y, width, height, level=0)
Source code in src/biomero_converter/ISyntaxSource.py
90 91 92 93 94 | |
get_version()
Get the version from the GitHub release tag.
Uses the BIOMERO_CONVERTER_VERSION environment variable if set (e.g. in the Docker image), otherwise the git tag of the source tree (e.g. 'v0.1.31', or 'v0.1.31-2-gabc1234' after the tag), otherwise the version of the installed package (taken from the tag when it was built).
Returns:
| Name | Type | Description |
|---|---|---|
str |
Version string, or 'unknown' if it cannot be determined. |
Source code in src/biomero_converter/version.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
ImageDbSource
ImageDbSource
Bases: ImageSource
Loads image and metadata from a database source for high-content screening.
Source code in src/biomero_converter/ImageDbSource.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 178 179 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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 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 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |
data = None
instance-attribute
data_level = None
instance-attribute
data_well_id = None
instance-attribute
db = DbReader(self.uri)
instance-attribute
dim_order = 'tczyx'
instance-attribute
__init__(uri, metadata={})
Source code in src/biomero_converter/ImageDbSource.py
17 18 19 20 21 22 23 | |
close()
Closes the database connection.
Source code in src/biomero_converter/ImageDbSource.py
384 385 386 387 388 | |
get_acquisition_datetime()
Source code in src/biomero_converter/ImageDbSource.py
352 353 | |
get_acquisition_metadata()
Source code in src/biomero_converter/ImageDbSource.py
381 382 | |
get_acquisitions()
Source code in src/biomero_converter/ImageDbSource.py
340 341 342 343 344 345 346 347 348 349 350 | |
get_channels()
Source code in src/biomero_converter/ImageDbSource.py
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |
get_columns()
Source code in src/biomero_converter/ImageDbSource.py
288 289 | |
get_data(dim_order, level=0, well_id=None, field_id=None, **kwargs)
Source code in src/biomero_converter/ImageDbSource.py
272 273 274 275 276 277 | |
get_dim_order()
Source code in src/biomero_converter/ImageDbSource.py
300 301 | |
get_dtype()
Source code in src/biomero_converter/ImageDbSource.py
303 304 | |
get_fields()
Source code in src/biomero_converter/ImageDbSource.py
297 298 | |
get_name()
Source code in src/biomero_converter/ImageDbSource.py
279 280 281 282 283 | |
get_nchannels()
Source code in src/biomero_converter/ImageDbSource.py
334 335 | |
get_pixel_size_um()
Source code in src/biomero_converter/ImageDbSource.py
306 307 | |
get_position_um(well_id=None, level=0)
Source code in src/biomero_converter/ImageDbSource.py
309 310 311 312 313 | |
get_rows()
Source code in src/biomero_converter/ImageDbSource.py
285 286 | |
get_scales()
Source code in src/biomero_converter/ImageDbSource.py
39 40 | |
get_shape()
Source code in src/biomero_converter/ImageDbSource.py
33 34 | |
get_shapes()
Source code in src/biomero_converter/ImageDbSource.py
36 37 | |
get_significant_bits()
Source code in src/biomero_converter/ImageDbSource.py
355 356 | |
get_time_points()
Source code in src/biomero_converter/ImageDbSource.py
294 295 | |
get_wells()
Source code in src/biomero_converter/ImageDbSource.py
291 292 | |
init_metadata()
Source code in src/biomero_converter/ImageDbSource.py
25 26 27 28 29 30 31 | |
is_rgb()
Source code in src/biomero_converter/ImageDbSource.py
337 338 | |
is_screen()
Source code in src/biomero_converter/ImageDbSource.py
269 270 | |
print_timepoint_well_matrix()
Source code in src/biomero_converter/ImageDbSource.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
camel_to_snake(name)
Source code in src/biomero_converter/util.py
303 304 305 | |
camel_to_snake_keys_dict(dct)
Source code in src/biomero_converter/util.py
295 296 297 298 299 300 | |
convert_dotnet_ticks_to_datetime(net_ticks)
Source code in src/biomero_converter/util.py
175 176 | |
convert_to_s(value, unit)
Source code in src/biomero_converter/util.py
319 320 321 322 323 324 | |
convert_to_um(value, unit)
Source code in src/biomero_converter/util.py
308 309 310 311 312 313 314 315 316 | |
dicom_to_dict(obj)
Source code in src/biomero_converter/util.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
ensure_list(item)
Source code in src/biomero_converter/util.py
11 12 13 14 | |
fix_bad_micro_value(value)
Source code in src/biomero_converter/util.py
365 366 367 368 | |
flatten_dict(dct, prefix='')
Source code in src/biomero_converter/util.py
281 282 283 284 285 286 287 288 289 290 291 292 | |
get_bits_type(nbits)
Source code in src/biomero_converter/util.py
77 78 79 80 81 82 83 84 85 86 | |
get_filetitle(filename)
Source code in src/biomero_converter/util.py
93 94 | |
get_level_from_scale(source_scales, target_scale=1)
Source code in src/biomero_converter/util.py
67 68 69 70 71 72 73 74 | |
get_numpy_data(data, dim_order, t, c, z, y, x, y_size, x_size)
Source code in src/biomero_converter/util.py
43 44 45 46 47 48 49 50 51 52 53 54 55 | |
get_pyramid_levels(shape, dim_order, max_levels, downscale, min_level_size=1)
Source code in src/biomero_converter/util.py
58 59 60 61 62 63 64 | |
get_rows_cols_plate(nwells)
Source code in src/biomero_converter/util.py
147 148 149 150 151 152 153 154 155 156 157 158 159 | |
pad_leading_zero(input_string, num_digits=2)
Source code in src/biomero_converter/util.py
129 130 131 132 133 134 135 136 137 138 139 | |
parse_datetime(value)
A datetime from an ISO 8601 or other common date text, or None if it is none.
Source code in src/biomero_converter/util.py
162 163 164 165 166 167 168 169 170 171 172 | |
print_dict(value, tab=0, max_len=250, bullet=False)
Source code in src/biomero_converter/util.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
print_hbytes(nbytes)
Source code in src/biomero_converter/util.py
351 352 353 354 355 356 357 358 359 360 361 362 | |
redimension_data(data, old_order, new_order, **indices)
Source code in src/biomero_converter/util.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
remove_key_prefix(obj, prefix)
Source code in src/biomero_converter/util.py
271 272 273 274 275 276 277 278 | |
split_well_name(well_name, remove_leading_zeros=True, col_as_int=False)
Source code in src/biomero_converter/util.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
splitall(path)
Source code in src/biomero_converter/util.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
strip_leading_zeros(well_name)
Source code in src/biomero_converter/util.py
142 143 144 | |
to_plain_types(obj)
Source code in src/biomero_converter/util.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
validate_filename(filename)
Source code in src/biomero_converter/util.py
89 90 | |
without_keys(value, keys)
Source code in src/biomero_converter/util.py
262 263 264 265 266 267 268 | |
xml_content_to_dict(element)
Source code in src/biomero_converter/util.py
179 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 213 214 215 216 217 218 219 | |
ImageSource
ImageSource
Bases: ABC
Abstract base class for image sources.
Source code in src/biomero_converter/ImageSource.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 178 179 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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 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 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | |
metadata = metadata
instance-attribute
uri = uri
instance-attribute
__init__(uri, metadata={})
Initialize ImageSource.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
Path to the image source. |
required |
metadata
|
dict
|
Optional metadata dictionary. |
{}
|
Source code in src/biomero_converter/ImageSource.py
13 14 15 16 17 18 19 20 21 22 | |
close()
Close the image source.
Source code in src/biomero_converter/ImageSource.py
342 343 344 345 346 | |
get_acquisition_datetime()
Get the acquisition datetime.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
251 252 253 254 255 256 257 258 | |
get_acquisition_end_datetime()
Get the datetime the acquisition ended, when its last image was collected.
Returns:
| Name | Type | Description |
|---|---|---|
datetime |
End datetime, or None if the metadata does not give it. |
Source code in src/biomero_converter/ImageSource.py
260 261 262 263 264 265 266 267 | |
get_acquisition_metadata()
Get microscope information. This can include details such as the microscope model, objective lens, and other relevant information.
Source code in src/biomero_converter/ImageSource.py
287 288 289 290 291 | |
get_acquisitions()
Get acquisition metadata.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
242 243 244 245 246 247 248 249 | |
get_channels()
Get channel metadata in NGFF format, color provided as RGBA list with values between 0 and 1 e.g. white = [1, 1, 1, 1]
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
172 173 174 175 176 177 178 179 180 | |
get_columns()
Get the list of column identifiers.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
206 207 208 209 210 211 212 213 | |
get_data(dim_order, level=0, well_id=None, field_id=None, **kwargs)
Get image data for a well and field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim_order
|
Dimension order of data |
required | |
level
|
int
|
Image resolution level |
0
|
well_id
|
str
|
Well identifier |
None
|
field_id
|
int
|
Field identifier |
None
|
kwargs
|
optional
|
Format specific keyword arguments. |
{}
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
get_data_as_dask(dim_order, level=0, **kwargs)
Get image data (WSI) as dask array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim_order
|
Dimension order of data |
required | |
level
|
int
|
Image resolution level |
0
|
kwargs
|
optional
|
Format specific keyword arguments. |
{}
|
Source code in src/biomero_converter/ImageSource.py
85 86 87 88 89 90 91 92 93 94 | |
get_data_as_generator(dim_order, **kwargs)
Get image data (WSI) as generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim_order
|
Dimension order of data |
required | |
kwargs
|
optional
|
Format specific keyword arguments. |
{}
|
Source code in src/biomero_converter/ImageSource.py
96 97 98 99 100 101 102 103 104 | |
get_dim_order()
Get the dimension order string.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
136 137 138 139 140 141 142 143 | |
get_dtype()
Get the numpy dtype of the image data.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
145 146 147 148 149 150 151 152 | |
get_fields()
Get the list of field indices.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
233 234 235 236 237 238 239 240 | |
get_image_window(window_scanner, well_id=None, field_id=None, data=None)
Get image value range window (for a well & field or from provided data).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window_scanner
|
WindowScanner
|
WindowScanner object to compute window. |
required |
well_id
|
str
|
Well identifier |
None
|
field_id
|
int
|
Field identifier |
None
|
data
|
ndarray
|
Image data to compute window from. |
None
|
Source code in src/biomero_converter/ImageSource.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
get_metadata()
Get the metadata dictionary.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Metadata dictionary. |
Source code in src/biomero_converter/ImageSource.py
278 279 280 281 282 283 284 285 | |
get_model_acquisition_datetime()
Get the acquisition datetime the model metadata gives (Image.AcquisitionDate), from the vendor metadata.
Returns:
| Name | Type | Description |
|---|---|---|
datetime |
Acquisition datetime, or None if the metadata does not give it. |
Source code in src/biomero_converter/ImageSource.py
314 315 316 317 318 319 320 321 322 323 324 | |
get_model_metadata()
Get the source metadata mapped onto the common imaging metadata model (https://github.com/NL-BioImaging/imaging-metadata-converter). Unmapped fields keep their original path.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Nested model metadata, e.g. {'Instrument': {'Manufacturer': ..., 'Model': ...}, ...}. |
Source code in src/biomero_converter/ImageSource.py
300 301 302 303 304 305 306 307 308 309 310 311 312 | |
get_name()
Get the name of the image source.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
127 128 129 130 131 132 133 134 | |
get_nchannels()
Get the number of channels.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
182 183 184 185 186 187 188 189 | |
get_pixel_size_um()
Get the pixel size in micrometers.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
154 155 156 157 158 159 160 161 | |
get_position_um(well_id=None)
Get the position in micrometers for a well.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
163 164 165 166 167 168 169 170 | |
get_rows()
Get the list of row identifiers.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
197 198 199 200 201 202 203 204 | |
get_scales()
Get the list of image scales.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
60 61 62 63 64 65 66 67 | |
get_shape()
Get the shape of the image data.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
42 43 44 45 46 47 48 49 | |
get_shapes()
Get a list of shapes corresponding to the image data levels.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
51 52 53 54 55 56 57 58 | |
get_significant_bits()
Get the number of significant bits in the image data.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
269 270 271 272 273 274 275 276 | |
get_source_metadata()
Get all of the source's metadata, but what only lays out or encodes the pixel data, for the imaging metadata converter: by default the acquisition metadata.
Source code in src/biomero_converter/ImageSource.py
293 294 295 296 297 298 | |
get_time_points()
Get the list of time points.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
224 225 226 227 228 229 230 231 | |
get_total_data_size()
Get the estimated total data size.
Returns:
| Name | Type | Description |
|---|---|---|
int |
Total data size in bytes. |
Source code in src/biomero_converter/ImageSource.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
get_wells()
Get the list of well identifiers.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
215 216 217 218 219 220 221 222 | |
init_metadata()
Initialize and load metadata.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
24 25 26 27 28 29 30 31 | |
is_rgb()
Check if the source is a RGB(A) image.
Source code in src/biomero_converter/ImageSource.py
191 192 193 194 195 | |
is_screen()
Check if the source is a screen (multi-well).
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Must be implemented by subclasses. |
Source code in src/biomero_converter/ImageSource.py
33 34 35 36 37 38 39 40 | |
print_well_matrix()
Print a matrix representation of the well plate.
Source code in src/biomero_converter/ImageSource.py
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | |
IncucyteSource
IncucyteSource
Bases: ImageSource
ImageSource implementation for Incucyte data
Handles the specific directory structure: EssenFiles/ScanData/YYMM/DD/HHMM/XXXX/*.tif
Filenames follow pattern: WELL-FIELD-CHANNEL.tif e.g., A1-1-C1.tif, B2-1-Ph.tif
Note: Multiple plates can exist in the same archive, identified by the XXXX folder. Use plate_id parameter to select a specific plate, or use get_available_plates() to discover all plates in the archive.
Source code in src/biomero_converter/IncucyteSource.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 178 179 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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 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 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 | |
DIAG_LOG_FILENAME = 'Diag.log'
class-attribute
instance-attribute
DIAG_ZIP_FILENAME = 'Diag.zip'
class-attribute
instance-attribute
base_path = Path(self.uri)
instance-attribute
fill_missing_images = True
instance-attribute
plate_id = plate_id
instance-attribute
scan_data_path = self.base_path / 'EssenFiles' / 'ScanData'
instance-attribute
__init__(uri, metadata={}, plate_id=None)
Initialize IncucyteSource.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
Path to the Incucyte archive folder |
required |
metadata
|
dict
|
Optional metadata dictionary |
{}
|
plate_id
|
str
|
Specific plate ID to process (e.g., '700', '701'). If None, will use the first available plate or all if only one exists. |
None
|
Source code in src/biomero_converter/IncucyteSource.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
close()
Clean up resources
Source code in src/biomero_converter/IncucyteSource.py
812 813 814 | |
enable_file_caching(file_caching=True)
Enable or disable file caching for image data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_caching
|
bool
|
If True, enable file caching; if False, disable it. |
True
|
Source code in src/biomero_converter/IncucyteSource.py
89 90 91 92 93 94 95 96 97 98 | |
get_acquisition_datetime()
Source code in src/biomero_converter/IncucyteSource.py
740 741 742 743 744 | |
get_acquisition_end_datetime()
Source code in src/biomero_converter/IncucyteSource.py
746 747 748 749 750 | |
get_acquisitions()
Return acquisition information based on timepoints
Source code in src/biomero_converter/IncucyteSource.py
722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 | |
get_available_plates(uri)
staticmethod
Discover all available plate IDs in an Incucyte archive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
Path to the Incucyte archive folder |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
List of plate IDs (strings) found in the archive |
Source code in src/biomero_converter/IncucyteSource.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
get_channels()
Source code in src/biomero_converter/IncucyteSource.py
697 698 | |
get_columns()
Source code in src/biomero_converter/IncucyteSource.py
706 707 | |
get_data(dim_order, level=0, well_id=None, field_id=None, **kwargs)
Get data for a specific well and field
Source code in src/biomero_converter/IncucyteSource.py
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 | |
get_dim_order()
Source code in src/biomero_converter/IncucyteSource.py
681 682 | |
get_dtype()
Source code in src/biomero_converter/IncucyteSource.py
684 685 | |
get_fields()
Source code in src/biomero_converter/IncucyteSource.py
715 716 | |
get_name()
Source code in src/biomero_converter/IncucyteSource.py
678 679 | |
get_nchannels()
Source code in src/biomero_converter/IncucyteSource.py
700 701 | |
get_pixel_size_um()
Source code in src/biomero_converter/IncucyteSource.py
687 688 | |
get_position_um(well_id=None)
Source code in src/biomero_converter/IncucyteSource.py
690 691 692 693 694 695 | |
get_rows()
Source code in src/biomero_converter/IncucyteSource.py
703 704 | |
get_scales()
Source code in src/biomero_converter/IncucyteSource.py
675 676 | |
get_shape()
Source code in src/biomero_converter/IncucyteSource.py
672 673 | |
get_significant_bits()
Source code in src/biomero_converter/IncucyteSource.py
752 753 | |
get_time_points()
Source code in src/biomero_converter/IncucyteSource.py
712 713 | |
get_total_data_size()
Source code in src/biomero_converter/IncucyteSource.py
755 756 | |
get_well_coords_um(well_id)
Get well coordinates (placeholder - Incucyte doesn't typically have stage coordinates)
Source code in src/biomero_converter/IncucyteSource.py
718 719 720 | |
get_wells()
Source code in src/biomero_converter/IncucyteSource.py
709 710 | |
init_metadata()
Initialize all metadata from Incucyte structure
Source code in src/biomero_converter/IncucyteSource.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
is_rgb()
Check if the source is a RGB(A) image. Incucyte data stores channels separately, not as RGB.
Source code in src/biomero_converter/IncucyteSource.py
805 806 807 808 809 810 | |
is_screen()
Source code in src/biomero_converter/IncucyteSource.py
636 637 | |
print_timepoint_well_matrix()
Print timepoint vs well matrix
Source code in src/biomero_converter/IncucyteSource.py
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 | |
print_well_matrix()
Print a visual representation of the plate layout
Source code in src/biomero_converter/IncucyteSource.py
758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 | |
LeicaSource
LAYOUT_KEYS = ('BytesInc', 'BitInc')
module-attribute
LUT_COLORS = {'red': [1, 0, 0, 1], 'green': [0, 1, 0, 1], 'blue': [0, 0, 1, 1], 'cyan': [0, 1, 1, 1], 'magenta': [1, 0, 1, 1], 'yellow': [1, 1, 0, 1], 'gray': [1, 1, 1, 1], 'grey': [1, 1, 1, 1]}
module-attribute
LeicaSource
Bases: ImageSource
Loads image and metadata from Leica LIF, LOF or XLEF files. A file can contain multiple images; a single image is selected by UUID or index (default: first image). Tile scans (mosaic) are stitched using the tile field positions; a tile scan with gaps between its tiles holds separate positions instead, one selected by position index.
Source code in src/biomero_converter/LeicaSource.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 178 179 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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 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 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | |
image = images[0]
instance-attribute
lif = LifFile(uri)
instance-attribute
position_index = int(position) if position is not None else None
instance-attribute
__init__(uri, metadata={}, image_uuid=None, image_index=None, position=None, **kwargs)
Initialize LeicaSource.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
Path to the Leica file. |
required |
metadata
|
dict
|
Optional metadata dictionary. |
{}
|
image_uuid
|
str
|
UUID of the image to read. |
None
|
image_index
|
int
|
Index of the image to read (e.g. for older files without UUIDs). |
None
|
position
|
int
|
Index of the position to read, for a tile scan with gaps between its tiles. |
None
|
Source code in src/biomero_converter/LeicaSource.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
close()
Source code in src/biomero_converter/LeicaSource.py
483 484 | |
get_acquisition_datetime()
Source code in src/biomero_converter/LeicaSource.py
471 472 | |
get_acquisition_end_datetime()
Source code in src/biomero_converter/LeicaSource.py
474 475 | |
get_acquisition_metadata()
Source code in src/biomero_converter/LeicaSource.py
480 481 | |
get_acquisitions()
Source code in src/biomero_converter/LeicaSource.py
468 469 | |
get_channels()
Source code in src/biomero_converter/LeicaSource.py
444 445 | |
get_columns()
Source code in src/biomero_converter/LeicaSource.py
456 457 | |
get_data(dim_order, level=0, well_id=None, field_id=None, **kwargs)
Source code in src/biomero_converter/LeicaSource.py
418 419 420 | |
get_data_as_dask(dim_order, level=0, **kwargs)
Source code in src/biomero_converter/LeicaSource.py
422 423 424 | |
get_dim_order()
Source code in src/biomero_converter/LeicaSource.py
429 430 | |
get_dtype()
Source code in src/biomero_converter/LeicaSource.py
432 433 | |
get_fields()
Source code in src/biomero_converter/LeicaSource.py
465 466 | |
get_image_count(uri)
staticmethod
Get the number of images in a Leica file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
Path to the Leica file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
Number of images. |
Source code in src/biomero_converter/LeicaSource.py
116 117 118 119 120 121 122 123 124 125 126 127 128 | |
get_name()
Source code in src/biomero_converter/LeicaSource.py
426 427 | |
get_nchannels()
Source code in src/biomero_converter/LeicaSource.py
447 448 | |
get_pixel_size_um()
Source code in src/biomero_converter/LeicaSource.py
435 436 437 438 439 | |
get_position_um(well_id=None)
Source code in src/biomero_converter/LeicaSource.py
441 442 | |
get_rows()
Source code in src/biomero_converter/LeicaSource.py
453 454 | |
get_scales()
Source code in src/biomero_converter/LeicaSource.py
415 416 | |
get_shape()
Source code in src/biomero_converter/LeicaSource.py
409 410 | |
get_shapes()
Source code in src/biomero_converter/LeicaSource.py
412 413 | |
get_significant_bits()
Source code in src/biomero_converter/LeicaSource.py
477 478 | |
get_source_metadata()
All of the image's metadata, for the imaging metadata converter, but its path on this disk and what only lays out the pixel data in the file (a channel's or dimension's byte and bit increments): its attachments whole (the hardware settings without their ATL prefix, LAS AF's records keyed by their names), the channel and dimension descriptions, and the time stamps of its frames.
Source code in src/biomero_converter/LeicaSource.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
get_time_points()
Source code in src/biomero_converter/LeicaSource.py
462 463 | |
get_wells()
Source code in src/biomero_converter/LeicaSource.py
459 460 | |
init_metadata()
Source code in src/biomero_converter/LeicaSource.py
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 178 179 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 213 214 215 216 217 218 219 | |
is_rgb()
Source code in src/biomero_converter/LeicaSource.py
450 451 | |
is_screen()
Source code in src/biomero_converter/LeicaSource.py
406 407 | |
key_setting_records(hardware_setting)
LAS AF's hardware settings with each record keyed by its own name, so a value has a path of its own.
LAS AF lists its settings as records, a scanner setting named by its Identifier (dblZoom) and a filter setting by its ObjectName and Attribute (DM6000 Turret, NumericalAperture), the value in Variant. Each record is kept whole under its name, without the fields that name it; the few attributes an object repeats (an AOBS's intensity per line, a spectrophotometer mirror's left and right wavelength) keep their records as a list, as written.
Source code in src/biomero_converter/LeicaSource.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
sequential_channel_names(xml_element, nchannels)
The channel names of a sequential confocal scan, or None where it is none.
Channel k is the k-th active detector, taken sequence by sequence, and its name the dye of that detector's spectral band. The bands are numbered by detector and stated once, not per sequence, so liffile, which names the channels after the bands in band order, misnames them wherever the sequences do not run in detector order (TileScan.lof: detectors 4, 5, 1).
Source code in src/biomero_converter/LeicaSource.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
MiraxSource
OME_DIR = 'OME'
module-attribute
OME_FILE = 'METADATA.ome.xml'
module-attribute
PYRAMID_DOWNSCALE = 2
module-attribute
PYRAMID_LEVELS = 6
module-attribute
RETRY_ATTEMPTS = 3
module-attribute
TIFF_COMPRESSION = 'LZW'
module-attribute
TILE_SIZE = 1024
module-attribute
VERSION = get_version()
module-attribute
ZARR_CHUNK_SIZE = TILE_SIZE
module-attribute
ZARR_SHARD_MULTIPLIER = 10
module-attribute
MiraxSource
Bases: ImageSource
ImageSource subclass for reading Mirax files using OpenSlide.
Source code in src/biomero_converter/MiraxSource.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 178 179 180 181 | |
slide = openslide.open_slide(uri)
instance-attribute
__init__(uri, metadata={})
Source code in src/biomero_converter/MiraxSource.py
21 22 23 | |
close()
Source code in src/biomero_converter/MiraxSource.py
180 181 | |
get_acquisition_datetime()
Source code in src/biomero_converter/MiraxSource.py
174 175 | |
get_acquisitions()
Source code in src/biomero_converter/MiraxSource.py
171 172 | |
get_channels()
Source code in src/biomero_converter/MiraxSource.py
141 142 143 144 145 146 147 148 | |
get_columns()
Source code in src/biomero_converter/MiraxSource.py
159 160 | |
get_data(dim_order, level=0, well_id=None, field_id=None, **kwargs)
Source code in src/biomero_converter/MiraxSource.py
91 92 93 | |
get_data_as_dask(dim_order, level=0, **kwargs)
Source code in src/biomero_converter/MiraxSource.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
get_data_as_generator(dim_order, **kwargs)
Source code in src/biomero_converter/MiraxSource.py
112 113 114 115 116 117 118 119 120 121 122 123 | |
get_dim_order()
Source code in src/biomero_converter/MiraxSource.py
128 129 | |
get_dtype()
Source code in src/biomero_converter/MiraxSource.py
131 132 | |
get_fields()
Source code in src/biomero_converter/MiraxSource.py
168 169 | |
get_name()
Source code in src/biomero_converter/MiraxSource.py
125 126 | |
get_nchannels()
Source code in src/biomero_converter/MiraxSource.py
150 151 | |
get_pixel_size_um()
Source code in src/biomero_converter/MiraxSource.py
134 135 | |
get_position_um(well_id=None)
Source code in src/biomero_converter/MiraxSource.py
137 138 139 | |
get_rows()
Source code in src/biomero_converter/MiraxSource.py
156 157 | |
get_scales()
Source code in src/biomero_converter/MiraxSource.py
75 76 | |
get_shape()
Source code in src/biomero_converter/MiraxSource.py
69 70 | |
get_shapes()
Source code in src/biomero_converter/MiraxSource.py
72 73 | |
get_significant_bits()
Source code in src/biomero_converter/MiraxSource.py
177 178 | |
get_time_points()
Source code in src/biomero_converter/MiraxSource.py
165 166 | |
get_wells()
Source code in src/biomero_converter/MiraxSource.py
162 163 | |
init_metadata()
Source code in src/biomero_converter/MiraxSource.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
is_rgb()
Source code in src/biomero_converter/MiraxSource.py
153 154 | |
is_screen()
Source code in src/biomero_converter/MiraxSource.py
65 66 67 | |
read_array(x, y, width, height, level=0)
Source code in src/biomero_converter/MiraxSource.py
81 82 83 84 85 86 87 88 89 | |
get_version()
Get the version from the GitHub release tag.
Uses the BIOMERO_CONVERTER_VERSION environment variable if set (e.g. in the Docker image), otherwise the git tag of the source tree (e.g. 'v0.1.31', or 'v0.1.31-2-gabc1234' after the tag), otherwise the version of the installed package (taken from the tag when it was built).
Returns:
| Name | Type | Description |
|---|---|---|
str |
Version string, or 'unknown' if it cannot be determined. |
Source code in src/biomero_converter/version.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
OmeTiffWriter
OME_DIR = 'OME'
module-attribute
OME_FILE = 'METADATA.ome.xml'
module-attribute
PYRAMID_DOWNSCALE = 2
module-attribute
PYRAMID_LEVELS = 6
module-attribute
RETRY_ATTEMPTS = 3
module-attribute
TIFF_COMPRESSION = 'LZW'
module-attribute
TILE_SIZE = 1024
module-attribute
VERSION = get_version()
module-attribute
ZARR_CHUNK_SIZE = TILE_SIZE
module-attribute
ZARR_SHARD_MULTIPLIER = 10
module-attribute
OmeTiffWriter
Bases: OmeWriter
Writes image data and metadata to OME-TIFF files.
Source code in src/biomero_converter/OmeTiffWriter.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 178 179 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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | |
verbose = verbose
instance-attribute
__init__(verbose=False)
Initialize OmeTiffWriter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
bool
|
If True, prints progress info. |
False
|
Source code in src/biomero_converter/OmeTiffWriter.py
19 20 21 22 23 24 25 26 27 | |
write(filepath, source, **kwargs)
Writes image or screen data to OME-TIFF files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str
|
Output file path. |
required |
source
|
ImageSource
|
Source object. |
required |
**kwargs
|
Additional options (e.g. wells selection). |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Containing output_path: str or list Output file path(s) and data window. |
Source code in src/biomero_converter/OmeTiffWriter.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
camel_to_snake(name)
Source code in src/biomero_converter/util.py
303 304 305 | |
camel_to_snake_keys_dict(dct)
Source code in src/biomero_converter/util.py
295 296 297 298 299 300 | |
convert_dotnet_ticks_to_datetime(net_ticks)
Source code in src/biomero_converter/util.py
175 176 | |
convert_to_s(value, unit)
Source code in src/biomero_converter/util.py
319 320 321 322 323 324 | |
convert_to_um(value, unit)
Source code in src/biomero_converter/util.py
308 309 310 311 312 313 314 315 316 | |
dicom_to_dict(obj)
Source code in src/biomero_converter/util.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
ensure_list(item)
Source code in src/biomero_converter/util.py
11 12 13 14 | |
fix_bad_micro_value(value)
Source code in src/biomero_converter/util.py
365 366 367 368 | |
flatten_dict(dct, prefix='')
Source code in src/biomero_converter/util.py
281 282 283 284 285 286 287 288 289 290 291 292 | |
get_bits_type(nbits)
Source code in src/biomero_converter/util.py
77 78 79 80 81 82 83 84 85 86 | |
get_filetitle(filename)
Source code in src/biomero_converter/util.py
93 94 | |
get_level_from_scale(source_scales, target_scale=1)
Source code in src/biomero_converter/util.py
67 68 69 70 71 72 73 74 | |
get_numpy_data(data, dim_order, t, c, z, y, x, y_size, x_size)
Source code in src/biomero_converter/util.py
43 44 45 46 47 48 49 50 51 52 53 54 55 | |
get_pyramid_levels(shape, dim_order, max_levels, downscale, min_level_size=1)
Source code in src/biomero_converter/util.py
58 59 60 61 62 63 64 | |
get_rows_cols_plate(nwells)
Source code in src/biomero_converter/util.py
147 148 149 150 151 152 153 154 155 156 157 158 159 | |
get_version()
Get the version from the GitHub release tag.
Uses the BIOMERO_CONVERTER_VERSION environment variable if set (e.g. in the Docker image), otherwise the git tag of the source tree (e.g. 'v0.1.31', or 'v0.1.31-2-gabc1234' after the tag), otherwise the version of the installed package (taken from the tag when it was built).
Returns:
| Name | Type | Description |
|---|---|---|
str |
Version string, or 'unknown' if it cannot be determined. |
Source code in src/biomero_converter/version.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
pad_leading_zero(input_string, num_digits=2)
Source code in src/biomero_converter/util.py
129 130 131 132 133 134 135 136 137 138 139 | |
parse_datetime(value)
A datetime from an ISO 8601 or other common date text, or None if it is none.
Source code in src/biomero_converter/util.py
162 163 164 165 166 167 168 169 170 171 172 | |
print_dict(value, tab=0, max_len=250, bullet=False)
Source code in src/biomero_converter/util.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
print_hbytes(nbytes)
Source code in src/biomero_converter/util.py
351 352 353 354 355 356 357 358 359 360 361 362 | |
redimension_data(data, old_order, new_order, **indices)
Source code in src/biomero_converter/util.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
remove_key_prefix(obj, prefix)
Source code in src/biomero_converter/util.py
271 272 273 274 275 276 277 278 | |
split_well_name(well_name, remove_leading_zeros=True, col_as_int=False)
Source code in src/biomero_converter/util.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
splitall(path)
Source code in src/biomero_converter/util.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
strip_leading_zeros(well_name)
Source code in src/biomero_converter/util.py
142 143 144 | |
to_plain_types(obj)
Source code in src/biomero_converter/util.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
validate_filename(filename)
Source code in src/biomero_converter/util.py
89 90 | |
without_keys(value, keys)
Source code in src/biomero_converter/util.py
262 263 264 265 266 267 268 | |
xml_content_to_dict(element)
Source code in src/biomero_converter/util.py
179 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 213 214 215 216 217 218 219 | |
OmeWriter
OmeWriter
Bases: ABC
Abstract base class for OME writers.
Source code in src/biomero_converter/OmeWriter.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
write(filepath, source, verbose=False, **kwargs)
Write image data and metadata to output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str
|
Output file path. |
required |
source
|
ImageSource
|
Source object. |
required |
verbose
|
bool
|
If True, prints progress info. |
False
|
**kwargs
|
Additional options. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
str
|
Containing output_path: str or list Output file path(s), and other optional output. |
Source code in src/biomero_converter/OmeWriter.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
OmeZarrSource
OME_DIR = 'OME'
module-attribute
OME_FILE = 'METADATA.ome.xml'
module-attribute
PYRAMID_DOWNSCALE = 2
module-attribute
PYRAMID_LEVELS = 6
module-attribute
RETRY_ATTEMPTS = 3
module-attribute
TIFF_COMPRESSION = 'LZW'
module-attribute
TILE_SIZE = 1024
module-attribute
VERSION = get_version()
module-attribute
ZARR_CHUNK_SIZE = TILE_SIZE
module-attribute
ZARR_SHARD_MULTIPLIER = 10
module-attribute
OmeZarrSource
Bases: ImageSource
Source code in src/biomero_converter/OmeZarrSource.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 178 179 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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
get_acquisition_datetime()
Source code in src/biomero_converter/OmeZarrSource.py
236 237 | |
get_acquisition_metadata()
Source code in src/biomero_converter/OmeZarrSource.py
242 243 | |
get_acquisitions()
Source code in src/biomero_converter/OmeZarrSource.py
233 234 | |
get_channels()
Source code in src/biomero_converter/OmeZarrSource.py
207 208 | |
get_columns()
Source code in src/biomero_converter/OmeZarrSource.py
220 221 | |
get_data(dim_order, level=0, well_id=None, field_id=None, **kwargs)
Source code in src/biomero_converter/OmeZarrSource.py
143 144 145 146 147 148 149 | |
get_data_as_generator(dim_order, **kwargs)
Source code in src/biomero_converter/OmeZarrSource.py
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 | |
get_dim_order()
Source code in src/biomero_converter/OmeZarrSource.py
188 189 | |
get_dtype()
Source code in src/biomero_converter/OmeZarrSource.py
191 192 | |
get_fields()
Source code in src/biomero_converter/OmeZarrSource.py
230 231 | |
get_image_window(window_scanner, well_id=None, field_id=None, data=None)
Source code in src/biomero_converter/OmeZarrSource.py
177 178 179 180 181 182 183 | |
get_name()
Source code in src/biomero_converter/OmeZarrSource.py
185 186 | |
get_nchannels()
Source code in src/biomero_converter/OmeZarrSource.py
210 211 | |
get_pixel_size_um()
Source code in src/biomero_converter/OmeZarrSource.py
194 195 | |
get_position_um(well_id=None)
Source code in src/biomero_converter/OmeZarrSource.py
197 198 199 200 201 202 203 204 205 | |
get_rows()
Source code in src/biomero_converter/OmeZarrSource.py
217 218 | |
get_scales()
Source code in src/biomero_converter/OmeZarrSource.py
140 141 | |
get_shape()
Source code in src/biomero_converter/OmeZarrSource.py
134 135 | |
get_shapes()
Source code in src/biomero_converter/OmeZarrSource.py
137 138 | |
get_significant_bits()
Source code in src/biomero_converter/OmeZarrSource.py
239 240 | |
get_time_points()
Source code in src/biomero_converter/OmeZarrSource.py
226 227 228 | |
get_wells()
Source code in src/biomero_converter/OmeZarrSource.py
223 224 | |
init_metadata()
Source code in src/biomero_converter/OmeZarrSource.py
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
is_rgb()
Source code in src/biomero_converter/OmeZarrSource.py
213 214 215 | |
is_screen()
Source code in src/biomero_converter/OmeZarrSource.py
131 132 | |
convert_multiscales_from_v06(multiscales)
Convert OME-Zarr 0.6 (RFC-5) multiscales metadata to the 0.4/0.5 layout (axes and a list of scale / translation transformations per dataset), so it can be read like earlier versions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
multiscales
|
list
|
Multiscales metadata. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
Multiscales metadata in the 0.5 layout. |
Source code in src/biomero_converter/ome_zarr_util.py
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 | |
convert_multiscales_to_v06(multiscales, coordinate_system='physical')
Convert OME-Zarr 0.4/0.5 multiscales metadata to the 0.6 (RFC-5) layout.
The axes move into a named coordinate system, and the transformations of each dataset become a single transformation (or a sequence of scale and translation) from the dataset path to that coordinate system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
multiscales
|
list
|
Multiscales metadata. |
required |
coordinate_system
|
str
|
Name of the (physical) coordinate system. |
'physical'
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
Multiscales metadata in the 0.6 layout. |
Source code in src/biomero_converter/ome_zarr_util.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
create_axes_metadata(dimension_order)
Create axes metadata for OME-Zarr from dimension order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimension_order
|
str
|
String of dimension characters. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
List of axis metadata dictionaries. |
Source code in src/biomero_converter/ome_zarr_util.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
create_channel_metadata(dtype, channels, nchannels, is_rgb, window, ome_version)
Create channel metadata for OME-Zarr.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype
|
Numpy dtype of image data. |
required | |
channels
|
list
|
List of channel dicts. |
required |
nchannels
|
int
|
Number of channels. |
required |
window
|
tuple
|
Min/max window values. |
required |
ome_version
|
str
|
OME-Zarr version. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Channel metadata dictionary. |
Source code in src/biomero_converter/ome_zarr_util.py
174 175 176 177 178 179 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 213 214 215 216 217 218 219 220 221 222 | |
create_transformation_metadata(dimension_order, pixel_size_um, factor, translation_um=None)
Create transformation metadata (scale and translation) for OME-Zarr.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimension_order
|
str
|
String of dimension characters. |
required |
pixel_size_um
|
dict
|
Pixel size in micrometers per dimension. |
required |
factor
|
float
|
Scaling factor. |
required |
translation_um
|
dict
|
Translation in micrometers per dimension. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
List of transformation metadata dictionaries. |
Source code in src/biomero_converter/ome_zarr_util.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
get_version()
Get the version from the GitHub release tag.
Uses the BIOMERO_CONVERTER_VERSION environment variable if set (e.g. in the Docker image), otherwise the git tag of the source tree (e.g. 'v0.1.31', or 'v0.1.31-2-gabc1234' after the tag), otherwise the version of the installed package (taken from the tag when it was built).
Returns:
| Name | Type | Description |
|---|---|---|
str |
Version string, or 'unknown' if it cannot be determined. |
Source code in src/biomero_converter/version.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
patch_zarr_windows_network_move()
Work around zarr LocalStore failing on Windows network shares (see issue #10).
On Windows zarr uses os.rename for exclusive writes (set_if_not_exists) and relies on FileExistsError when the destination exists. Some network shares (SMB) report this as PermissionError [WinError 5] instead, which zarr does not handle.
Source code in src/biomero_converter/ome_zarr_util.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
rgba_to_hexrgb(rgba)
Source code in src/biomero_converter/color_conversion.py
16 17 18 | |
scale_dimensions_dict(shape0, scale)
Scale x and y dimensions in a shape dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape0
|
dict
|
Original shape dictionary. |
required |
scale
|
float
|
Scaling factor. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Scaled shape dictionary. |
Source code in src/biomero_converter/ome_zarr_util.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
scale_dimensions_xy(shape0, dimension_order, scale)
Scale x and y dimensions in a shape tuple.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape0
|
tuple
|
Original shape. |
required |
dimension_order
|
str
|
String of dimension characters. |
required |
scale
|
float
|
Scaling factor. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
Scaled shape. |
Source code in src/biomero_converter/ome_zarr_util.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
OmeZarrWriter
OME_DIR = 'OME'
module-attribute
OME_FILE = 'METADATA.ome.xml'
module-attribute
PYRAMID_DOWNSCALE = 2
module-attribute
PYRAMID_LEVELS = 6
module-attribute
RETRY_ATTEMPTS = 3
module-attribute
TIFF_COMPRESSION = 'LZW'
module-attribute
TILE_SIZE = 1024
module-attribute
VERSION = get_version()
module-attribute
ZARR_CHUNK_SIZE = TILE_SIZE
module-attribute
ZARR_SHARD_MULTIPLIER = 10
module-attribute
OmeZarrWriter
Bases: OmeWriter
Writer for exporting image or screen data to OME-Zarr format. Supports both single images and high-content screening (HCS) plates.
Source code in src/biomero_converter/OmeZarrWriter.py
32 33 34 35 36 37 38 39 40 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 178 179 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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 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 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | |
dim_order = 'tczyx'
instance-attribute
ome_format = FormatV04()
instance-attribute
ome_version = ome_version
instance-attribute
verbose = verbose
instance-attribute
zarr_format = 2
instance-attribute
__init__(ome_version='0.4', verbose=False)
Initialize the OmeZarrWriter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ome_version
|
str
|
OME-Zarr metadata version ('0.4', '0.5' or '0.6'). |
'0.4'
|
verbose
|
bool
|
If True, print additional information. |
False
|
Source code in src/biomero_converter/OmeZarrWriter.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
write(filepath, source, write_xml=True, write_rocrate=True, **kwargs)
Write the provided source data to an OME-Zarr file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str
|
Output path for the Zarr file. |
required |
source
|
source reader supporting required interface. |
required | |
**kwargs
|
Additional arguments (e.g. wells selection). |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Containing output_path: str Output file path. |
Source code in src/biomero_converter/OmeZarrWriter.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
convert_multiscales_from_v06(multiscales)
Convert OME-Zarr 0.6 (RFC-5) multiscales metadata to the 0.4/0.5 layout (axes and a list of scale / translation transformations per dataset), so it can be read like earlier versions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
multiscales
|
list
|
Multiscales metadata. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
Multiscales metadata in the 0.5 layout. |
Source code in src/biomero_converter/ome_zarr_util.py
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 | |
convert_multiscales_to_v06(multiscales, coordinate_system='physical')
Convert OME-Zarr 0.4/0.5 multiscales metadata to the 0.6 (RFC-5) layout.
The axes move into a named coordinate system, and the transformations of each dataset become a single transformation (or a sequence of scale and translation) from the dataset path to that coordinate system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
multiscales
|
list
|
Multiscales metadata. |
required |
coordinate_system
|
str
|
Name of the (physical) coordinate system. |
'physical'
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
Multiscales metadata in the 0.6 layout. |
Source code in src/biomero_converter/ome_zarr_util.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
create_axes_metadata(dimension_order)
Create axes metadata for OME-Zarr from dimension order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimension_order
|
str
|
String of dimension characters. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
List of axis metadata dictionaries. |
Source code in src/biomero_converter/ome_zarr_util.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
create_channel_metadata(dtype, channels, nchannels, is_rgb, window, ome_version)
Create channel metadata for OME-Zarr.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype
|
Numpy dtype of image data. |
required | |
channels
|
list
|
List of channel dicts. |
required |
nchannels
|
int
|
Number of channels. |
required |
window
|
tuple
|
Min/max window values. |
required |
ome_version
|
str
|
OME-Zarr version. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Channel metadata dictionary. |
Source code in src/biomero_converter/ome_zarr_util.py
174 175 176 177 178 179 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 213 214 215 216 217 218 219 220 221 222 | |
create_transformation_metadata(dimension_order, pixel_size_um, factor, translation_um=None)
Create transformation metadata (scale and translation) for OME-Zarr.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimension_order
|
str
|
String of dimension characters. |
required |
pixel_size_um
|
dict
|
Pixel size in micrometers per dimension. |
required |
factor
|
float
|
Scaling factor. |
required |
translation_um
|
dict
|
Translation in micrometers per dimension. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
List of transformation metadata dictionaries. |
Source code in src/biomero_converter/ome_zarr_util.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
get_version()
Get the version from the GitHub release tag.
Uses the BIOMERO_CONVERTER_VERSION environment variable if set (e.g. in the Docker image), otherwise the git tag of the source tree (e.g. 'v0.1.31', or 'v0.1.31-2-gabc1234' after the tag), otherwise the version of the installed package (taken from the tag when it was built).
Returns:
| Name | Type | Description |
|---|---|---|
str |
Version string, or 'unknown' if it cannot be determined. |
Source code in src/biomero_converter/version.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
patch_zarr_windows_network_move()
Work around zarr LocalStore failing on Windows network shares (see issue #10).
On Windows zarr uses os.rename for exclusive writes (set_if_not_exists) and relies on FileExistsError when the destination exists. Some network shares (SMB) report this as PermissionError [WinError 5] instead, which zarr does not handle.
Source code in src/biomero_converter/ome_zarr_util.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
rgba_to_hexrgb(rgba)
Source code in src/biomero_converter/color_conversion.py
16 17 18 | |
scale_dimensions_dict(shape0, scale)
Scale x and y dimensions in a shape dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape0
|
dict
|
Original shape dictionary. |
required |
scale
|
float
|
Scaling factor. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Scaled shape dictionary. |
Source code in src/biomero_converter/ome_zarr_util.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
scale_dimensions_xy(shape0, dimension_order, scale)
Scale x and y dimensions in a shape tuple.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape0
|
tuple
|
Original shape. |
required |
dimension_order
|
str
|
String of dimension characters. |
required |
scale
|
float
|
Scaling factor. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
Scaled shape. |
Source code in src/biomero_converter/ome_zarr_util.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
TiffSource
OME_LAYOUT_KEYS = ('TiffData', 'BinData', 'BigEndian', 'Interleaved')
module-attribute
TIFF_LAYOUT_TAGS = {'NewSubfileType', 'SubfileType', 'Compression', 'Predictor', 'PlanarConfiguration', 'FillOrder', 'StripOffsets', 'StripByteCounts', 'RowsPerStrip', 'TileWidth', 'TileLength', 'TileDepth', 'TileOffsets', 'TileByteCounts', 'SubIFDs', 'JPEGTables', 'JPEGProc', 'JPEGInterchangeFormat', 'JPEGInterchangeFormatLength', 'JPEGRestartInterval', 'JPEGLosslessPredictors', 'JPEGPointTransforms', 'JPEGQTables', 'JPEGDCTables', 'JPEGACTables', 'YCbCrCoefficients', 'YCbCrSubSampling', 'YCbCrPositioning', 'ReferenceBlackWhite', 'ExtraSamples', 'ColorMap'}
module-attribute
TiffSource
Bases: ImageSource
Loads image and metadata from TIFF or OME-TIFF files.
Source code in src/biomero_converter/TiffSource.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 178 179 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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
image_filenames = {}
instance-attribute
is_ome = False
instance-attribute
metadata = metadata_to_dict(file.read().decode())
instance-attribute
tiff = TiffFile(image_filename)
instance-attribute
__init__(uri, metadata={})
Initialize TiffSource.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
Path to the TIFF file. |
required |
metadata
|
dict
|
Optional metadata dictionary. |
{}
|
Source code in src/biomero_converter/TiffSource.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
close()
Source code in src/biomero_converter/TiffSource.py
247 248 | |
get_acquisition_datetime()
Source code in src/biomero_converter/TiffSource.py
229 230 231 232 233 | |
get_acquisition_end_datetime()
Source code in src/biomero_converter/TiffSource.py
235 236 | |
get_acquisition_metadata()
Source code in src/biomero_converter/TiffSource.py
241 242 | |
get_acquisitions()
Source code in src/biomero_converter/TiffSource.py
226 227 | |
get_channels()
Source code in src/biomero_converter/TiffSource.py
198 199 | |
get_columns()
Source code in src/biomero_converter/TiffSource.py
210 211 | |
get_data(dim_order, level=0, well_id=None, field_id=None, **kwargs)
Source code in src/biomero_converter/TiffSource.py
163 164 165 166 167 168 169 170 | |
get_data_as_dask(dim_order, level=0, **kwargs)
Source code in src/biomero_converter/TiffSource.py
172 173 174 175 176 177 178 | |
get_dim_order()
Source code in src/biomero_converter/TiffSource.py
183 184 | |
get_dtype()
Source code in src/biomero_converter/TiffSource.py
186 187 | |
get_fields()
Source code in src/biomero_converter/TiffSource.py
223 224 | |
get_name()
Source code in src/biomero_converter/TiffSource.py
180 181 | |
get_nchannels()
Source code in src/biomero_converter/TiffSource.py
201 202 | |
get_pixel_size_um()
Source code in src/biomero_converter/TiffSource.py
189 190 191 192 193 | |
get_position_um(well_id=None)
Source code in src/biomero_converter/TiffSource.py
195 196 | |
get_rows()
Source code in src/biomero_converter/TiffSource.py
207 208 | |
get_scales()
Source code in src/biomero_converter/TiffSource.py
160 161 | |
get_shape()
Source code in src/biomero_converter/TiffSource.py
154 155 | |
get_shapes()
Source code in src/biomero_converter/TiffSource.py
157 158 | |
get_significant_bits()
Source code in src/biomero_converter/TiffSource.py
238 239 | |
get_source_metadata()
Source code in src/biomero_converter/TiffSource.py
244 245 | |
get_time_points()
Source code in src/biomero_converter/TiffSource.py
216 217 218 219 220 221 | |
get_wells()
Source code in src/biomero_converter/TiffSource.py
213 214 | |
init_metadata()
Source code in src/biomero_converter/TiffSource.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 | |
is_rgb()
Source code in src/biomero_converter/TiffSource.py
204 205 | |
is_screen()
Source code in src/biomero_converter/TiffSource.py
151 152 | |
get_fiji_pixelsize(metadata)
Source code in src/biomero_converter/TiffSource.py
251 252 253 254 255 256 257 258 259 260 261 | |
parse_tiff_datetime(value)
Parses a TIFF DateTime tag value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
'YYYY:MM:DD HH:MM:SS' as the TIFF spec defines, or another format some writers use. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
datetime |
Parsed datetime. |
Source code in src/biomero_converter/TiffSource.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
plain_tag_value(value)
A tag's value as plain data: an enumeration by its name, text read as text.
Source code in src/biomero_converter/TiffSource.py
277 278 279 280 281 282 283 | |
tags_to_dict(tags)
Converts TIFF tags to a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tags
|
TIFF tags object. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Tag name-value mapping. |
Source code in src/biomero_converter/TiffSource.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
Timer
Timer
Bases: object
Context manager for timing code execution and logging the elapsed time.
Source code in src/biomero_converter/Timer.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
auto_unit = auto_unit
instance-attribute
title = title
instance-attribute
verbose = verbose
instance-attribute
__enter__()
Start timing.
Source code in src/biomero_converter/Timer.py
25 26 27 28 29 30 | |
__exit__(type, value, traceback)
Stop timing and log the elapsed time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
Exception type, if any. |
required | |
value
|
Exception value, if any. |
required | |
traceback
|
Exception traceback, if any. |
required |
Source code in src/biomero_converter/Timer.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
__init__(title, auto_unit=True, verbose=True)
Initialize the Timer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Description for the timed block. |
required |
auto_unit
|
bool
|
Automatically select time unit (seconds/minutes/hours). |
True
|
verbose
|
bool
|
If True, log the elapsed time. |
True
|
Source code in src/biomero_converter/Timer.py
12 13 14 15 16 17 18 19 20 21 22 23 | |
TreeBuilder
TreeBuilder
Source code in src/biomero_converter/TreeBuilder.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
root = data
instance-attribute
__init__(data)
Source code in src/biomero_converter/TreeBuilder.py
2 3 4 | |
find_id(id_value)
Source code in src/biomero_converter/TreeBuilder.py
9 10 | |
index_ids()
Source code in src/biomero_converter/TreeBuilder.py
6 7 | |
recreate_tree(data=None)
Source code in src/biomero_converter/TreeBuilder.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
WindowScanner
WindowScanner
Computes quantile-based min/max window for image channels.
Source code in src/biomero_converter/WindowScanner.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
maxs = []
instance-attribute
mins = []
instance-attribute
__init__()
Initialize WindowScanner.
Source code in src/biomero_converter/WindowScanner.py
11 12 13 14 15 16 | |
get_window()
Returns the computed min/max window for channels.
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
(min dict, max dict) |
Source code in src/biomero_converter/WindowScanner.py
43 44 45 46 47 48 49 50 | |
process(data, dim_order, min_quantile=0.01, max_quantile=0.99)
Processes image data to compute min/max quantiles for each channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
Image data. |
required |
dim_order
|
str
|
Dimension order string. |
required |
min_quantile
|
float
|
Lower quantile. |
0.01
|
max_quantile
|
float
|
Upper quantile. |
0.99
|
Source code in src/biomero_converter/WindowScanner.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
color_conversion
hexrgb_to_rgba(hexrgb)
Source code in src/biomero_converter/color_conversion.py
21 22 23 24 25 26 | |
int_to_rgba(intrgba)
Source code in src/biomero_converter/color_conversion.py
3 4 5 6 7 8 | |
rgba_to_hexrgb(rgba)
Source code in src/biomero_converter/color_conversion.py
16 17 18 | |
rgba_to_int(rgba)
Source code in src/biomero_converter/color_conversion.py
11 12 13 | |
converter
convert(input_filename, output_folder, alt_output_folder=None, output_format=None, show_progress=False, verbose=False, max_attempts=RETRY_ATTEMPTS, **kwargs)
Source code in src/biomero_converter/converter.py
33 34 35 36 37 38 39 40 41 42 43 44 45 | |
init_logging(log_filename, verbose=False)
Initialize logging to file and optionally to console.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_filename
|
str
|
Path to the log file. |
required |
verbose
|
bool
|
If True, also log to console. |
False
|
Source code in src/biomero_converter/converter.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
helper
LEICA_EXTENSIONS = ['.lif', '.lof', '.lifext', '.xlif', '.xlcf', '.xlef']
module-attribute
create_incucyte_source(filename, plate_id=None)
Create an IncucyteSource object for a specific plate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the Incucyte archive folder or .icarch file. |
required |
plate_id
|
str
|
Specific plate ID to process. If None, uses the first available plate if multiple plates exist. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
IncucyteSource |
Source object for the specified plate. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the path is not a valid Incucyte archive. |
Source code in src/biomero_converter/helper.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
create_source(filename, **kwargs)
Create an image source object based on the input file extension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the input file or Incucyte .icarch file. |
required |
**kwargs
|
Source-specific parameters (e.g., plate_id for Incucyte). |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
ImageSource |
Source object for the input file. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file format is unsupported. |
Source code in src/biomero_converter/helper.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
create_writer(output_format, verbose=False)
Create a writer object and output extension based on the output format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_format
|
str
|
Output format string: 'omezarr04', 'omezarr05', 'omezarr06' (OME-Zarr version) or 'ometiff'. The legacy names 'omezarr2' and 'omezarr3' (Zarr version) are still accepted. |
required |
verbose
|
bool
|
If True, enables verbose output. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
(writer object, output file extension) |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the output format is unsupported. |
Source code in src/biomero_converter/helper.py
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 | |
get_incucyte_plates(filename)
Get all available plate IDs from an Incucyte archive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the Incucyte archive folder or .icarch file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
List of plate IDs (strings) found in the archive. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the path is not a valid Incucyte archive. |
Source code in src/biomero_converter/helper.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
is_dicom(filename)
Check if the input is a DICOM file (by extension or content), a DICOMDIR or a folder holding DICOM files.
Source code in src/biomero_converter/helper.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
main
main()
Source code in src/biomero_converter/main.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
ome_tiff_util
INVALID_XML_CHARS = re.compile('[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]')
module-attribute
camel_to_snake(name)
Source code in src/biomero_converter/util.py
303 304 305 | |
camel_to_snake_keys_dict(dct)
Source code in src/biomero_converter/util.py
295 296 297 298 299 300 | |
convert_dotnet_ticks_to_datetime(net_ticks)
Source code in src/biomero_converter/util.py
175 176 | |
convert_to_s(value, unit)
Source code in src/biomero_converter/util.py
319 320 321 322 323 324 | |
convert_to_um(value, unit)
Source code in src/biomero_converter/util.py
308 309 310 311 312 313 314 315 316 | |
create_binaryonly_metadata(metadata_filename, companion_uuid)
Source code in src/biomero_converter/ome_tiff_util.py
410 411 412 413 414 415 | |
create_image_metadata(source, image_name, dim_order='tczyx', image_uuid=None, image_filename=None, instrument_id=None, objective_id=None, metadata_only=False, position=None)
Source code in src/biomero_converter/ome_tiff_util.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | |
create_metadata(source, dim_order='tczyx', uuid=None, image_uuids=None, image_filenames=None, wells=None, metadata_only=False)
Source code in src/biomero_converter/ome_tiff_util.py
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 178 179 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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 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 291 292 293 294 295 296 | |
create_planes(position_um, pixel_size_um, nt, nc, nz)
Source code in src/biomero_converter/ome_tiff_util.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |
create_resolution_metadata(source)
Source code in src/biomero_converter/ome_tiff_util.py
445 446 447 448 449 | |
create_row_col_label(index, naming_convention)
Source code in src/biomero_converter/ome_tiff_util.py
437 438 439 440 441 442 | |
create_uuid()
Source code in src/biomero_converter/ome_tiff_util.py
30 31 | |
dicom_to_dict(obj)
Source code in src/biomero_converter/util.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
ensure_list(item)
Source code in src/biomero_converter/util.py
11 12 13 14 | |
fix_bad_micro_value(value)
Source code in src/biomero_converter/util.py
365 366 367 368 | |
flatten_dict(dct, prefix='')
Source code in src/biomero_converter/util.py
281 282 283 284 285 286 287 288 289 290 291 292 | |
get_bits_type(nbits)
Source code in src/biomero_converter/util.py
77 78 79 80 81 82 83 84 85 86 | |
get_filetitle(filename)
Source code in src/biomero_converter/util.py
93 94 | |
get_level_from_scale(source_scales, target_scale=1)
Source code in src/biomero_converter/util.py
67 68 69 70 71 72 73 74 | |
get_numpy_data(data, dim_order, t, c, z, y, x, y_size, x_size)
Source code in src/biomero_converter/util.py
43 44 45 46 47 48 49 50 51 52 53 54 55 | |
get_pyramid_levels(shape, dim_order, max_levels, downscale, min_level_size=1)
Source code in src/biomero_converter/util.py
58 59 60 61 62 63 64 | |
get_row_col_index(label)
Source code in src/biomero_converter/ome_tiff_util.py
429 430 431 432 433 434 | |
get_row_col_len_type(labels)
Source code in src/biomero_converter/ome_tiff_util.py
418 419 420 421 422 423 424 425 426 | |
get_rows_cols_plate(nwells)
Source code in src/biomero_converter/util.py
147 148 149 150 151 152 153 154 155 156 157 158 159 | |
metadata_to_dict(xml_metadata)
Source code in src/biomero_converter/ome_tiff_util.py
18 19 20 21 22 | |
pad_leading_zero(input_string, num_digits=2)
Source code in src/biomero_converter/util.py
129 130 131 132 133 134 135 136 137 138 139 | |
parse_datetime(value)
A datetime from an ISO 8601 or other common date text, or None if it is none.
Source code in src/biomero_converter/util.py
162 163 164 165 166 167 168 169 170 171 172 | |
print_dict(value, tab=0, max_len=250, bullet=False)
Source code in src/biomero_converter/util.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
print_hbytes(nbytes)
Source code in src/biomero_converter/util.py
351 352 353 354 355 356 357 358 359 360 361 362 | |
read_ome_acquisition_end_datetime(metadata)
Source code in src/biomero_converter/ome_tiff_util.py
136 137 138 139 140 141 142 143 144 145 146 147 | |
read_ome_xml_metadata(metadata)
Source code in src/biomero_converter/ome_tiff_util.py
38 39 40 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
redimension_data(data, old_order, new_order, **indices)
Source code in src/biomero_converter/util.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
remove_invalid_xml_chars(value)
Source code in src/biomero_converter/ome_tiff_util.py
25 26 27 | |
remove_key_prefix(obj, prefix)
Source code in src/biomero_converter/util.py
271 272 273 274 275 276 277 278 | |
reset_ome_ids()
Source code in src/biomero_converter/ome_tiff_util.py
34 35 | |
split_well_name(well_name, remove_leading_zeros=True, col_as_int=False)
Source code in src/biomero_converter/util.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
splitall(path)
Source code in src/biomero_converter/util.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
strip_leading_zeros(well_name)
Source code in src/biomero_converter/util.py
142 143 144 | |
to_plain_types(obj)
Source code in src/biomero_converter/util.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
validate_filename(filename)
Source code in src/biomero_converter/util.py
89 90 | |
without_keys(value, keys)
Source code in src/biomero_converter/util.py
262 263 264 265 266 267 268 | |
xml_content_to_dict(element)
Source code in src/biomero_converter/util.py
179 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 213 214 215 216 217 218 219 | |
ome_zarr_util
convert_multiscales_from_v06(multiscales)
Convert OME-Zarr 0.6 (RFC-5) multiscales metadata to the 0.4/0.5 layout (axes and a list of scale / translation transformations per dataset), so it can be read like earlier versions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
multiscales
|
list
|
Multiscales metadata. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
Multiscales metadata in the 0.5 layout. |
Source code in src/biomero_converter/ome_zarr_util.py
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 | |
convert_multiscales_to_v06(multiscales, coordinate_system='physical')
Convert OME-Zarr 0.4/0.5 multiscales metadata to the 0.6 (RFC-5) layout.
The axes move into a named coordinate system, and the transformations of each dataset become a single transformation (or a sequence of scale and translation) from the dataset path to that coordinate system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
multiscales
|
list
|
Multiscales metadata. |
required |
coordinate_system
|
str
|
Name of the (physical) coordinate system. |
'physical'
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
Multiscales metadata in the 0.6 layout. |
Source code in src/biomero_converter/ome_zarr_util.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
create_axes_metadata(dimension_order)
Create axes metadata for OME-Zarr from dimension order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimension_order
|
str
|
String of dimension characters. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
List of axis metadata dictionaries. |
Source code in src/biomero_converter/ome_zarr_util.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
create_channel_metadata(dtype, channels, nchannels, is_rgb, window, ome_version)
Create channel metadata for OME-Zarr.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype
|
Numpy dtype of image data. |
required | |
channels
|
list
|
List of channel dicts. |
required |
nchannels
|
int
|
Number of channels. |
required |
window
|
tuple
|
Min/max window values. |
required |
ome_version
|
str
|
OME-Zarr version. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Channel metadata dictionary. |
Source code in src/biomero_converter/ome_zarr_util.py
174 175 176 177 178 179 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 213 214 215 216 217 218 219 220 221 222 | |
create_transformation_metadata(dimension_order, pixel_size_um, factor, translation_um=None)
Create transformation metadata (scale and translation) for OME-Zarr.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimension_order
|
str
|
String of dimension characters. |
required |
pixel_size_um
|
dict
|
Pixel size in micrometers per dimension. |
required |
factor
|
float
|
Scaling factor. |
required |
translation_um
|
dict
|
Translation in micrometers per dimension. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
List of transformation metadata dictionaries. |
Source code in src/biomero_converter/ome_zarr_util.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
patch_zarr_windows_network_move()
Work around zarr LocalStore failing on Windows network shares (see issue #10).
On Windows zarr uses os.rename for exclusive writes (set_if_not_exists) and relies on FileExistsError when the destination exists. Some network shares (SMB) report this as PermissionError [WinError 5] instead, which zarr does not handle.
Source code in src/biomero_converter/ome_zarr_util.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
scale_dimensions_dict(shape0, scale)
Scale x and y dimensions in a shape dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape0
|
dict
|
Original shape dictionary. |
required |
scale
|
float
|
Scaling factor. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Scaled shape dictionary. |
Source code in src/biomero_converter/ome_zarr_util.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
scale_dimensions_xy(shape0, dimension_order, scale)
Scale x and y dimensions in a shape tuple.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape0
|
tuple
|
Original shape. |
required |
dimension_order
|
str
|
String of dimension characters. |
required |
scale
|
float
|
Scaling factor. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
Scaled shape. |
Source code in src/biomero_converter/ome_zarr_util.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
parameters
OME_DIR = 'OME'
module-attribute
OME_FILE = 'METADATA.ome.xml'
module-attribute
PYRAMID_DOWNSCALE = 2
module-attribute
PYRAMID_LEVELS = 6
module-attribute
RETRY_ATTEMPTS = 3
module-attribute
TIFF_COMPRESSION = 'LZW'
module-attribute
TILE_SIZE = 1024
module-attribute
VERSION = get_version()
module-attribute
ZARR_CHUNK_SIZE = TILE_SIZE
module-attribute
ZARR_SHARD_MULTIPLIER = 10
module-attribute
rocrate_utils
ACQUISITION_METADATA_FILENAME = 'acquisition-metadata.yaml'
module-attribute
CONVERTER_URL = 'https://github.com/NL-BioImaging/biomero-converter'
module-attribute
MODEL_SCHEMA_URL = 'https://github.com/NL-BioImaging/imaging-metadata-converter/blob/{release}/src/imaging_metadata_converter/models/' + os.path.basename(DEFAULT_MODEL_FILE)
module-attribute
add_instrument(crate, source, model_instrument)
The instrument named in the metadata, identified by what names it; None if the metadata does not.
Source code in src/biomero_converter/rocrate_utils.py
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 | |
create_ro_crate(source, dest_path={})
Source code in src/biomero_converter/rocrate_utils.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
get_model_schema_version()
Source code in src/biomero_converter/rocrate_utils.py
182 183 184 185 186 187 188 189 | |
normalise_key(key)
Source code in src/biomero_converter/rocrate_utils.py
218 219 | |
search_metadata(metadata, label, context='', path=())
The first value whose key contains the label, below or at a key containing the context; without a context, whose key is the label (EXIF Make, Model).
Source code in src/biomero_converter/rocrate_utils.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
search_metadata_fully(metadata, labels, contexts=None)
Source code in src/biomero_converter/rocrate_utils.py
192 193 194 195 196 197 198 | |
to_iso_datetime(value)
Source code in src/biomero_converter/rocrate_utils.py
176 177 178 179 | |
tiff_metadata
Read the metadata of a TIFF file, and what it says about space.
Vendors write the pixel size and the stage position in their own tags, under their own names and in their own units, so rather than reading the tags of particular vendors, the whole metadata tree is searched for the names these values are known by, and every value is normalised to micrometres. That way a vendor which is not known here is picked up as well, as long as it names its fields the way the rest do.
AXIS_SUFFIXES = (('x', 'x'), ('y', 'y'), ('z', 'z'), ('width', 'x'), ('height', 'y'), ('depth', 'z'))
module-attribute
DIMENSION_SUFFIXES = ('width', 'height', 'depth')
module-attribute
EXIF_TAG_NAME = 'ExifTag'
module-attribute
FIELD_OF_VIEW_NAMES = ('fov', 'fieldofview', 'fieldwidth', 'hfw', 'horizontalfieldwidth', 'vfw')
module-attribute
IDENTITY_TAG_NAMES = ('Make', 'Model', 'Software', 'HostComputer')
module-attribute
MOJIBAKE = {'¦Ì': 'µ'}
module-attribute
PIXEL_SIZE_NAMES = ('pixelsize', 'pixelspacing', 'physicalsize')
module-attribute
PLAUSIBLE_PIXEL_SIZE_UM = (1e-05, 10000.0)
module-attribute
POSITION_CONTAINER_NAMES = ('stage', 'position')
module-attribute
POSITION_NAMES = ('stage', 'stagepos', 'position', 'pos')
module-attribute
PRIVATE_TAG_CODE = 32768
module-attribute
QUANTITY_PATTERN = re.compile('^\\s*([-+]?[\\d.]+(?:[eE][-+]?\\d+)?)\\s*([^\\d\\s]*)\\s*$')
module-attribute
SCREEN_RESOLUTIONS = (72, 96)
module-attribute
STAGE_TRAVEL_PATTERN = re.compile('(\\d{1,4})x(\\d{1,4})(?:x(\\d{1,4}))?', re.IGNORECASE)
module-attribute
UM_CONVERSIONS = {'a': 0.0001, 'angstrom': 0.0001, 'nm': 0.001, 'nanometer': 0.001, 'nanometre': 0.001, 'um': 1, 'µm': 1, 'micrometer': 1, 'micrometre': 1, 'micron': 1, 'mm': 1000.0, 'millimeter': 1000.0, 'millimetre': 1000.0, 'cm': 10000.0, 'centimeter': 10000.0, 'centimetre': 10000.0, 'm': 1000000.0, 'meter': 1000000.0, 'metre': 1000000.0, 'inch': 25400, 'in': 25400}
module-attribute
UNIT_KEYS = ('unit', 'units')
module-attribute
VALUE_KEYS = ('value', 'val')
module-attribute
XSI_NAMESPACE = '{http://www.w3.org/2001/XMLSchema-instance}'
module-attribute
logger = logging.getLogger(__name__)
module-attribute
convert_to_um(value, unit)
Return a value in micrometres, or None if it cannot be read.
Source code in src/biomero_converter/tiff_metadata.py
239 240 241 242 243 244 245 246 247 248 | |
decode_metadata(value)
Decode a metadata value into the structure it holds.
Vendors store their metadata as an xml document or as a nested mapping, so parse the xml into a mapping, keeping its root element, such as OME, FeiImage or Fibics, which names the vendor's schema.
Source code in src/biomero_converter/tiff_metadata.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
drop_document_details(value)
Recursively drop the entries describing the xml document itself.
The plumbing appears at every level of a vendor's schema, not just at the top, so this has to walk the whole tree.
Source code in src/biomero_converter/tiff_metadata.py
114 115 116 117 118 119 120 121 122 123 124 125 126 | |
field_of_view_pixel_size(metadata, shape)
Return the pixel size from the width of the whole image.
Electron microscopes state the field of view rather than the pixel, so divide it by the pixels across the image.
Source code in src/biomero_converter/tiff_metadata.py
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |
find_unit(keyed)
Return the unit a mapping names, if it names one.
Source code in src/biomero_converter/tiff_metadata.py
274 275 276 277 278 279 | |
get_extra_metadata(tif)
Return the vendor metadata in a TIFF file.
Rather than reading the tags of particular vendors, every private tag is collected and normalised the same way, so that vendors which are not known here are picked up as well. TIFF reserves tag codes at or above 32768 for a vendor's own use, which is where instrument metadata ends up, whereas the baseline tags below that hold the bookkeeping needed to decode the pixels.
The Exif IFD is the exception: its fields are standard rather than a vendor's own, so they are merged in beside the rest instead of being nested behind the name of the tag that points at them.
Source code in src/biomero_converter/tiff_metadata.py
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 69 70 71 72 73 74 75 76 77 78 79 | |
get_pixel_size_um(tif, metadata, shape)
Return the size of a pixel in micrometres, per axis.
The sources are tried in the order they can be trusted: what a vendor states outright, then the width of the image divided by the pixels across it, and last the baseline TIFF resolution, which is the one every writer fills in whether it knows the answer or not.
Source code in src/biomero_converter/tiff_metadata.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | |
get_position_um(metadata)
Return the stage position in micrometres, per axis.
A vendor writes the position as a structure named after the stage, holding one field per axis, or as flat fields with the axis on the end of the name. Where no unit is given the value is read as metres, unless the file says how far the stage travels.
Source code in src/biomero_converter/tiff_metadata.py
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | |
imagej_pixel_size(tif)
Return the pixel size ImageJ writes, which names its own unit.
Source code in src/biomero_converter/tiff_metadata.py
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | |
implied_position_unit(value, travel_mm)
Return the unit a position with no unit beside it is in.
A vendor leaving the unit out means the SI one, except where the file also names the travel of its stage: a coordinate that fits inside that travel read as millimetres is millimetres, because no stage of that size reaches metres away from its own origin.
Source code in src/biomero_converter/tiff_metadata.py
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
implied_unit(name)
Return the unit a pixel size with no unit beside it is in.
OME states that PhysicalSize defaults to micrometres. Anywhere else a bare length is in the SI unit: Olympus writes 1.65e-9, which is metres or nothing.
Source code in src/biomero_converter/tiff_metadata.py
360 361 362 363 364 365 366 367 | |
is_document_detail(key, value)
Return whether an entry describes the document, not the image.
Source code in src/biomero_converter/tiff_metadata.py
129 130 131 132 | |
is_plausible_pixel_size(size)
Return whether a pixel size can be a measurement at all.
Source code in src/biomero_converter/tiff_metadata.py
333 334 335 336 | |
normalise_name(key)
Return a key as bare lowercase letters, for comparing names.
Source code in src/biomero_converter/tiff_metadata.py
219 220 221 222 223 224 | |
parse_quantity(value, unit=None)
Return a metadata value in micrometres, however it is written.
A vendor writes a measurement as a number beside a unit field, as a number with the unit stuck on the end of the string, or as a bare number whose unit is named by a neighbouring field.
Source code in src/biomero_converter/tiff_metadata.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
parse_xml(value)
Return value parsed as an xml document, or None if it is not one.
The xml declaration is optional, and vendors do leave it out, so rather than looking for one, hand anything that opens like a document to the parser and let it decide.
Source code in src/biomero_converter/tiff_metadata.py
99 100 101 102 103 104 105 106 107 108 109 110 111 | |
repair_text(value)
Recursively put back the characters a broken encoding garbled.
Only the sequences known to be garbled are replaced, rather than guessing at the encoding of every string, which would mangle text that was read correctly.
Source code in src/biomero_converter/tiff_metadata.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
resolution_pixel_size(tif)
Return the pixel size from the baseline TIFF resolution.
The resolution is a rational, and a writer with nothing to say fills it in anyway, so read it only where it can mean something.
Source code in src/biomero_converter/tiff_metadata.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | |
sibling_unit(key, siblings)
Return the unit a neighbouring field names for this one.
OME writes PhysicalSizeX beside PhysicalSizeXUnit, which is the same name with the unit on the end.
Source code in src/biomero_converter/tiff_metadata.py
297 298 299 300 301 302 303 304 305 306 307 308 309 | |
split_axis(name)
Split the axis off the end of a normalised field name.
The suffix itself comes back as well, because a name means different things depending on how the axis was written.
Source code in src/biomero_converter/tiff_metadata.py
227 228 229 230 231 232 233 234 235 236 | |
stage_travel_mm(metadata)
Return how far the stage travels, where a field names it.
A vendor writes the travel into the model of the stage, as in TMCM-GYLZ-4000X-FIVE-110x110x69, and quotes it in millimetres.
Source code in src/biomero_converter/tiff_metadata.py
446 447 448 449 450 451 452 453 454 455 456 457 458 | |
stated_pixel_size(metadata, shape)
Return the pixel size from any field naming one.
This is where OME PhysicalSizeX, and every vendor field named after the size or the spacing of a pixel, is picked up.
Source code in src/biomero_converter/tiff_metadata.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
walk_fields(metadata)
Yield every field in the metadata, with the mapping holding it.
The mapping comes along so that a field can be read together with its neighbours, which is where the unit of a bare number is named.
Source code in src/biomero_converter/tiff_metadata.py
282 283 284 285 286 287 288 289 290 291 292 293 294 | |
util
camel_to_snake(name)
Source code in src/biomero_converter/util.py
303 304 305 | |
camel_to_snake_keys_dict(dct)
Source code in src/biomero_converter/util.py
295 296 297 298 299 300 | |
convert_dotnet_ticks_to_datetime(net_ticks)
Source code in src/biomero_converter/util.py
175 176 | |
convert_to_s(value, unit)
Source code in src/biomero_converter/util.py
319 320 321 322 323 324 | |
convert_to_um(value, unit)
Source code in src/biomero_converter/util.py
308 309 310 311 312 313 314 315 316 | |
dicom_to_dict(obj)
Source code in src/biomero_converter/util.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
ensure_list(item)
Source code in src/biomero_converter/util.py
11 12 13 14 | |
fix_bad_micro_value(value)
Source code in src/biomero_converter/util.py
365 366 367 368 | |
flatten_dict(dct, prefix='')
Source code in src/biomero_converter/util.py
281 282 283 284 285 286 287 288 289 290 291 292 | |
get_bits_type(nbits)
Source code in src/biomero_converter/util.py
77 78 79 80 81 82 83 84 85 86 | |
get_filetitle(filename)
Source code in src/biomero_converter/util.py
93 94 | |
get_level_from_scale(source_scales, target_scale=1)
Source code in src/biomero_converter/util.py
67 68 69 70 71 72 73 74 | |
get_numpy_data(data, dim_order, t, c, z, y, x, y_size, x_size)
Source code in src/biomero_converter/util.py
43 44 45 46 47 48 49 50 51 52 53 54 55 | |
get_pyramid_levels(shape, dim_order, max_levels, downscale, min_level_size=1)
Source code in src/biomero_converter/util.py
58 59 60 61 62 63 64 | |
get_rows_cols_plate(nwells)
Source code in src/biomero_converter/util.py
147 148 149 150 151 152 153 154 155 156 157 158 159 | |
pad_leading_zero(input_string, num_digits=2)
Source code in src/biomero_converter/util.py
129 130 131 132 133 134 135 136 137 138 139 | |
parse_datetime(value)
A datetime from an ISO 8601 or other common date text, or None if it is none.
Source code in src/biomero_converter/util.py
162 163 164 165 166 167 168 169 170 171 172 | |
print_dict(value, tab=0, max_len=250, bullet=False)
Source code in src/biomero_converter/util.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
print_hbytes(nbytes)
Source code in src/biomero_converter/util.py
351 352 353 354 355 356 357 358 359 360 361 362 | |
redimension_data(data, old_order, new_order, **indices)
Source code in src/biomero_converter/util.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
remove_key_prefix(obj, prefix)
Source code in src/biomero_converter/util.py
271 272 273 274 275 276 277 278 | |
split_well_name(well_name, remove_leading_zeros=True, col_as_int=False)
Source code in src/biomero_converter/util.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
splitall(path)
Source code in src/biomero_converter/util.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
strip_leading_zeros(well_name)
Source code in src/biomero_converter/util.py
142 143 144 | |
to_plain_types(obj)
Source code in src/biomero_converter/util.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
validate_filename(filename)
Source code in src/biomero_converter/util.py
89 90 | |
without_keys(value, keys)
Source code in src/biomero_converter/util.py
262 263 264 265 266 267 268 | |
xml_content_to_dict(element)
Source code in src/biomero_converter/util.py
179 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 213 214 215 216 217 218 219 | |
version
REPO_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
module-attribute
get_version()
Get the version from the GitHub release tag.
Uses the BIOMERO_CONVERTER_VERSION environment variable if set (e.g. in the Docker image), otherwise the git tag of the source tree (e.g. 'v0.1.31', or 'v0.1.31-2-gabc1234' after the tag), otherwise the version of the installed package (taken from the tag when it was built).
Returns:
| Name | Type | Description |
|---|---|---|
str |
Version string, or 'unknown' if it cannot be determined. |
Source code in src/biomero_converter/version.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
zarr_extension
ZarrCrate
Bases: ROCrate
Source code in src/biomero_converter/zarr_extension.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
__init__(source=None, gen_preview=False, init=False, exclude=None)
Source code in src/biomero_converter/zarr_extension.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |