mobiedantic 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1285 @@
1
+ # generated by datamodel-codegen:
2
+ # filename: https://raw.githubusercontent.com/mobie/mobie.github.io/master/schema/dataset.schema.json
3
+ # timestamp: 2024-07-09T08:23:17+00:00
4
+
5
+ from __future__ import annotations
6
+
7
+ from enum import Enum
8
+ from typing import Dict, List, Optional, Union
9
+
10
+ from pydantic import (
11
+ BaseModel,
12
+ ConfigDict,
13
+ Field,
14
+ PositiveFloat,
15
+ RootModel,
16
+ confloat,
17
+ conint,
18
+ constr,
19
+ field_validator,
20
+ )
21
+
22
+
23
+ class BdvHdf5(BaseModel):
24
+ """
25
+ Data stored in the bdv.hdf5 format, i.e. hdf5 data that is stored on the local fileystem.
26
+ """
27
+
28
+ model_config = ConfigDict(
29
+ extra='forbid',
30
+ )
31
+ relativePath: str = Field(
32
+ ...,
33
+ description='The file path to the xml storing the bdv metadata, relative to the dataset root location.',
34
+ )
35
+ absolutePath: Optional[str] = Field(
36
+ None, description='The absolute file path to the xml storing the bdv metadata.'
37
+ )
38
+ channel: Optional[int] = Field(
39
+ None,
40
+ description='Optional setup to display from the bdv.xml, in case it contains multiple setups.',
41
+ )
42
+
43
+
44
+ class BdvHdf51(BaseModel):
45
+ """
46
+ Data stored in the bdv.hdf5 format, i.e. hdf5 data that is stored on the local fileystem.
47
+ """
48
+
49
+ model_config = ConfigDict(
50
+ extra='forbid',
51
+ )
52
+ relativePath: Optional[str] = Field(
53
+ None,
54
+ description='The file path to the xml storing the bdv metadata, relative to the dataset root location.',
55
+ )
56
+ absolutePath: str = Field(
57
+ ..., description='The absolute file path to the xml storing the bdv metadata.'
58
+ )
59
+ channel: Optional[int] = Field(
60
+ None,
61
+ description='Optional setup to display from the bdv.xml, in case it contains multiple setups.',
62
+ )
63
+
64
+
65
+ class BdvN5(BaseModel):
66
+ """
67
+ Data stored in the bdv.n5 format, i.e. n5 data that is stored on the local fileystem.
68
+ """
69
+
70
+ model_config = ConfigDict(
71
+ extra='forbid',
72
+ )
73
+ relativePath: str = Field(
74
+ ...,
75
+ description='The file path to the xml storing the bdv metadata, relative to the dataset root location.',
76
+ )
77
+ absolutePath: Optional[str] = Field(
78
+ None, description='The absolute file path to the xml storing the bdv metadata.'
79
+ )
80
+ channel: Optional[int] = Field(
81
+ None,
82
+ description='Optional setup to display from the bdv.xml, in case it contains multiple setups.',
83
+ )
84
+
85
+
86
+ class BdvN51(BaseModel):
87
+ """
88
+ Data stored in the bdv.n5 format, i.e. n5 data that is stored on the local fileystem.
89
+ """
90
+
91
+ model_config = ConfigDict(
92
+ extra='forbid',
93
+ )
94
+ relativePath: Optional[str] = Field(
95
+ None,
96
+ description='The file path to the xml storing the bdv metadata, relative to the dataset root location.',
97
+ )
98
+ absolutePath: str = Field(
99
+ ..., description='The absolute file path to the xml storing the bdv metadata.'
100
+ )
101
+ channel: Optional[int] = Field(
102
+ None,
103
+ description='Optional setup to display from the bdv.xml, in case it contains multiple setups.',
104
+ )
105
+
106
+
107
+ class BdvN5S3(BaseModel):
108
+ """
109
+ Data stored in the bdv.n5.s3 format, i.e. n5 data that is stored on a s3 object store.
110
+ """
111
+
112
+ model_config = ConfigDict(
113
+ extra='forbid',
114
+ )
115
+ relativePath: str = Field(
116
+ ...,
117
+ description='The file path to the xml storing the bdv metadata, relative to the dataset root location.',
118
+ )
119
+ channel: Optional[int] = Field(
120
+ None,
121
+ description='Optional setup to display from the bdv.xml, in case it contains multiple setups.',
122
+ )
123
+
124
+
125
+ class BdvOmeZarr(BaseModel):
126
+ """
127
+ Data stored in the bdv.ome.zarr format, i.e. ome.zarr data that is stored on the local fileystem with additional bdv xml metadata. This data format is deprecated, please use ome.zarr instead.
128
+ """
129
+
130
+ model_config = ConfigDict(
131
+ extra='forbid',
132
+ )
133
+ relativePath: str = Field(
134
+ ...,
135
+ description='The file path to the xml storing the bdv metadata, relative to the dataset root location.',
136
+ )
137
+ absolutePath: Optional[str] = Field(
138
+ None, description='The absolute file path to the xml storing the bdv metadata.'
139
+ )
140
+ channel: Optional[int] = Field(
141
+ None,
142
+ description='Optional setup to display from the bdv.xml, in case it contains multiple setups.',
143
+ )
144
+
145
+
146
+ class BdvOmeZarr1(BaseModel):
147
+ """
148
+ Data stored in the bdv.ome.zarr format, i.e. ome.zarr data that is stored on the local fileystem with additional bdv xml metadata. This data format is deprecated, please use ome.zarr instead.
149
+ """
150
+
151
+ model_config = ConfigDict(
152
+ extra='forbid',
153
+ )
154
+ relativePath: Optional[str] = Field(
155
+ None,
156
+ description='The file path to the xml storing the bdv metadata, relative to the dataset root location.',
157
+ )
158
+ absolutePath: str = Field(
159
+ ..., description='The absolute file path to the xml storing the bdv metadata.'
160
+ )
161
+ channel: Optional[int] = Field(
162
+ None,
163
+ description='Optional setup to display from the bdv.xml, in case it contains multiple setups.',
164
+ )
165
+
166
+
167
+ class BdvOmeZarrS3(BaseModel):
168
+ """
169
+ Data stored in the bdv.ome.zarr.s3 format, i.e. ome.zarr data that is stored on a s3 object store with additional bdv xml metadata. This data format is deprecated, please use ome.zarr.s3 instead.
170
+ """
171
+
172
+ model_config = ConfigDict(
173
+ extra='forbid',
174
+ )
175
+ relativePath: str = Field(
176
+ ...,
177
+ description='The file path to the xml storing the bdv metadata, relative to the dataset root location.',
178
+ )
179
+ channel: Optional[int] = Field(
180
+ None,
181
+ description='Optional setup to display from the bdv.xml, in case it contains multiple setups.',
182
+ )
183
+
184
+
185
+ class OmeZarr(BaseModel):
186
+ """
187
+ Data stored in the ome.zarr format, i.e. ome.zarr data that is stored on the local fileystem.
188
+ """
189
+
190
+ model_config = ConfigDict(
191
+ extra='forbid',
192
+ )
193
+ relativePath: str = Field(
194
+ ...,
195
+ description='The file path to the ome.zarr file, relative to the dataset root location.',
196
+ )
197
+ absolutePath: Optional[str] = Field(
198
+ None, description='The absolute file path to the ome.zarr file.'
199
+ )
200
+ channel: Optional[int] = Field(
201
+ None,
202
+ description='Optional channel to display from the ome.zarr file, in case it contains multiple channels.',
203
+ )
204
+
205
+
206
+ class OmeZarr1(BaseModel):
207
+ """
208
+ Data stored in the ome.zarr format, i.e. ome.zarr data that is stored on the local fileystem.
209
+ """
210
+
211
+ model_config = ConfigDict(
212
+ extra='forbid',
213
+ )
214
+ relativePath: Optional[str] = Field(
215
+ None,
216
+ description='The file path to the ome.zarr file, relative to the dataset root location.',
217
+ )
218
+ absolutePath: str = Field(
219
+ ..., description='The absolute file path to the ome.zarr file.'
220
+ )
221
+ channel: Optional[int] = Field(
222
+ None,
223
+ description='Optional channel to display from the ome.zarr file, in case it contains multiple channels.',
224
+ )
225
+
226
+
227
+ class OmeZarrS3(BaseModel):
228
+ """
229
+ Data stored in the ome.zarr.s3 format, i.e. ome.zarr data that is stored on a s3 object store.
230
+ """
231
+
232
+ model_config = ConfigDict(
233
+ extra='forbid',
234
+ )
235
+ s3Address: str = Field(..., description='The s3 address for this image data.')
236
+ signingRegion: Optional[str] = Field(
237
+ None, description='The signing region for aws, e.g. us-east-1'
238
+ )
239
+ channel: Optional[int] = Field(
240
+ None,
241
+ description='Optional channel to display from the ome.zarr file, in case it contains multiple channels.',
242
+ )
243
+
244
+
245
+ class OpenOrganelleS3(BaseModel):
246
+ """
247
+ Data stored in the openOrganelle file format on a s3 object store.
248
+ """
249
+
250
+ model_config = ConfigDict(
251
+ extra='forbid',
252
+ )
253
+ s3Address: str = Field(..., description='The s3 address for this image data.')
254
+ signingRegion: Optional[str] = Field(
255
+ None, description='The signing region for aws, e.g. us-east-1'
256
+ )
257
+ channel: Optional[int] = Field(
258
+ None,
259
+ description='Optional channel to display from the open organelle file, in case it contains multiple channels.',
260
+ )
261
+
262
+
263
+ class ImageData(BaseModel):
264
+ """
265
+ Description of the image data for this source, including the file format and the location of the data.
266
+ """
267
+
268
+ model_config = ConfigDict(
269
+ extra='forbid',
270
+ )
271
+ bdv_hdf5: Optional[Union[BdvHdf5, BdvHdf51]] = Field(
272
+ None,
273
+ alias='bdv.hdf5',
274
+ description='Data stored in the bdv.hdf5 format, i.e. hdf5 data that is stored on the local fileystem.',
275
+ )
276
+ bdv_n5: Optional[Union[BdvN5, BdvN51]] = Field(
277
+ None,
278
+ alias='bdv.n5',
279
+ description='Data stored in the bdv.n5 format, i.e. n5 data that is stored on the local fileystem.',
280
+ )
281
+ bdv_n5_s3: Optional[BdvN5S3] = Field(
282
+ None,
283
+ alias='bdv.n5.s3',
284
+ description='Data stored in the bdv.n5.s3 format, i.e. n5 data that is stored on a s3 object store.',
285
+ )
286
+ bdv_ome_zarr: Optional[Union[BdvOmeZarr, BdvOmeZarr1]] = Field(
287
+ None,
288
+ alias='bdv.ome.zarr',
289
+ description='Data stored in the bdv.ome.zarr format, i.e. ome.zarr data that is stored on the local fileystem with additional bdv xml metadata. This data format is deprecated, please use ome.zarr instead.',
290
+ )
291
+ bdv_ome_zarr_s3: Optional[BdvOmeZarrS3] = Field(
292
+ None,
293
+ alias='bdv.ome.zarr.s3',
294
+ description='Data stored in the bdv.ome.zarr.s3 format, i.e. ome.zarr data that is stored on a s3 object store with additional bdv xml metadata. This data format is deprecated, please use ome.zarr.s3 instead.',
295
+ )
296
+ ome_zarr: Optional[Union[OmeZarr, OmeZarr1]] = Field(
297
+ None,
298
+ alias='ome.zarr',
299
+ description='Data stored in the ome.zarr format, i.e. ome.zarr data that is stored on the local fileystem.',
300
+ )
301
+ ome_zarr_s3: Optional[OmeZarrS3] = Field(
302
+ None,
303
+ alias='ome.zarr.s3',
304
+ description='Data stored in the ome.zarr.s3 format, i.e. ome.zarr data that is stored on a s3 object store.',
305
+ )
306
+ openOrganelle_s3: Optional[OpenOrganelleS3] = Field(
307
+ None,
308
+ alias='openOrganelle.s3',
309
+ description='Data stored in the openOrganelle file format on a s3 object store.',
310
+ )
311
+
312
+
313
+ class Tsv(BaseModel):
314
+ """
315
+ Table data in tsv file format, specified as root location for the folder with tables. The folder MUST contain the table default.tsv, which will always be loaded as the first table for this source; this table MUST contain the mandatory columns for the given source type.
316
+ """
317
+
318
+ model_config = ConfigDict(
319
+ extra='forbid',
320
+ )
321
+ relativePath: str = Field(
322
+ ...,
323
+ description='The relative path of the table data w.r.t the dataset root location.',
324
+ )
325
+
326
+
327
+ class TableData(BaseModel):
328
+ """
329
+ Description of the table data for this source, including the format and the location of the table data.
330
+ """
331
+
332
+ model_config = ConfigDict(
333
+ extra='forbid',
334
+ )
335
+ tsv: Tsv = Field(
336
+ ...,
337
+ description='Table data in tsv file format, specified as root location for the folder with tables. The folder MUST contain the table default.tsv, which will always be loaded as the first table for this source; this table MUST contain the mandatory columns for the given source type.',
338
+ )
339
+
340
+
341
+ class ImageSource(BaseModel):
342
+ """
343
+ An image source. The source name (=key for this source entry) must be the same as the setup name in the bdv.xml.
344
+ """
345
+
346
+ model_config = ConfigDict(
347
+ extra='forbid',
348
+ )
349
+ imageData: ImageData
350
+
351
+
352
+ class SegmentationSource(BaseModel):
353
+ """
354
+ A segmentation source. The source name (=key for this source entry) must be the same as the setup name in the bdv.xml.
355
+ """
356
+
357
+ model_config = ConfigDict(
358
+ extra='forbid',
359
+ )
360
+ imageData: ImageData
361
+ tableData: Optional[TableData] = None
362
+
363
+
364
+ class SpotSource(BaseModel):
365
+ """
366
+ A spot source, corresponding to a collection of points loaded from a table. The table must contain the columns 'spot_id', as well as 'x', 'y', 'z' ('z' is not required for 2d datasets.)
367
+ """
368
+
369
+ model_config = ConfigDict(
370
+ extra='forbid',
371
+ )
372
+ boundingBoxMin: List[float] = Field(
373
+ ...,
374
+ description='The minimum of the bounding box of physical cooridinates for the spots.',
375
+ max_length=3,
376
+ min_length=2,
377
+ )
378
+ boundingBoxMax: List[float] = Field(
379
+ ...,
380
+ description='The maximum of the bounding box of physical cooridinates for the spots.',
381
+ max_length=3,
382
+ min_length=2,
383
+ )
384
+ tableData: TableData
385
+ unit: str = Field(
386
+ ...,
387
+ description='The unit of measurement for the coordinate system, e.g. micrometer or nanometer',
388
+ )
389
+
390
+
391
+ class RegionSource(BaseModel):
392
+ """
393
+ A region table, corresponding to a image region attributes. The table must contain the column 'region_id'. Can be referenced in regionDisplays
394
+ """
395
+
396
+ model_config = ConfigDict(
397
+ extra='forbid',
398
+ )
399
+ tableData: TableData
400
+
401
+
402
+ class Name(RootModel[constr(pattern=r'^[^;\/ ]+$')]):
403
+ root: constr(pattern=r'^[^;\/ ]+$') = Field(..., description='Name of this field.')
404
+
405
+
406
+ class AdditionalTables(
407
+ RootModel[
408
+ List[
409
+ Union[
410
+ constr(pattern=r'^[^;\/ ]+\.csv$'), constr(pattern=r'^[^;\/ ]+\.tsv$')
411
+ ]
412
+ ]
413
+ ]
414
+ ):
415
+ """
416
+ Additional tables to load for this display. This only needs to be specified if additional tables are loaded; the default table (default.tsv) will always be loaded.
417
+ """
418
+
419
+ root: List[
420
+ Union[constr(pattern=r'^[^;\/ ]+\.csv$'), constr(pattern=r'^[^;\/ ]+\.tsv$')]
421
+ ] = Field(
422
+ ...,
423
+ description='Additional tables to load for this display. This only needs to be specified if additional tables are loaded; the default table (default.tsv) will always be loaded.',
424
+ min_length=1,
425
+ )
426
+
427
+
428
+ class Lut(Enum):
429
+ """
430
+ The look-up-table for categorical coloring modes. Note: if the lut is numeric ('viridis', 'blueWhiteRed'), the valueLimits field must be given. 'argbColumn' is deprecated, please use 'rgbaColumn' instead
431
+ """
432
+
433
+ argbColumn = 'argbColumn'
434
+ blueWhiteRed = 'blueWhiteRed'
435
+ glasbey = 'glasbey'
436
+ glasbeyZeroTransparent = 'glasbeyZeroTransparent'
437
+ viridis = 'viridis'
438
+ rgbaColumn = 'rgbaColumn'
439
+
440
+
441
+ class Opacity(RootModel[confloat(ge=0.0, le=1.0)]):
442
+ root: confloat(ge=0.0, le=1.0) = Field(
443
+ ...,
444
+ description='The alpha value used for blending segmentation and image data in the viewer.',
445
+ )
446
+
447
+
448
+ class OpacityNotSelected(RootModel[confloat(ge=0.0, le=1.0)]):
449
+ root: confloat(ge=0.0, le=1.0) = Field(
450
+ ...,
451
+ description='The alpha value used for blending segmentation and image data in the viewer that is applied to segments that are not currently selected. By default this is set to 0.15',
452
+ )
453
+
454
+
455
+ class ValueLimits(RootModel[List[float]]):
456
+ """
457
+ Value limits for numerical color maps: 'blueWhiteRed', 'viridis'.
458
+ """
459
+
460
+ root: List[float] = Field(
461
+ ...,
462
+ description="Value limits for numerical color maps: 'blueWhiteRed', 'viridis'.",
463
+ )
464
+
465
+
466
+ class ScatterPlotAxes(RootModel[List[Name]]):
467
+ """
468
+ The names of columns which should be used for the scatter plot.
469
+ """
470
+
471
+ root: List[Name] = Field(
472
+ ...,
473
+ description='The names of columns which should be used for the scatter plot.',
474
+ max_length=2,
475
+ min_length=2,
476
+ )
477
+
478
+
479
+ class MapOfSources(RootModel[Optional[Dict[str, List[Name]]]]):
480
+ root: Optional[Dict[str, List[Name]]] = Field(None, min_length=1)
481
+
482
+
483
+ class NestedListOfSources(RootModel[List[List[Name]]]):
484
+ root: List[List[Name]]
485
+
486
+
487
+ class Positions(RootModel[List[List[int]]]):
488
+ """
489
+ Grid positions for the sources. If not specified, the sources will be arranged in a square grid. If given, must have the same length as `sources` and contain 2d grid positions specified as [y, x].
490
+ """
491
+
492
+ root: List[List[int]] = Field(
493
+ ...,
494
+ description='Grid positions for the sources. If not specified, the sources will be arranged in a square grid. If given, must have the same length as `sources` and contain 2d grid positions specified as [y, x].',
495
+ min_length=2,
496
+ )
497
+
498
+
499
+ class ColorModel1(Enum):
500
+ black = 'black'
501
+ blue = 'blue'
502
+ cyan = 'cyan'
503
+ darkGray = 'darkGray'
504
+ randomFromGlasbey = 'randomFromGlasbey'
505
+ gray = 'gray'
506
+ green = 'green'
507
+ lightGray = 'lightGray'
508
+ magenta = 'magenta'
509
+ orange = 'orange'
510
+ pink = 'pink'
511
+ red = 'red'
512
+ white = 'white'
513
+ yellow = 'yellow'
514
+
515
+
516
+ class ColorModel(
517
+ RootModel[
518
+ Union[
519
+ ColorModel1,
520
+ constr(pattern=r'^(\d+)-(\d+)-(\d+)-(\d+)$'),
521
+ constr(pattern=r'^r=(\d+),g=(\d+),b=(\d+),a=(\d+)$'),
522
+ constr(pattern=r'^r(\d+)-g(\d+)-b(\d+)-a(\d+)$'),
523
+ ]
524
+ ]
525
+ ):
526
+ root: Union[
527
+ ColorModel1,
528
+ constr(pattern=r'^(\d+)-(\d+)-(\d+)-(\d+)$'),
529
+ constr(pattern=r'^r=(\d+),g=(\d+),b=(\d+),a=(\d+)$'),
530
+ constr(pattern=r'^r(\d+)-g(\d+)-b(\d+)-a(\d+)$'),
531
+ ]
532
+
533
+
534
+ class SelectionColor(RootModel[ColorModel]):
535
+ model_config = ConfigDict(
536
+ use_enum_values=True,
537
+ )
538
+
539
+ root: ColorModel = Field(
540
+ ...,
541
+ description='Color for the selected objects (segments, regions or spots). By default the color that follows from the current coloring scheme is used.',
542
+ )
543
+
544
+
545
+ class BlendingMode(Enum):
546
+ """
547
+ The blending mode for rendeting multiple image sources on top of each other. Use 'sum' for additive blending and 'alpha' for occluded blending. If not specified 'sum' will be used
548
+ """
549
+
550
+ sum = 'sum'
551
+ alpha = 'alpha'
552
+
553
+
554
+ class Resolution3dViewItem(RootModel[PositiveFloat]):
555
+ root: PositiveFloat
556
+
557
+
558
+ class ImageDisplay1(BaseModel):
559
+ """
560
+ Viewer state for a group of image sources.
561
+ """
562
+
563
+ model_config = ConfigDict(
564
+ extra='forbid',
565
+ use_enum_values=True,
566
+ )
567
+ color: Union[
568
+ ColorModel1,
569
+ constr(pattern=r'^(\d+)-(\d+)-(\d+)-(\d+)$'),
570
+ constr(pattern=r'^r=(\d+),g=(\d+),b=(\d+),a=(\d+)$'),
571
+ constr(pattern=r'^r(\d+)-g(\d+)-b(\d+)-a(\d+)$'),
572
+ ] = Field(..., description='The color map.')
573
+ contrastLimits: List[float] = Field(..., description='The contrast limits.')
574
+ name: Name = Field(..., description='Name of this image display.')
575
+ opacity: Opacity
576
+ blendingMode: Optional[BlendingMode] = Field(
577
+ None,
578
+ description="The blending mode for rendeting multiple image sources on top of each other. Use 'sum' for additive blending and 'alpha' for occluded blending. If not specified 'sum' will be used",
579
+ )
580
+ resolution3dView: Optional[List[Resolution3dViewItem]] = Field(
581
+ None,
582
+ description="The resolution used for the 3d viewer, in physical units. Only relevant if 'showImageIn3d' is true. Will be determined automatically if not specified.",
583
+ max_length=3,
584
+ min_length=3,
585
+ )
586
+ showImagesIn3d: Optional[bool] = Field(
587
+ None, description='Whether to show the images in the 3d viewer.'
588
+ )
589
+ sources: List[Name] = Field(
590
+ ...,
591
+ description='The image sources that are part of this display group. Multiple sources should be moved apart spatially with source transform(s), e.g. grid, otherwise they will not be correctly displayed in the viewer.',
592
+ min_length=1,
593
+ )
594
+ visible: Optional[bool] = Field(
595
+ None, description='Are the sources of this display visible? Default is true.'
596
+ )
597
+ invert: Optional[bool] = Field(
598
+ None, description='Whether to invert the colormap. Default is false'
599
+ )
600
+
601
+
602
+ class ImageDisplay(BaseModel):
603
+ model_config = ConfigDict(
604
+ extra='forbid',
605
+ )
606
+ imageDisplay: ImageDisplay1 = Field(
607
+ ..., description='Viewer state for a group of image sources.'
608
+ )
609
+
610
+
611
+ class SegmentationDisplay1(BaseModel):
612
+ model_config = ConfigDict(
613
+ extra='forbid',
614
+ use_enum_values=True,
615
+ )
616
+ opacity: Opacity
617
+ opacityNotSelected: Optional[OpacityNotSelected] = None
618
+ lut: Lut
619
+ colorByColumn: Optional[Name] = Field(
620
+ None,
621
+ description="Name of table column that is used for coloring. By default the 'label_id' column is used.",
622
+ )
623
+ resolution3dView: Optional[List[Resolution3dViewItem]] = Field(
624
+ None,
625
+ description="Resolution used for the 3d viewer, in physical units. Only relevant if 'showSelectedSegmentsIn3d' is true. Will be determined automatically if not specified.",
626
+ max_length=3,
627
+ min_length=3,
628
+ )
629
+ name: Name = Field(..., description='Name of this segmentation display.')
630
+ scatterPlotAxes: Optional[ScatterPlotAxes] = None
631
+ selectedSegmentIds: Optional[List[constr(pattern=r'^[^; \/]+;\d+;\d+$')]] = Field(
632
+ None,
633
+ description='List of selected segment ids, each of the form sourceName;timePoint;label_id',
634
+ )
635
+ showScatterPlot: Optional[bool] = Field(
636
+ None,
637
+ description="Whether to show the scatter plot. The default is 'false', i.e. if this property is not present the scatter plot should not be shown. If it is 'true' then 'scatterPlotAxes' must be given.",
638
+ )
639
+ showSelectedSegmentsIn3d: Optional[bool] = Field(
640
+ None, description='Whether to show the selected segments in the 3d viewer.'
641
+ )
642
+ sources: List[Name] = Field(
643
+ ...,
644
+ description='The segmentation sources that are part of this display group. Multiple sources should be moved apart spatially with source transform(s), e.g. grid, otherwise they will not be correctly displayed in the viewer.',
645
+ min_length=1,
646
+ )
647
+ additionalTables: Optional[AdditionalTables] = None
648
+ valueLimits: Optional[ValueLimits] = None
649
+ visible: Optional[bool] = Field(
650
+ None, description='Are the sources of this display visible? Default is true.'
651
+ )
652
+ showTable: Optional[bool] = Field(
653
+ None,
654
+ description='Show the table GUI element. Default is true (if the display has a table).',
655
+ )
656
+ showAsBoundaries: Optional[bool] = Field(
657
+ None,
658
+ description='Show boundary mask instead of segment masks. Default is false.',
659
+ )
660
+ boundaryThickness: Optional[float] = Field(
661
+ None,
662
+ description='Thickness of the boundary masks. Only used if showAsBoundaries is true.',
663
+ )
664
+ randomColorSeed: Optional[float] = Field(
665
+ None,
666
+ description='Random seed for the random color lut (e.g. glasbey) to reproduce the exact colors of the view. (Optional)',
667
+ )
668
+ selectionColor: Optional[SelectionColor] = None
669
+
670
+
671
+ class SegmentationDisplay(BaseModel):
672
+ """
673
+ Viewer state for a group of segmentation sources.
674
+ """
675
+
676
+ model_config = ConfigDict(
677
+ extra='forbid',
678
+ )
679
+ segmentationDisplay: SegmentationDisplay1 = Field(..., description='')
680
+
681
+
682
+ class RegionDisplay1(BaseModel):
683
+ model_config = ConfigDict(
684
+ extra='forbid',
685
+ use_enum_values=True,
686
+ )
687
+ name: Name
688
+ sources: MapOfSources = Field(
689
+ ...,
690
+ description='Map of region_ids (first table column) to source per location.',
691
+ )
692
+ tableSource: Optional[Name] = None
693
+ additionalTables: Optional[AdditionalTables] = None
694
+ lut: Lut
695
+ colorByColumn: Optional[Name] = Field(
696
+ None,
697
+ description="Name of table column that is used for coloring. By default the 'region_id' column is used.",
698
+ )
699
+ opacity: Opacity
700
+ opacityNotSelected: Optional[OpacityNotSelected] = None
701
+ valueLimits: Optional[ValueLimits] = None
702
+ selectedRegionIds: Optional[List[constr(pattern=r'^\d+;[^;\/ ]+$')]] = Field(
703
+ None,
704
+ description='List of selected source region ids, each of the form timePoint;region_id',
705
+ )
706
+ scatterPlotAxes: Optional[ScatterPlotAxes] = None
707
+ showScatterPlot: Optional[bool] = Field(
708
+ None,
709
+ description="Whether to show the scatter plot. The default is 'false', i.e. if this property is not present the scatter plot should not be shown.",
710
+ )
711
+ showTable: Optional[bool] = Field(
712
+ None, description='Show the table GUI element. Default is true.'
713
+ )
714
+ visible: Optional[bool] = Field(
715
+ None,
716
+ description='Is the color overlay of this display visible? Default is true.',
717
+ )
718
+ showAsBoundaries: Optional[bool] = Field(
719
+ None,
720
+ description='Show boundary mask instead of region masks. Default is false.',
721
+ )
722
+ boundaryThickness: Optional[float] = Field(
723
+ None,
724
+ description='Thickness of the boundary masks. Only used if showAsBoundaries is true.',
725
+ )
726
+ boundaryThicknessIsRelative: Optional[bool] = Field(
727
+ None,
728
+ description='Whether the boundary thicknes is given relative to the region size, or in absolute units (default: False)',
729
+ )
730
+ randomColorSeed: Optional[float] = Field(
731
+ None,
732
+ description='Random seed for the random color lut (e.g. glasbey) to reproduce the exact colors of the view. (Optional)',
733
+ )
734
+ selectionColor: Optional[SelectionColor] = None
735
+
736
+
737
+ class RegionDisplay(BaseModel):
738
+ """
739
+ Viewer state for a spatial arrangement of sources, e.g. via grid transform, with an associated table.
740
+ """
741
+
742
+ model_config = ConfigDict(
743
+ extra='forbid',
744
+ )
745
+ regionDisplay: RegionDisplay1
746
+
747
+
748
+ class SpotDisplay1(BaseModel):
749
+ model_config = ConfigDict(
750
+ extra='forbid',
751
+ use_enum_values=True,
752
+ )
753
+ opacity: Opacity
754
+ opacityNotSelected: Optional[OpacityNotSelected] = None
755
+ lut: Lut
756
+ colorByColumn: Optional[Name] = Field(
757
+ None,
758
+ description="Name of table column that is used for coloring. By default the 'label_id' column is used.",
759
+ )
760
+ name: Name = Field(..., description='Name of this spot display.')
761
+ scatterPlotAxes: Optional[ScatterPlotAxes] = None
762
+ selectedSpotIds: Optional[List[constr(pattern=r'^[^; \/]+;\d+;\d+$')]] = Field(
763
+ None,
764
+ description='List of selected segment ids, each of the form sourceName;timePoint;spot_id',
765
+ )
766
+ showScatterPlot: Optional[bool] = Field(
767
+ None,
768
+ description="Whether to show the scatter plot. The default is 'false', i.e. if this property is not present the scatter plot should not be shown. If it is 'true' then 'scatterPlotAxes' must be given.",
769
+ )
770
+ sources: List[Name] = Field(
771
+ ...,
772
+ description='The spot sources that are part of this display group.',
773
+ min_length=1,
774
+ )
775
+ additionalTables: Optional[AdditionalTables] = None
776
+ valueLimits: Optional[ValueLimits] = None
777
+ visible: Optional[bool] = Field(
778
+ None, description='Are the sources of this display visible? Default is true.'
779
+ )
780
+ showTable: Optional[bool] = Field(
781
+ None,
782
+ description='Show the table GUI element. Default is true (if the display has a table).',
783
+ )
784
+ showAsBoundaries: Optional[bool] = Field(
785
+ None,
786
+ description='Show boundary mask instead of segment masks. Default is false.',
787
+ )
788
+ boundaryThickness: Optional[float] = Field(
789
+ None,
790
+ description='Thickness of the boundary masks. Only used if showAsBoundaries is true.',
791
+ )
792
+ randomColorSeed: Optional[float] = Field(
793
+ None,
794
+ description='Random seed for the random color lut (e.g. glasbey) to reproduce the exact colors of the view. (Optional)',
795
+ )
796
+ spotRadius: Optional[float] = Field(
797
+ None,
798
+ description='The radius that is used for rendering the spots. In physical units',
799
+ )
800
+ selectionColor: Optional[SelectionColor] = None
801
+
802
+
803
+ class SpotDisplay(BaseModel):
804
+ """
805
+ Viewer state for a group of spot sources.
806
+ """
807
+
808
+ model_config = ConfigDict(
809
+ extra='forbid',
810
+ )
811
+ spotDisplay: SpotDisplay1 = Field(..., description='')
812
+
813
+
814
+ class Timepoint(RootModel[conint(ge=0)]):
815
+ root: conint(ge=0)
816
+
817
+
818
+ class Affine1(BaseModel):
819
+ """
820
+ Affine transformation applied to a list of sources.
821
+ """
822
+
823
+ model_config = ConfigDict(
824
+ extra='forbid',
825
+ )
826
+ parameters: List[float] = Field(
827
+ ...,
828
+ description='Parameters of the affine transformation, using the BigDataViewer convention.',
829
+ max_length=12,
830
+ min_length=12,
831
+ )
832
+ sources: List[Name] = Field(
833
+ ..., description='The sources this transformation is applied to.', min_length=1
834
+ )
835
+ sourceNamesAfterTransform: Optional[List[Name]] = Field(
836
+ None,
837
+ description='Names of the sources after transformation. If given, must have the same number of elements as `sources`.',
838
+ min_length=1,
839
+ )
840
+ name: Optional[Name] = Field(None, description='Name of this transformation')
841
+ timepoints: Optional[List[Timepoint]] = Field(
842
+ None,
843
+ description='The valid timepoints for this transformation. If none is given, the transformation is valid for all timepoints.',
844
+ min_length=1,
845
+ )
846
+
847
+
848
+ class Affine(BaseModel):
849
+ model_config = ConfigDict(
850
+ extra='forbid',
851
+ )
852
+ affine: Affine1 = Field(
853
+ ..., description='Affine transformation applied to a list of sources.'
854
+ )
855
+
856
+
857
+ class Crop1(BaseModel):
858
+ """
859
+ Crop transformation applied to a list of sources.
860
+ """
861
+
862
+ model_config = ConfigDict(
863
+ extra='forbid',
864
+ )
865
+ boxAffine: Optional[List[float]] = Field(
866
+ None,
867
+ description="The transformation to place the crop's bounding box in the global coordinate system (if not given assumes identity)",
868
+ max_length=12,
869
+ min_length=12,
870
+ )
871
+ min: List[float] = Field(
872
+ ..., description='Minimum coordinates for the crop.', max_length=3, min_length=3
873
+ )
874
+ max: List[float] = Field(
875
+ ..., description='Maximum coordinates for the crop.', max_length=3, min_length=3
876
+ )
877
+ rectify: Optional[bool] = Field(
878
+ None,
879
+ description="Whether to align the crop's bounding box with the coordinate system. By default true.",
880
+ )
881
+ sources: List[Name] = Field(
882
+ ..., description='The sources this transformation is applied to.', min_length=1
883
+ )
884
+ sourceNamesAfterTransform: Optional[List[Name]] = Field(
885
+ None,
886
+ description='Names of the sources after transformation. If given, must have the same number of elements as `sources`.',
887
+ min_length=1,
888
+ )
889
+ name: Optional[Name] = Field(None, description='Name of this transformation')
890
+ timepoints: Optional[List[Timepoint]] = Field(
891
+ None,
892
+ description='The valid timepoints for this transformation. If none is given, the transformation is valid for all timepoints.',
893
+ min_length=1,
894
+ )
895
+ centerAtOrigin: Optional[bool] = Field(
896
+ None,
897
+ description='Whether to center the source at the coordinate space origin after applying the crop. By default true.',
898
+ )
899
+
900
+
901
+ class Crop(BaseModel):
902
+ model_config = ConfigDict(
903
+ extra='forbid',
904
+ )
905
+ crop: Crop1 = Field(
906
+ ..., description='Crop transformation applied to a list of sources.'
907
+ )
908
+
909
+
910
+ class MergedGrid1(BaseModel):
911
+ """
912
+ A grid view of multiple sources that creates an new merged source. Only valid if all sources have the same size (both in pixels and physical space).
913
+ """
914
+
915
+ model_config = ConfigDict(
916
+ extra='allow',
917
+ )
918
+ sources: List[Name] = Field(
919
+ ...,
920
+ description='The sources this transformation is applied to. After transformation all sources will get the name `<sourceName>_<mergedGridSourceName>`. `<sourceName>` still refers to the source befor transformation (useful e.g. for specifying a metadataSource)',
921
+ min_length=2,
922
+ )
923
+ positions: Optional[Positions] = None
924
+ mergedGridSourceName: Name
925
+ metadataSource: Optional[str] = Field(
926
+ None,
927
+ description='Name of the source to be used as reference to load the metadata for all sources in this transformation. This can decrease the load time significantly for large grids. Note that the image related metadata (shape, datatype, etc.) must exactly match.',
928
+ )
929
+ margin: Optional[float] = Field(
930
+ None,
931
+ description='The margin to add around a position in the grid. By default a fraction of 0.1 of the position size will be used.',
932
+ )
933
+
934
+
935
+ class MergedGrid(BaseModel):
936
+ model_config = ConfigDict(
937
+ extra='forbid',
938
+ )
939
+ mergedGrid: MergedGrid1 = Field(
940
+ ...,
941
+ description='A grid view of multiple sources that creates an new merged source. Only valid if all sources have the same size (both in pixels and physical space).',
942
+ )
943
+
944
+
945
+ class Parameter(RootModel[List[int]]):
946
+ root: List[int]
947
+
948
+
949
+ class Timepoints1(BaseModel):
950
+ """
951
+ Move sources to different timepoints.
952
+ """
953
+
954
+ sources: List[Name] = Field(
955
+ ..., description='The sources this transformation is applied to.', min_length=1
956
+ )
957
+ parameters: List[Parameter] = Field(
958
+ ...,
959
+ description='List of the timepoint shifts. The list contains elements of size 2, the first entry gives the new timepoint (where the source is moved to), the second the old one (where it comes from). The first entries must be unique across the whole list, the second entries may be duplicated.',
960
+ min_length=1,
961
+ )
962
+ sourceNamesAfterTransform: Optional[List[Name]] = Field(
963
+ None,
964
+ description='Names of the sources after transformation. If given, must have the same number of elements as `sources`.',
965
+ min_length=1,
966
+ )
967
+ name: Optional[Name] = Field(None, description='Name of this transformation')
968
+ keep: Optional[bool] = Field(
969
+ None,
970
+ description='Whether to keep timepoints that are not transformed, or to only display timepoints that are explicitly given in the transformation.',
971
+ )
972
+
973
+
974
+ class Timepoints(BaseModel):
975
+ model_config = ConfigDict(
976
+ extra='forbid',
977
+ )
978
+ timepoints: Timepoints1 = Field(
979
+ ..., description='Move sources to different timepoints.'
980
+ )
981
+
982
+
983
+ class TransformedGrid1(BaseModel):
984
+ """
985
+ Arrange multiple sources in a grid by offseting sources with a grid spacing.
986
+ """
987
+
988
+ model_config = ConfigDict(
989
+ extra='forbid',
990
+ )
991
+ positions: Optional[Positions] = None
992
+ nestedSources: NestedListOfSources = Field(
993
+ ...,
994
+ description='The sources for the grid. Map of grid posititions to sources per position.',
995
+ )
996
+ sourceNamesAfterTransform: Optional[NestedListOfSources] = Field(
997
+ None,
998
+ description='Names of the sources after transformation. If given, must have the same structure as `sources`.',
999
+ )
1000
+ name: Optional[Name] = Field(None, description='Name of this transformation')
1001
+ timepoints: Optional[List[int]] = Field(
1002
+ None,
1003
+ description='The valid timepoints for this transformation. If none is given, the transformation is valid for all timepoints.',
1004
+ min_length=1,
1005
+ )
1006
+ centerAtOrigin: Optional[bool] = Field(
1007
+ None, description='Center the views at the origin for 3d sources.'
1008
+ )
1009
+ margin: Optional[float] = Field(
1010
+ None,
1011
+ description='The margin to add around a position in the grid. By default a fraction of 0.1 of the position size will be used.',
1012
+ )
1013
+
1014
+
1015
+ class TransformedGrid(BaseModel):
1016
+ model_config = ConfigDict(
1017
+ extra='forbid',
1018
+ )
1019
+ transformedGrid: TransformedGrid1 = Field(
1020
+ ...,
1021
+ description='Arrange multiple sources in a grid by offseting sources with a grid spacing.',
1022
+ )
1023
+
1024
+
1025
+ class ViewerTransform1(BaseModel):
1026
+ """
1027
+ A viewer transform to specify position, rotation, timepoint and/or zoom.
1028
+ """
1029
+
1030
+ model_config = ConfigDict(
1031
+ extra='forbid',
1032
+ )
1033
+ timepoint: conint(ge=0) = Field(
1034
+ ..., description='The initial timepoint shown in the viewer.'
1035
+ )
1036
+
1037
+
1038
+ class ViewerTransform2(BaseModel):
1039
+ """
1040
+ A viewer transform to specify position, rotation, timepoint and/or zoom.
1041
+ """
1042
+
1043
+ model_config = ConfigDict(
1044
+ extra='forbid',
1045
+ )
1046
+ normalVector: List[float] = Field(
1047
+ ...,
1048
+ description='The normal vector to the view plane.',
1049
+ max_length=3,
1050
+ min_length=3,
1051
+ )
1052
+ timepoint: Optional[conint(ge=0)] = Field(
1053
+ None, description='The initial timepoint shown in the viewer.'
1054
+ )
1055
+
1056
+
1057
+ class ViewerTransform3(BaseModel):
1058
+ """
1059
+ A viewer transform to specify position, rotation, timepoint and/or zoom.
1060
+ """
1061
+
1062
+ model_config = ConfigDict(
1063
+ extra='forbid',
1064
+ )
1065
+ affine: List[float] = Field(
1066
+ ...,
1067
+ description='Affine transformation applied by the viewer.',
1068
+ max_length=12,
1069
+ min_length=12,
1070
+ )
1071
+ timepoint: Optional[conint(ge=0)] = Field(
1072
+ None, description='The initial timepoint shown in the viewer.'
1073
+ )
1074
+
1075
+
1076
+ class ViewerTransform4(BaseModel):
1077
+ """
1078
+ A viewer transform to specify position, rotation, timepoint and/or zoom.
1079
+ """
1080
+
1081
+ model_config = ConfigDict(
1082
+ extra='forbid',
1083
+ )
1084
+ normalizedAffine: List[float] = Field(
1085
+ ...,
1086
+ description='Normalized affine transformation applied by the viewer.',
1087
+ max_length=12,
1088
+ min_length=12,
1089
+ )
1090
+ timepoint: Optional[conint(ge=0)] = Field(
1091
+ None, description='The initial timepoint shown in the viewer.'
1092
+ )
1093
+
1094
+
1095
+ class PositionItem(RootModel[confloat(ge=0.0)]):
1096
+ root: confloat(ge=0.0)
1097
+
1098
+
1099
+ class ViewerTransform5(BaseModel):
1100
+ """
1101
+ A viewer transform to specify position, rotation, timepoint and/or zoom.
1102
+ """
1103
+
1104
+ model_config = ConfigDict(
1105
+ extra='forbid',
1106
+ )
1107
+ position: List[PositionItem] = Field(
1108
+ ...,
1109
+ description='Position that will be centered in the viewer.',
1110
+ max_length=3,
1111
+ min_length=3,
1112
+ )
1113
+ timepoint: Optional[conint(ge=0)] = Field(
1114
+ None, description='The initial timepoint shown in the viewer.'
1115
+ )
1116
+
1117
+
1118
+ class ViewerTransform(
1119
+ RootModel[
1120
+ Union[
1121
+ ViewerTransform1,
1122
+ ViewerTransform2,
1123
+ ViewerTransform3,
1124
+ ViewerTransform4,
1125
+ ViewerTransform5,
1126
+ ]
1127
+ ]
1128
+ ):
1129
+ root: Union[
1130
+ ViewerTransform1,
1131
+ ViewerTransform2,
1132
+ ViewerTransform3,
1133
+ ViewerTransform4,
1134
+ ViewerTransform5,
1135
+ ] = Field(
1136
+ ...,
1137
+ description='A viewer transform to specify position, rotation, timepoint and/or zoom.',
1138
+ )
1139
+
1140
+
1141
+ class MoBIESourceSchema(BaseModel):
1142
+ """
1143
+ Schema describing a MoBIE source
1144
+ """
1145
+
1146
+ model_config = ConfigDict(
1147
+ extra='forbid',
1148
+ )
1149
+ image: ImageSource
1150
+
1151
+
1152
+ class MoBIESourceSchema1(BaseModel):
1153
+ """
1154
+ Schema describing a MoBIE source
1155
+ """
1156
+
1157
+ model_config = ConfigDict(
1158
+ extra='forbid',
1159
+ )
1160
+ segmentation: SegmentationSource
1161
+
1162
+
1163
+ class MoBIESourceSchema2(BaseModel):
1164
+ """
1165
+ Schema describing a MoBIE source
1166
+ """
1167
+
1168
+ model_config = ConfigDict(
1169
+ extra='forbid',
1170
+ )
1171
+ spots: SpotSource
1172
+
1173
+
1174
+ class MoBIESourceSchema3(BaseModel):
1175
+ """
1176
+ Schema describing a MoBIE source
1177
+ """
1178
+
1179
+ model_config = ConfigDict(
1180
+ extra='forbid',
1181
+ )
1182
+ regions: RegionSource
1183
+
1184
+
1185
+ class View(BaseModel):
1186
+ """
1187
+ Schema for serializing the MoBIE viewer state
1188
+ """
1189
+
1190
+ model_config = ConfigDict(
1191
+ extra='forbid',
1192
+ )
1193
+ uiSelectionGroup: Name = Field(
1194
+ ..., description='Name of the UI from which this view can be selected.'
1195
+ )
1196
+ isExclusive: bool = Field(
1197
+ ...,
1198
+ description='Does this view replace the current viewer state (exclusive) or is it added to it (additive)?',
1199
+ )
1200
+ description: Optional[str] = Field(
1201
+ None,
1202
+ description='Description of this view. Will be displayed when the view is loaded.',
1203
+ )
1204
+ sourceDisplays: Optional[
1205
+ List[Union[ImageDisplay, SegmentationDisplay, SpotDisplay, RegionDisplay]]
1206
+ ] = Field(None, description='The display groups of this view.')
1207
+ sourceTransforms: Optional[
1208
+ List[Union[Affine, Crop, MergedGrid, Timepoints, TransformedGrid]]
1209
+ ] = Field(
1210
+ None,
1211
+ description='The source transformations of this view. The transformations must be defined in the physical coordinate space and are applied in addition to the transformations given in the bdv.xml.',
1212
+ )
1213
+ viewerTransform: Optional[ViewerTransform] = None
1214
+
1215
+
1216
+ class Dataset(BaseModel):
1217
+ """
1218
+ Schema describing a MoBIE dataset
1219
+ """
1220
+
1221
+ model_config = ConfigDict(
1222
+ extra='forbid',
1223
+ validate_assignment=True,
1224
+ )
1225
+ is2D: bool
1226
+ description: Optional[str] = Field(None, description='Description of the dataset')
1227
+ sources: Dict[str, Source] = Field(
1228
+ ..., description='The list of sources in this dataset.'
1229
+ )
1230
+ views: Dict[str, View] = Field(
1231
+ ..., description='The list of views in this dataset.'
1232
+ )
1233
+ defaultLocation: Optional[ViewerTransform] = Field(
1234
+ None,
1235
+ description="Default location for the 'location' menu in the viewer. Must be a valid viewer transform. If none is given the menu will be empty.",
1236
+ )
1237
+
1238
+ @field_validator('views')
1239
+ @classmethod
1240
+ def validate_default_item(cls, views: Dict[str, View]):
1241
+ if 'default' not in views:
1242
+ message = "The 'views' list must contain a view named 'default'"
1243
+ raise ValueError(message)
1244
+ return views
1245
+
1246
+
1247
+ class Source(
1248
+ RootModel[
1249
+ Union[
1250
+ MoBIESourceSchema,
1251
+ MoBIESourceSchema1,
1252
+ MoBIESourceSchema2,
1253
+ MoBIESourceSchema3,
1254
+ ]
1255
+ ]
1256
+ ):
1257
+ root: Union[
1258
+ MoBIESourceSchema, MoBIESourceSchema1, MoBIESourceSchema2, MoBIESourceSchema3
1259
+ ] = Field(
1260
+ ..., description='Schema describing a MoBIE source', title='MoBIESourceSchema'
1261
+ )
1262
+
1263
+
1264
+ class Project(BaseModel):
1265
+ """
1266
+ Schema describing a MoBIE project
1267
+ """
1268
+
1269
+ model_config = ConfigDict(
1270
+ extra='forbid',
1271
+ validate_assignment=True,
1272
+ )
1273
+ datasets: List[Name] = Field(
1274
+ ..., description='The list of datasets available in this project.'
1275
+ )
1276
+ defaultDataset: str = Field(
1277
+ ..., description='The default dataset for this project.'
1278
+ )
1279
+ description: Optional[str] = None
1280
+ references: Optional[List[str]] = Field(
1281
+ None, description='Publication or other references for this project'
1282
+ )
1283
+ specVersion: constr(pattern=r'0\.3\.\d+') = Field(
1284
+ ..., description='The MoBIE spec version of this project.'
1285
+ )