@vitessce/vit-s 3.1.3 → 3.2.0

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.
Files changed (46) hide show
  1. package/dist/index.js +1673 -130
  2. package/dist-tsc/data-hook-utils.d.ts +1 -0
  3. package/dist-tsc/data-hook-utils.d.ts.map +1 -1
  4. package/dist-tsc/data-hook-utils.js +12 -4
  5. package/dist-tsc/data-hooks-multilevel-utils.d.ts +77 -0
  6. package/dist-tsc/data-hooks-multilevel-utils.d.ts.map +1 -0
  7. package/dist-tsc/data-hooks-multilevel-utils.js +418 -0
  8. package/dist-tsc/data-hooks-multilevel-utils.test.d.ts +2 -0
  9. package/dist-tsc/data-hooks-multilevel-utils.test.d.ts.map +1 -0
  10. package/dist-tsc/data-hooks-multilevel-utils.test.js +101 -0
  11. package/dist-tsc/data-hooks-multilevel.d.ts +8 -0
  12. package/dist-tsc/data-hooks-multilevel.d.ts.map +1 -0
  13. package/dist-tsc/data-hooks-multilevel.js +125 -0
  14. package/dist-tsc/data-hooks.d.ts +7 -0
  15. package/dist-tsc/data-hooks.d.ts.map +1 -1
  16. package/dist-tsc/data-hooks.js +75 -6
  17. package/dist-tsc/hooks.js +1 -1
  18. package/dist-tsc/index.d.ts +3 -2
  19. package/dist-tsc/index.js +3 -2
  20. package/dist-tsc/shared-mui/components.d.ts.map +1 -1
  21. package/dist-tsc/shared-mui/components.js +3 -2
  22. package/dist-tsc/state/hooks.d.ts +80 -21
  23. package/dist-tsc/state/hooks.d.ts.map +1 -1
  24. package/dist-tsc/state/hooks.js +428 -103
  25. package/dist-tsc/state/hooks.test.d.ts +2 -0
  26. package/dist-tsc/state/hooks.test.d.ts.map +1 -0
  27. package/dist-tsc/state/hooks.test.js +149 -0
  28. package/dist-tsc/state/spatial-reducers.d.ts +25 -0
  29. package/dist-tsc/state/spatial-reducers.d.ts.map +1 -0
  30. package/dist-tsc/state/spatial-reducers.js +251 -0
  31. package/dist-tsc/state/spatial-reducers.test.d.ts +2 -0
  32. package/dist-tsc/state/spatial-reducers.test.d.ts.map +1 -0
  33. package/dist-tsc/state/spatial-reducers.test.js +1382 -0
  34. package/package.json +5 -5
  35. package/src/data-hook-utils.js +19 -3
  36. package/src/data-hooks-multilevel-utils.js +571 -0
  37. package/src/data-hooks-multilevel-utils.test.js +110 -0
  38. package/src/data-hooks-multilevel.js +226 -0
  39. package/src/data-hooks.js +156 -6
  40. package/src/hooks.js +1 -1
  41. package/src/index.js +25 -0
  42. package/src/shared-mui/components.js +9 -4
  43. package/src/state/hooks.js +485 -104
  44. package/src/state/hooks.test.js +182 -0
  45. package/src/state/spatial-reducers.js +291 -0
  46. package/src/state/spatial-reducers.test.js +1432 -0
@@ -0,0 +1,1432 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import {
3
+ getMetaScope,
4
+ getMetaScopeBy,
5
+ removeImageChannelInMetaCoordinationScopesHelper,
6
+ addImageChannelInMetaCoordinationScopesHelper,
7
+ } from './spatial-reducers.js';
8
+
9
+ describe('spatial-reducers.js', () => {
10
+ describe('getMetaScope', () => {
11
+ it('works without metaCoordinationScopes', () => {
12
+ expect(getMetaScope(
13
+ {
14
+ obsType: 'A',
15
+ },
16
+ {
17
+ obsType: {
18
+ A: 'cell',
19
+ B: 'molecule',
20
+ },
21
+ },
22
+ 'obsType',
23
+ )).toEqual(undefined);
24
+ });
25
+ it('works with one metaCoordinationScopes', () => {
26
+ expect(getMetaScope(
27
+ {
28
+ // meta match should take precedence
29
+ metaCoordinationScopes: 'metaA',
30
+ obsType: 'A',
31
+ },
32
+ {
33
+ obsType: {
34
+ A: 'cell',
35
+ B: 'molecule',
36
+ },
37
+ metaCoordinationScopes: {
38
+ metaA: {
39
+ obsType: 'B',
40
+ },
41
+ },
42
+ },
43
+ 'obsType',
44
+ )).toEqual('metaA');
45
+ });
46
+ it('works with multiple metaCoordinationScopes', () => {
47
+ expect(getMetaScope(
48
+ {
49
+ // first meta match should take precedence
50
+ metaCoordinationScopes: ['metaA', 'metaB'],
51
+ obsType: 'A',
52
+ },
53
+ {
54
+ obsType: {
55
+ A: 'cell',
56
+ B: 'molecule',
57
+ },
58
+ metaCoordinationScopes: {
59
+ metaA: {
60
+ featureType: 'D',
61
+ },
62
+ metaB: {
63
+ obsType: 'C',
64
+ },
65
+ },
66
+ },
67
+ 'obsType',
68
+ )).toEqual('metaB');
69
+ });
70
+ });
71
+ describe('getMetaScopeBy', () => {
72
+ it('works with one metaCoordinationScopesBy', () => {
73
+ expect(getMetaScopeBy(
74
+ {
75
+ metaCoordinationScopesBy: 'metaA',
76
+ spatialSegmentationLayer: ['abc', 'def'],
77
+ },
78
+ {
79
+ spatialSegmentationLayer: {
80
+ glomerulus: 'glomerulus',
81
+ tubule: 'tubule',
82
+ },
83
+ spatialTargetC: {
84
+ A: 1,
85
+ B: 2,
86
+ },
87
+ metaCoordinationScopesBy: {
88
+ metaA: {
89
+ spatialSegmentationLayer: {
90
+ spatialTargetC: {
91
+ glomerulus: 'A',
92
+ tubule: 'B',
93
+ },
94
+ },
95
+ },
96
+ },
97
+ },
98
+ 'spatialSegmentationLayer',
99
+ 'spatialTargetC',
100
+ 'glomerulus',
101
+ )).toEqual('metaA');
102
+ });
103
+ it('works with multiple metaCoordinationScopes', () => {
104
+ expect(getMetaScopeBy(
105
+ {
106
+ metaCoordinationScopesBy: ['metaA', 'metaB'],
107
+ spatialSegmentationLayer: ['abc', 'def'],
108
+ },
109
+ {
110
+ spatialSegmentationLayer: {
111
+ glomerulus: 'glomerulus',
112
+ tubule: 'tubule',
113
+ },
114
+ spatialTargetC: {
115
+ A: 1,
116
+ B: 2,
117
+ },
118
+ metaCoordinationScopesBy: {
119
+ metaA: {
120
+ spatialSegmentationLayer: {
121
+ spatialLayerOpacity: {
122
+ glomerulus: 'C',
123
+ tubule: 'D',
124
+ },
125
+ },
126
+ },
127
+ metaB: {
128
+ spatialSegmentationLayer: {
129
+ spatialTargetC: {
130
+ glomerulus: 'A',
131
+ tubule: 'B',
132
+ },
133
+ },
134
+ },
135
+ },
136
+ },
137
+ 'spatialSegmentationLayer',
138
+ 'spatialLayerOpacity',
139
+ 'tubule',
140
+ )).toEqual('metaA');
141
+ });
142
+ });
143
+ describe('removeImageChannelInMetaCoordinationScopesHelper', () => {
144
+ it('removes the blue channel from an RGB image when image channels are per-image-layer', () => {
145
+ const coordinationScopesRaw = {
146
+ metaCoordinationScopes: [
147
+ 'metaA',
148
+ ],
149
+ metaCoordinationScopesBy: [
150
+ 'metaA',
151
+ ],
152
+ spatialTargetX: 'A',
153
+ spatialTargetY: 'A',
154
+ spatialZoom: 'A',
155
+ dataset: 'A',
156
+ image: 'A',
157
+ imageChannel: 'A',
158
+ spatialTargetC: 'A',
159
+ spatialLayerVisible: 'A',
160
+ spatialLayerOpacity: 'A',
161
+ spatialLayerColormap: 'A',
162
+ spatialChannelVisible: 'A',
163
+ spatialChannelOpacity: 'A',
164
+ spatialChannelWindow: 'A',
165
+ spatialChannelColor: 'A',
166
+ photometricInterpretation: 'A',
167
+ };
168
+ const layerScope = 'histology';
169
+ const channelScope = 'B';
170
+ const coordinationSpace = {
171
+ metaCoordinationScopes: {
172
+ metaA: {
173
+ imageLayer: [
174
+ 'histology',
175
+ ],
176
+ },
177
+ },
178
+ metaCoordinationScopesBy: {
179
+ metaA: {
180
+ imageLayer: {
181
+ image: {
182
+ histology: 'rgb',
183
+ },
184
+ imageChannel: {
185
+ histology: [
186
+ 'R',
187
+ 'G',
188
+ 'B',
189
+ ],
190
+ },
191
+ spatialLayerVisible: {
192
+ histology: 'image',
193
+ },
194
+ spatialLayerOpacity: {
195
+ histology: 'image',
196
+ },
197
+ photometricInterpretation: {
198
+ histology: 'rgb',
199
+ },
200
+ },
201
+ imageChannel: {
202
+ spatialTargetC: {
203
+ R: 'imageR',
204
+ G: 'imageG',
205
+ B: 'imageB',
206
+ },
207
+ spatialChannelColor: {
208
+ R: 'imageR',
209
+ G: 'imageG',
210
+ B: 'imageB',
211
+ },
212
+ spatialChannelVisible: {
213
+ R: 'imageR',
214
+ G: 'imageG',
215
+ B: 'imageB',
216
+ },
217
+ spatialChannelOpacity: {
218
+ R: 'imageR',
219
+ G: 'imageG',
220
+ B: 'imageB',
221
+ },
222
+ spatialChannelWindow: {
223
+ R: 'imageR',
224
+ G: 'imageG',
225
+ B: 'imageB',
226
+ },
227
+ },
228
+ },
229
+ },
230
+ spatialZoom: {
231
+ A: -4,
232
+ },
233
+ spatialTargetX: {
234
+ A: 10,
235
+ },
236
+ spatialTargetY: {
237
+ A: 20,
238
+ },
239
+ image: {
240
+ rgb: 'S-1905-017737_bf',
241
+ },
242
+ imageLayer: {
243
+ histology: 'histology',
244
+ },
245
+ imageChannel: {
246
+ R: 'R',
247
+ G: 'G',
248
+ B: 'B',
249
+ },
250
+ spatialTargetC: {
251
+ imageR: 0,
252
+ imageG: 1,
253
+ imageB: 2,
254
+ },
255
+ spatialLayerVisible: {
256
+ image: true,
257
+ },
258
+ spatialLayerOpacity: {
259
+ image: 1,
260
+ },
261
+ spatialChannelVisible: {
262
+ imageR: true,
263
+ imageG: true,
264
+ imageB: true,
265
+ },
266
+ spatialChannelOpacity: {
267
+ imageR: 1,
268
+ imageG: 1,
269
+ imageB: 1,
270
+ },
271
+ spatialChannelWindow: {
272
+ imageR: [
273
+ 0,
274
+ 255,
275
+ ],
276
+ imageG: [
277
+ 0,
278
+ 255,
279
+ ],
280
+ imageB: [
281
+ 0,
282
+ 255,
283
+ ],
284
+ },
285
+ spatialChannelColor: {
286
+ imageR: [
287
+ 255,
288
+ 0,
289
+ 0,
290
+ ],
291
+ imageG: [
292
+ 0,
293
+ 255,
294
+ 0,
295
+ ],
296
+ imageB: [
297
+ 0,
298
+ 0,
299
+ 255,
300
+ ],
301
+ },
302
+ photometricInterpretation: {
303
+ rgb: 'RGB',
304
+ },
305
+ dataset: {
306
+ A: 'S-1905-017737',
307
+ },
308
+ spatialLayerColormap: {
309
+ A: null,
310
+ },
311
+ };
312
+ const newCoordinationSpace = removeImageChannelInMetaCoordinationScopesHelper(
313
+ coordinationScopesRaw,
314
+ layerScope,
315
+ channelScope,
316
+ coordinationSpace,
317
+ );
318
+ expect(newCoordinationSpace).toEqual({
319
+ metaCoordinationScopes: {
320
+ metaA: {
321
+ imageLayer: [
322
+ 'histology',
323
+ ],
324
+ },
325
+ },
326
+ metaCoordinationScopesBy: {
327
+ metaA: {
328
+ imageLayer: {
329
+ image: {
330
+ histology: 'rgb',
331
+ },
332
+ imageChannel: {
333
+ histology: [
334
+ // The important part
335
+ 'R',
336
+ 'G',
337
+ ],
338
+ },
339
+ spatialLayerVisible: {
340
+ histology: 'image',
341
+ },
342
+ spatialLayerOpacity: {
343
+ histology: 'image',
344
+ },
345
+ photometricInterpretation: {
346
+ histology: 'rgb',
347
+ },
348
+ },
349
+ imageChannel: {
350
+ spatialTargetC: {
351
+ R: 'imageR',
352
+ G: 'imageG',
353
+ B: 'imageB',
354
+ },
355
+ spatialChannelColor: {
356
+ R: 'imageR',
357
+ G: 'imageG',
358
+ B: 'imageB',
359
+ },
360
+ spatialChannelVisible: {
361
+ R: 'imageR',
362
+ G: 'imageG',
363
+ B: 'imageB',
364
+ },
365
+ spatialChannelOpacity: {
366
+ R: 'imageR',
367
+ G: 'imageG',
368
+ B: 'imageB',
369
+ },
370
+ spatialChannelWindow: {
371
+ R: 'imageR',
372
+ G: 'imageG',
373
+ B: 'imageB',
374
+ },
375
+ },
376
+ },
377
+ },
378
+ spatialZoom: {
379
+ A: -4,
380
+ },
381
+ spatialTargetX: {
382
+ A: 10,
383
+ },
384
+ spatialTargetY: {
385
+ A: 20,
386
+ },
387
+ image: {
388
+ rgb: 'S-1905-017737_bf',
389
+ },
390
+ imageLayer: {
391
+ histology: 'histology',
392
+ },
393
+ imageChannel: {
394
+ R: 'R',
395
+ G: 'G',
396
+ B: 'B',
397
+ },
398
+ spatialTargetC: {
399
+ imageR: 0,
400
+ imageG: 1,
401
+ imageB: 2,
402
+ },
403
+ spatialLayerVisible: {
404
+ image: true,
405
+ },
406
+ spatialLayerOpacity: {
407
+ image: 1,
408
+ },
409
+ spatialChannelVisible: {
410
+ imageR: true,
411
+ imageG: true,
412
+ imageB: true,
413
+ },
414
+ spatialChannelOpacity: {
415
+ imageR: 1,
416
+ imageG: 1,
417
+ imageB: 1,
418
+ },
419
+ spatialChannelWindow: {
420
+ imageR: [
421
+ 0,
422
+ 255,
423
+ ],
424
+ imageG: [
425
+ 0,
426
+ 255,
427
+ ],
428
+ imageB: [
429
+ 0,
430
+ 255,
431
+ ],
432
+ },
433
+ spatialChannelColor: {
434
+ imageR: [
435
+ 255,
436
+ 0,
437
+ 0,
438
+ ],
439
+ imageG: [
440
+ 0,
441
+ 255,
442
+ 0,
443
+ ],
444
+ imageB: [
445
+ 0,
446
+ 0,
447
+ 255,
448
+ ],
449
+ },
450
+ photometricInterpretation: {
451
+ rgb: 'RGB',
452
+ },
453
+ dataset: {
454
+ A: 'S-1905-017737',
455
+ },
456
+ spatialLayerColormap: {
457
+ A: null,
458
+ },
459
+ });
460
+ });
461
+ it('removes the blue channel from an RGB image when image channels are per-view', () => {
462
+ const coordinationScopesRaw = {
463
+ metaCoordinationScopes: [
464
+ 'metaA',
465
+ ],
466
+ metaCoordinationScopesBy: [
467
+ 'metaA',
468
+ ],
469
+ spatialTargetX: 'A',
470
+ spatialTargetY: 'A',
471
+ spatialZoom: 'A',
472
+ dataset: 'A',
473
+ image: 'A',
474
+ imageChannel: 'A',
475
+ spatialTargetC: 'A',
476
+ spatialLayerVisible: 'A',
477
+ spatialLayerOpacity: 'A',
478
+ spatialLayerColormap: 'A',
479
+ spatialChannelVisible: 'A',
480
+ spatialChannelOpacity: 'A',
481
+ spatialChannelWindow: 'A',
482
+ spatialChannelColor: 'A',
483
+ photometricInterpretation: 'A',
484
+ };
485
+ const layerScope = 'histology';
486
+ const channelScope = 'B';
487
+ const coordinationSpace = {
488
+ metaCoordinationScopes: {
489
+ metaA: {
490
+ imageLayer: [
491
+ 'histology',
492
+ ],
493
+ imageChannel: [
494
+ 'R', 'G', 'B',
495
+ ],
496
+ },
497
+ },
498
+ metaCoordinationScopesBy: {
499
+ metaA: {
500
+ imageLayer: {
501
+ image: {
502
+ histology: 'rgb',
503
+ },
504
+ spatialLayerVisible: {
505
+ histology: 'image',
506
+ },
507
+ spatialLayerOpacity: {
508
+ histology: 'image',
509
+ },
510
+ photometricInterpretation: {
511
+ histology: 'rgb',
512
+ },
513
+ },
514
+ imageChannel: {
515
+ spatialTargetC: {
516
+ R: 'imageR',
517
+ G: 'imageG',
518
+ B: 'imageB',
519
+ },
520
+ spatialChannelColor: {
521
+ R: 'imageR',
522
+ G: 'imageG',
523
+ B: 'imageB',
524
+ },
525
+ spatialChannelVisible: {
526
+ R: 'imageR',
527
+ G: 'imageG',
528
+ B: 'imageB',
529
+ },
530
+ spatialChannelOpacity: {
531
+ R: 'imageR',
532
+ G: 'imageG',
533
+ B: 'imageB',
534
+ },
535
+ spatialChannelWindow: {
536
+ R: 'imageR',
537
+ G: 'imageG',
538
+ B: 'imageB',
539
+ },
540
+ },
541
+ },
542
+ },
543
+ spatialZoom: {
544
+ A: -4,
545
+ },
546
+ spatialTargetX: {
547
+ A: 10,
548
+ },
549
+ spatialTargetY: {
550
+ A: 20,
551
+ },
552
+ image: {
553
+ rgb: 'S-1905-017737_bf',
554
+ },
555
+ imageLayer: {
556
+ histology: 'histology',
557
+ },
558
+ imageChannel: {
559
+ R: 'R',
560
+ G: 'G',
561
+ B: 'B',
562
+ },
563
+ spatialTargetC: {
564
+ imageR: 0,
565
+ imageG: 1,
566
+ imageB: 2,
567
+ },
568
+ spatialLayerVisible: {
569
+ image: true,
570
+ },
571
+ spatialLayerOpacity: {
572
+ image: 1,
573
+ },
574
+ spatialChannelVisible: {
575
+ imageR: true,
576
+ imageG: true,
577
+ imageB: true,
578
+ },
579
+ spatialChannelOpacity: {
580
+ imageR: 1,
581
+ imageG: 1,
582
+ imageB: 1,
583
+ },
584
+ spatialChannelWindow: {
585
+ imageR: [
586
+ 0,
587
+ 255,
588
+ ],
589
+ imageG: [
590
+ 0,
591
+ 255,
592
+ ],
593
+ imageB: [
594
+ 0,
595
+ 255,
596
+ ],
597
+ },
598
+ spatialChannelColor: {
599
+ imageR: [
600
+ 255,
601
+ 0,
602
+ 0,
603
+ ],
604
+ imageG: [
605
+ 0,
606
+ 255,
607
+ 0,
608
+ ],
609
+ imageB: [
610
+ 0,
611
+ 0,
612
+ 255,
613
+ ],
614
+ },
615
+ photometricInterpretation: {
616
+ rgb: 'RGB',
617
+ },
618
+ dataset: {
619
+ A: 'S-1905-017737',
620
+ },
621
+ spatialLayerColormap: {
622
+ A: null,
623
+ },
624
+ };
625
+ const newCoordinationSpace = removeImageChannelInMetaCoordinationScopesHelper(
626
+ coordinationScopesRaw,
627
+ layerScope,
628
+ channelScope,
629
+ coordinationSpace,
630
+ );
631
+ expect(newCoordinationSpace).toEqual({
632
+ metaCoordinationScopes: {
633
+ metaA: {
634
+ imageLayer: [
635
+ 'histology',
636
+ ],
637
+ imageChannel: [
638
+ 'R', 'G',
639
+ ],
640
+ },
641
+ },
642
+ metaCoordinationScopesBy: {
643
+ metaA: {
644
+ imageLayer: {
645
+ image: {
646
+ histology: 'rgb',
647
+ },
648
+ spatialLayerVisible: {
649
+ histology: 'image',
650
+ },
651
+ spatialLayerOpacity: {
652
+ histology: 'image',
653
+ },
654
+ photometricInterpretation: {
655
+ histology: 'rgb',
656
+ },
657
+ },
658
+ imageChannel: {
659
+ spatialTargetC: {
660
+ R: 'imageR',
661
+ G: 'imageG',
662
+ B: 'imageB',
663
+ },
664
+ spatialChannelColor: {
665
+ R: 'imageR',
666
+ G: 'imageG',
667
+ B: 'imageB',
668
+ },
669
+ spatialChannelVisible: {
670
+ R: 'imageR',
671
+ G: 'imageG',
672
+ B: 'imageB',
673
+ },
674
+ spatialChannelOpacity: {
675
+ R: 'imageR',
676
+ G: 'imageG',
677
+ B: 'imageB',
678
+ },
679
+ spatialChannelWindow: {
680
+ R: 'imageR',
681
+ G: 'imageG',
682
+ B: 'imageB',
683
+ },
684
+ },
685
+ },
686
+ },
687
+ spatialZoom: {
688
+ A: -4,
689
+ },
690
+ spatialTargetX: {
691
+ A: 10,
692
+ },
693
+ spatialTargetY: {
694
+ A: 20,
695
+ },
696
+ image: {
697
+ rgb: 'S-1905-017737_bf',
698
+ },
699
+ imageLayer: {
700
+ histology: 'histology',
701
+ },
702
+ imageChannel: {
703
+ R: 'R',
704
+ G: 'G',
705
+ B: 'B',
706
+ },
707
+ spatialTargetC: {
708
+ imageR: 0,
709
+ imageG: 1,
710
+ imageB: 2,
711
+ },
712
+ spatialLayerVisible: {
713
+ image: true,
714
+ },
715
+ spatialLayerOpacity: {
716
+ image: 1,
717
+ },
718
+ spatialChannelVisible: {
719
+ imageR: true,
720
+ imageG: true,
721
+ imageB: true,
722
+ },
723
+ spatialChannelOpacity: {
724
+ imageR: 1,
725
+ imageG: 1,
726
+ imageB: 1,
727
+ },
728
+ spatialChannelWindow: {
729
+ imageR: [
730
+ 0,
731
+ 255,
732
+ ],
733
+ imageG: [
734
+ 0,
735
+ 255,
736
+ ],
737
+ imageB: [
738
+ 0,
739
+ 255,
740
+ ],
741
+ },
742
+ spatialChannelColor: {
743
+ imageR: [
744
+ 255,
745
+ 0,
746
+ 0,
747
+ ],
748
+ imageG: [
749
+ 0,
750
+ 255,
751
+ 0,
752
+ ],
753
+ imageB: [
754
+ 0,
755
+ 0,
756
+ 255,
757
+ ],
758
+ },
759
+ photometricInterpretation: {
760
+ rgb: 'RGB',
761
+ },
762
+ dataset: {
763
+ A: 'S-1905-017737',
764
+ },
765
+ spatialLayerColormap: {
766
+ A: null,
767
+ },
768
+ });
769
+ });
770
+ });
771
+ describe('addImageChannelInMetaCoordinationScopesHelper', () => {
772
+ it('adds an image channel to an image layer when channels are per-image-layer', () => {
773
+ const coordinationScopesRaw = {
774
+ metaCoordinationScopes: [
775
+ 'metaA',
776
+ ],
777
+ metaCoordinationScopesBy: [
778
+ 'metaA',
779
+ ],
780
+ spatialTargetX: 'A',
781
+ spatialTargetY: 'A',
782
+ spatialZoom: 'A',
783
+ dataset: 'A',
784
+ image: 'A',
785
+ imageChannel: 'A',
786
+ spatialTargetC: 'A',
787
+ spatialLayerVisible: 'A',
788
+ spatialLayerOpacity: 'A',
789
+ spatialLayerColormap: 'A',
790
+ spatialChannelVisible: 'A',
791
+ spatialChannelOpacity: 'A',
792
+ spatialChannelWindow: 'A',
793
+ spatialChannelColor: 'A',
794
+ photometricInterpretation: 'A',
795
+ };
796
+ const layerScope = 'histology';
797
+ const coordinationSpace = {
798
+ metaCoordinationScopes: {
799
+ metaA: {
800
+ imageLayer: [
801
+ 'histology',
802
+ ],
803
+ },
804
+ },
805
+ metaCoordinationScopesBy: {
806
+ metaA: {
807
+ imageLayer: {
808
+ image: {
809
+ histology: 'rgb',
810
+ },
811
+ imageChannel: {
812
+ histology: [
813
+ 'R',
814
+ 'G',
815
+ ],
816
+ },
817
+ spatialLayerVisible: {
818
+ histology: 'image',
819
+ },
820
+ spatialLayerOpacity: {
821
+ histology: 'image',
822
+ },
823
+ photometricInterpretation: {
824
+ histology: 'rgb',
825
+ },
826
+ },
827
+ imageChannel: {
828
+ spatialTargetC: {
829
+ R: 'imageR',
830
+ G: 'imageG',
831
+ B: 'imageB',
832
+ },
833
+ spatialChannelColor: {
834
+ R: 'imageR',
835
+ G: 'imageG',
836
+ B: 'imageB',
837
+ },
838
+ spatialChannelVisible: {
839
+ R: 'imageR',
840
+ G: 'imageG',
841
+ B: 'imageB',
842
+ },
843
+ spatialChannelOpacity: {
844
+ R: 'imageR',
845
+ G: 'imageG',
846
+ B: 'imageB',
847
+ },
848
+ spatialChannelWindow: {
849
+ R: 'imageR',
850
+ G: 'imageG',
851
+ B: 'imageB',
852
+ },
853
+ },
854
+ },
855
+ },
856
+ spatialZoom: {
857
+ A: -4,
858
+ },
859
+ spatialTargetX: {
860
+ A: 10,
861
+ },
862
+ spatialTargetY: {
863
+ A: 20,
864
+ },
865
+ image: {
866
+ rgb: 'S-1905-017737_bf',
867
+ },
868
+ imageLayer: {
869
+ histology: 'histology',
870
+ },
871
+ imageChannel: {
872
+ R: 'R',
873
+ G: 'G',
874
+ B: 'B',
875
+ },
876
+ spatialTargetC: {
877
+ imageR: 0,
878
+ imageG: 1,
879
+ imageB: 2,
880
+ },
881
+ spatialLayerVisible: {
882
+ image: true,
883
+ },
884
+ spatialLayerOpacity: {
885
+ image: 1,
886
+ },
887
+ spatialChannelVisible: {
888
+ imageR: true,
889
+ imageG: true,
890
+ imageB: true,
891
+ },
892
+ spatialChannelOpacity: {
893
+ imageR: 1,
894
+ imageG: 1,
895
+ imageB: 1,
896
+ },
897
+ spatialChannelWindow: {
898
+ imageR: [
899
+ 0,
900
+ 255,
901
+ ],
902
+ imageG: [
903
+ 0,
904
+ 255,
905
+ ],
906
+ imageB: [
907
+ 0,
908
+ 255,
909
+ ],
910
+ },
911
+ spatialChannelColor: {
912
+ imageR: [
913
+ 255,
914
+ 0,
915
+ 0,
916
+ ],
917
+ imageG: [
918
+ 0,
919
+ 255,
920
+ 0,
921
+ ],
922
+ imageB: [
923
+ 0,
924
+ 0,
925
+ 255,
926
+ ],
927
+ },
928
+ photometricInterpretation: {
929
+ rgb: 'RGB',
930
+ },
931
+ dataset: {
932
+ A: 'S-1905-017737',
933
+ },
934
+ spatialLayerColormap: {
935
+ A: null,
936
+ },
937
+ };
938
+ const newCoordinationSpace = addImageChannelInMetaCoordinationScopesHelper(
939
+ coordinationScopesRaw,
940
+ layerScope,
941
+ coordinationSpace,
942
+ );
943
+ expect(newCoordinationSpace).toEqual({
944
+ metaCoordinationScopes: {
945
+ metaA: {
946
+ imageLayer: [
947
+ 'histology',
948
+ ],
949
+ },
950
+ },
951
+ metaCoordinationScopesBy: {
952
+ metaA: {
953
+ imageLayer: {
954
+ image: {
955
+ histology: 'rgb',
956
+ },
957
+ imageChannel: {
958
+ histology: [
959
+ 'R',
960
+ 'G',
961
+ 'A',
962
+ ],
963
+ },
964
+ spatialLayerVisible: {
965
+ histology: 'image',
966
+ },
967
+ spatialLayerOpacity: {
968
+ histology: 'image',
969
+ },
970
+ photometricInterpretation: {
971
+ histology: 'rgb',
972
+ },
973
+ },
974
+ imageChannel: {
975
+ spatialTargetC: {
976
+ R: 'imageR',
977
+ G: 'imageG',
978
+ B: 'imageB',
979
+ A: 'A',
980
+ },
981
+ spatialChannelColor: {
982
+ R: 'imageR',
983
+ G: 'imageG',
984
+ B: 'imageB',
985
+ A: 'A',
986
+ },
987
+ spatialChannelVisible: {
988
+ R: 'imageR',
989
+ G: 'imageG',
990
+ B: 'imageB',
991
+ A: 'A',
992
+ },
993
+ spatialChannelOpacity: {
994
+ R: 'imageR',
995
+ G: 'imageG',
996
+ B: 'imageB',
997
+ A: 'A',
998
+ },
999
+ spatialChannelWindow: {
1000
+ R: 'imageR',
1001
+ G: 'imageG',
1002
+ B: 'imageB',
1003
+ A: 'A',
1004
+ },
1005
+ },
1006
+ },
1007
+ },
1008
+ spatialZoom: {
1009
+ A: -4,
1010
+ },
1011
+ spatialTargetX: {
1012
+ A: 10,
1013
+ },
1014
+ spatialTargetY: {
1015
+ A: 20,
1016
+ },
1017
+ image: {
1018
+ rgb: 'S-1905-017737_bf',
1019
+ },
1020
+ imageLayer: {
1021
+ histology: 'histology',
1022
+ },
1023
+ imageChannel: {
1024
+ R: 'R',
1025
+ G: 'G',
1026
+ B: 'B',
1027
+ A: '__dummy__',
1028
+ },
1029
+
1030
+ spatialTargetC: {
1031
+ imageR: 0,
1032
+ imageG: 1,
1033
+ imageB: 2,
1034
+ A: 0,
1035
+ },
1036
+ spatialLayerVisible: {
1037
+ image: true,
1038
+ },
1039
+ spatialLayerOpacity: {
1040
+ image: 1,
1041
+ },
1042
+ spatialChannelVisible: {
1043
+ imageR: true,
1044
+ imageG: true,
1045
+ imageB: true,
1046
+ A: true,
1047
+ },
1048
+ spatialChannelOpacity: {
1049
+ imageR: 1,
1050
+ imageG: 1,
1051
+ imageB: 1,
1052
+ A: 1,
1053
+ },
1054
+ spatialChannelWindow: {
1055
+ imageR: [
1056
+ 0,
1057
+ 255,
1058
+ ],
1059
+ imageG: [
1060
+ 0,
1061
+ 255,
1062
+ ],
1063
+ imageB: [
1064
+ 0,
1065
+ 255,
1066
+ ],
1067
+ A: [
1068
+ 0,
1069
+ 255,
1070
+ ],
1071
+ },
1072
+ spatialChannelColor: {
1073
+ imageR: [
1074
+ 255,
1075
+ 0,
1076
+ 0,
1077
+ ],
1078
+ imageG: [
1079
+ 0,
1080
+ 255,
1081
+ 0,
1082
+ ],
1083
+ imageB: [
1084
+ 0,
1085
+ 0,
1086
+ 255,
1087
+ ],
1088
+ A: [
1089
+ 255,
1090
+ 255,
1091
+ 255,
1092
+ ],
1093
+ },
1094
+ photometricInterpretation: {
1095
+ rgb: 'RGB',
1096
+ },
1097
+ dataset: {
1098
+ A: 'S-1905-017737',
1099
+ },
1100
+ spatialLayerColormap: {
1101
+ A: null,
1102
+ },
1103
+ });
1104
+ });
1105
+ it('adds an image channel to an image layer when channels are per-view', () => {
1106
+ const coordinationScopesRaw = {
1107
+ metaCoordinationScopes: [
1108
+ 'metaA',
1109
+ ],
1110
+ metaCoordinationScopesBy: [
1111
+ 'metaA',
1112
+ ],
1113
+ spatialTargetX: 'A',
1114
+ spatialTargetY: 'A',
1115
+ spatialZoom: 'A',
1116
+ dataset: 'A',
1117
+ image: 'A',
1118
+ imageChannel: 'A',
1119
+ spatialTargetC: 'A',
1120
+ spatialLayerVisible: 'A',
1121
+ spatialLayerOpacity: 'A',
1122
+ spatialLayerColormap: 'A',
1123
+ spatialChannelVisible: 'A',
1124
+ spatialChannelOpacity: 'A',
1125
+ spatialChannelWindow: 'A',
1126
+ spatialChannelColor: 'A',
1127
+ photometricInterpretation: 'A',
1128
+ };
1129
+ const layerScope = 'histology';
1130
+ const coordinationSpace = {
1131
+ metaCoordinationScopes: {
1132
+ metaA: {
1133
+ imageLayer: [
1134
+ 'histology',
1135
+ ],
1136
+ imageChannel: [
1137
+ 'R', 'G',
1138
+ ],
1139
+ },
1140
+ },
1141
+ metaCoordinationScopesBy: {
1142
+ metaA: {
1143
+ imageLayer: {
1144
+ image: {
1145
+ histology: 'rgb',
1146
+ },
1147
+ spatialLayerVisible: {
1148
+ histology: 'image',
1149
+ },
1150
+ spatialLayerOpacity: {
1151
+ histology: 'image',
1152
+ },
1153
+ photometricInterpretation: {
1154
+ histology: 'rgb',
1155
+ },
1156
+ },
1157
+ imageChannel: {
1158
+ spatialTargetC: {
1159
+ R: 'imageR',
1160
+ G: 'imageG',
1161
+ B: 'imageB',
1162
+ },
1163
+ spatialChannelColor: {
1164
+ R: 'imageR',
1165
+ G: 'imageG',
1166
+ B: 'imageB',
1167
+ },
1168
+ spatialChannelVisible: {
1169
+ R: 'imageR',
1170
+ G: 'imageG',
1171
+ B: 'imageB',
1172
+ },
1173
+ spatialChannelOpacity: {
1174
+ R: 'imageR',
1175
+ G: 'imageG',
1176
+ B: 'imageB',
1177
+ },
1178
+ spatialChannelWindow: {
1179
+ R: 'imageR',
1180
+ G: 'imageG',
1181
+ B: 'imageB',
1182
+ },
1183
+ },
1184
+ },
1185
+ },
1186
+ spatialZoom: {
1187
+ A: -4,
1188
+ },
1189
+ spatialTargetX: {
1190
+ A: 10,
1191
+ },
1192
+ spatialTargetY: {
1193
+ A: 20,
1194
+ },
1195
+ image: {
1196
+ rgb: 'S-1905-017737_bf',
1197
+ },
1198
+ imageLayer: {
1199
+ histology: 'histology',
1200
+ },
1201
+ imageChannel: {
1202
+ R: 'R',
1203
+ G: 'G',
1204
+ B: 'B',
1205
+ },
1206
+ spatialTargetC: {
1207
+ imageR: 0,
1208
+ imageG: 1,
1209
+ imageB: 2,
1210
+ },
1211
+ spatialLayerVisible: {
1212
+ image: true,
1213
+ },
1214
+ spatialLayerOpacity: {
1215
+ image: 1,
1216
+ },
1217
+ spatialChannelVisible: {
1218
+ imageR: true,
1219
+ imageG: true,
1220
+ imageB: true,
1221
+ },
1222
+ spatialChannelOpacity: {
1223
+ imageR: 1,
1224
+ imageG: 1,
1225
+ imageB: 1,
1226
+ },
1227
+ spatialChannelWindow: {
1228
+ imageR: [
1229
+ 0,
1230
+ 255,
1231
+ ],
1232
+ imageG: [
1233
+ 0,
1234
+ 255,
1235
+ ],
1236
+ imageB: [
1237
+ 0,
1238
+ 255,
1239
+ ],
1240
+ },
1241
+ spatialChannelColor: {
1242
+ imageR: [
1243
+ 255,
1244
+ 0,
1245
+ 0,
1246
+ ],
1247
+ imageG: [
1248
+ 0,
1249
+ 255,
1250
+ 0,
1251
+ ],
1252
+ imageB: [
1253
+ 0,
1254
+ 0,
1255
+ 255,
1256
+ ],
1257
+ },
1258
+ photometricInterpretation: {
1259
+ rgb: 'RGB',
1260
+ },
1261
+ dataset: {
1262
+ A: 'S-1905-017737',
1263
+ },
1264
+ spatialLayerColormap: {
1265
+ A: null,
1266
+ },
1267
+ };
1268
+ const newCoordinationSpace = addImageChannelInMetaCoordinationScopesHelper(
1269
+ coordinationScopesRaw,
1270
+ layerScope,
1271
+ coordinationSpace,
1272
+ );
1273
+ expect(newCoordinationSpace).toEqual({
1274
+ metaCoordinationScopes: {
1275
+ metaA: {
1276
+ imageLayer: [
1277
+ 'histology',
1278
+ ],
1279
+ imageChannel: [
1280
+ 'R', 'G', 'A',
1281
+ ],
1282
+ },
1283
+ },
1284
+ metaCoordinationScopesBy: {
1285
+ metaA: {
1286
+ imageLayer: {
1287
+ image: {
1288
+ histology: 'rgb',
1289
+ },
1290
+ spatialLayerVisible: {
1291
+ histology: 'image',
1292
+ },
1293
+ spatialLayerOpacity: {
1294
+ histology: 'image',
1295
+ },
1296
+ photometricInterpretation: {
1297
+ histology: 'rgb',
1298
+ },
1299
+ },
1300
+ imageChannel: {
1301
+ spatialTargetC: {
1302
+ R: 'imageR',
1303
+ G: 'imageG',
1304
+ B: 'imageB',
1305
+ A: 'A',
1306
+ },
1307
+ spatialChannelColor: {
1308
+ R: 'imageR',
1309
+ G: 'imageG',
1310
+ B: 'imageB',
1311
+ A: 'A',
1312
+ },
1313
+ spatialChannelVisible: {
1314
+ R: 'imageR',
1315
+ G: 'imageG',
1316
+ B: 'imageB',
1317
+ A: 'A',
1318
+ },
1319
+ spatialChannelOpacity: {
1320
+ R: 'imageR',
1321
+ G: 'imageG',
1322
+ B: 'imageB',
1323
+ A: 'A',
1324
+ },
1325
+ spatialChannelWindow: {
1326
+ R: 'imageR',
1327
+ G: 'imageG',
1328
+ B: 'imageB',
1329
+ A: 'A',
1330
+ },
1331
+ },
1332
+ },
1333
+ },
1334
+ spatialZoom: {
1335
+ A: -4,
1336
+ },
1337
+ spatialTargetX: {
1338
+ A: 10,
1339
+ },
1340
+ spatialTargetY: {
1341
+ A: 20,
1342
+ },
1343
+ image: {
1344
+ rgb: 'S-1905-017737_bf',
1345
+ },
1346
+ imageLayer: {
1347
+ histology: 'histology',
1348
+ },
1349
+ imageChannel: {
1350
+ R: 'R',
1351
+ G: 'G',
1352
+ B: 'B',
1353
+ A: '__dummy__',
1354
+ },
1355
+
1356
+ spatialTargetC: {
1357
+ imageR: 0,
1358
+ imageG: 1,
1359
+ imageB: 2,
1360
+ A: 0,
1361
+ },
1362
+ spatialLayerVisible: {
1363
+ image: true,
1364
+ },
1365
+ spatialLayerOpacity: {
1366
+ image: 1,
1367
+ },
1368
+ spatialChannelVisible: {
1369
+ imageR: true,
1370
+ imageG: true,
1371
+ imageB: true,
1372
+ A: true,
1373
+ },
1374
+ spatialChannelOpacity: {
1375
+ imageR: 1,
1376
+ imageG: 1,
1377
+ imageB: 1,
1378
+ A: 1,
1379
+ },
1380
+ spatialChannelWindow: {
1381
+ imageR: [
1382
+ 0,
1383
+ 255,
1384
+ ],
1385
+ imageG: [
1386
+ 0,
1387
+ 255,
1388
+ ],
1389
+ imageB: [
1390
+ 0,
1391
+ 255,
1392
+ ],
1393
+ A: [
1394
+ 0,
1395
+ 255,
1396
+ ],
1397
+ },
1398
+ spatialChannelColor: {
1399
+ imageR: [
1400
+ 255,
1401
+ 0,
1402
+ 0,
1403
+ ],
1404
+ imageG: [
1405
+ 0,
1406
+ 255,
1407
+ 0,
1408
+ ],
1409
+ imageB: [
1410
+ 0,
1411
+ 0,
1412
+ 255,
1413
+ ],
1414
+ A: [
1415
+ 255,
1416
+ 255,
1417
+ 255,
1418
+ ],
1419
+ },
1420
+ photometricInterpretation: {
1421
+ rgb: 'RGB',
1422
+ },
1423
+ dataset: {
1424
+ A: 'S-1905-017737',
1425
+ },
1426
+ spatialLayerColormap: {
1427
+ A: null,
1428
+ },
1429
+ });
1430
+ });
1431
+ });
1432
+ });