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