@vitessce/spatial-utils 3.6.10 → 3.6.12

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.
@@ -3,6 +3,7 @@ import {
3
3
  coordinateTransformationsToMatrix,
4
4
  normalizeCoordinateTransformations,
5
5
  getSwapAxesMatrix,
6
+ coordinateTransformationsToMatrixForSpatialData,
6
7
  } from './spatial.js';
7
8
 
8
9
  const defaultAxes = [
@@ -308,6 +309,44 @@ describe('Spatial.js', () => {
308
309
  // the user to specify this somehow and use that information to filter which transforms
309
310
  // are included here.
310
311
  {
312
+ input: {
313
+ axes: [
314
+ {
315
+ name: 'c',
316
+ type: 'channel',
317
+ },
318
+ {
319
+ name: 'y',
320
+ type: 'space',
321
+ unit: 'unit',
322
+ },
323
+ {
324
+ name: 'x',
325
+ type: 'space',
326
+ unit: 'unit',
327
+ },
328
+ ],
329
+ name: 'cyx',
330
+ },
331
+ output: {
332
+ axes: [
333
+ {
334
+ name: 'c',
335
+ type: 'channel',
336
+ },
337
+ {
338
+ name: 'y',
339
+ type: 'space',
340
+ unit: 'unit',
341
+ },
342
+ {
343
+ name: 'x',
344
+ type: 'space',
345
+ unit: 'unit',
346
+ },
347
+ ],
348
+ name: 'ST8059048',
349
+ },
311
350
  scale: [
312
351
  1.0,
313
352
  8.670500183814605,
@@ -318,4 +357,512 @@ describe('Spatial.js', () => {
318
357
  ]);
319
358
  });
320
359
  });
360
+ describe('coordinateTransformationsToMatrixForSpatialData', () => {
361
+ it('supports transformations from visium_hd_3.0.0_io.zip labels/rasterized_016um element', () => {
362
+ const zattrs = {
363
+ 'image-label': {
364
+ version: '0.4-dev-spatialdata',
365
+ },
366
+ multiscales: [
367
+ {
368
+ axes: [
369
+ {
370
+ name: 'y',
371
+ type: 'space',
372
+ },
373
+ {
374
+ name: 'x',
375
+ type: 'space',
376
+ },
377
+ ],
378
+ coordinateTransformations: [
379
+ {
380
+ input: {
381
+ axes: [
382
+ {
383
+ name: 'y',
384
+ type: 'space',
385
+ unit: 'unit',
386
+ },
387
+ {
388
+ name: 'x',
389
+ type: 'space',
390
+ unit: 'unit',
391
+ },
392
+ ],
393
+ name: 'yx',
394
+ },
395
+ output: {
396
+ axes: [
397
+ {
398
+ name: 'x',
399
+ type: 'space',
400
+ unit: 'unit',
401
+ },
402
+ {
403
+ name: 'y',
404
+ type: 'space',
405
+ unit: 'unit',
406
+ },
407
+ ],
408
+ name: 'Visium_HD_Mouse_Small_Intestine',
409
+ },
410
+ transformations: [
411
+ {
412
+ input: {
413
+ axes: [
414
+ {
415
+ name: 'y',
416
+ type: 'space',
417
+ unit: 'unit',
418
+ },
419
+ {
420
+ name: 'x',
421
+ type: 'space',
422
+ unit: 'unit',
423
+ },
424
+ ],
425
+ name: 'yx',
426
+ },
427
+ output: {
428
+ axes: [
429
+ {
430
+ name: 'x',
431
+ type: 'space',
432
+ unit: 'unit',
433
+ },
434
+ {
435
+ name: 'y',
436
+ type: 'space',
437
+ unit: 'unit',
438
+ },
439
+ ],
440
+ name: 'global',
441
+ },
442
+ transformations: [
443
+ {
444
+ affine: [
445
+ [
446
+ -0.38,
447
+ 58.43,
448
+ 257.07,
449
+ ],
450
+ [
451
+ -58.42,
452
+ -0.38,
453
+ 24102.79,
454
+ ],
455
+ ],
456
+ input: {
457
+ axes: [
458
+ {
459
+ name: 'y',
460
+ type: 'space',
461
+ unit: 'unit',
462
+ },
463
+ {
464
+ name: 'x',
465
+ type: 'space',
466
+ unit: 'unit',
467
+ },
468
+ ],
469
+ name: 'yx',
470
+ },
471
+ output: {
472
+ axes: [
473
+ {
474
+ name: 'x',
475
+ type: 'space',
476
+ unit: 'unit',
477
+ },
478
+ {
479
+ name: 'y',
480
+ type: 'space',
481
+ unit: 'unit',
482
+ },
483
+ ],
484
+ name: 'global',
485
+ },
486
+ type: 'affine',
487
+ },
488
+ ],
489
+ type: 'sequence',
490
+ },
491
+ {
492
+ input: {
493
+ axes: [
494
+ {
495
+ name: 'x',
496
+ type: 'space',
497
+ unit: 'unit',
498
+ },
499
+ {
500
+ name: 'y',
501
+ type: 'space',
502
+ unit: 'unit',
503
+ },
504
+ ],
505
+ name: 'xy',
506
+ },
507
+ output: {
508
+ axes: [
509
+ {
510
+ name: 'x',
511
+ type: 'space',
512
+ unit: 'unit',
513
+ },
514
+ {
515
+ name: 'y',
516
+ type: 'space',
517
+ unit: 'unit',
518
+ },
519
+ ],
520
+ name: 'global',
521
+ },
522
+ type: 'identity',
523
+ },
524
+ ],
525
+ type: 'sequence',
526
+ },
527
+ {
528
+ input: {
529
+ axes: [
530
+ {
531
+ name: 'y',
532
+ type: 'space',
533
+ unit: 'unit',
534
+ },
535
+ {
536
+ name: 'x',
537
+ type: 'space',
538
+ unit: 'unit',
539
+ },
540
+ ],
541
+ name: 'yx',
542
+ },
543
+ output: {
544
+ axes: [
545
+ {
546
+ name: 'x',
547
+ type: 'space',
548
+ unit: 'unit',
549
+ },
550
+ {
551
+ name: 'y',
552
+ type: 'space',
553
+ unit: 'unit',
554
+ },
555
+ ],
556
+ name: 'Visium_HD_Mouse_Small_Intestine_downscaled_hires',
557
+ },
558
+ transformations: [
559
+ {
560
+ input: {
561
+ axes: [
562
+ {
563
+ name: 'y',
564
+ type: 'space',
565
+ unit: 'unit',
566
+ },
567
+ {
568
+ name: 'x',
569
+ type: 'space',
570
+ unit: 'unit',
571
+ },
572
+ ],
573
+ name: 'yx',
574
+ },
575
+ output: {
576
+ axes: [
577
+ {
578
+ name: 'x',
579
+ type: 'space',
580
+ unit: 'unit',
581
+ },
582
+ {
583
+ name: 'y',
584
+ type: 'space',
585
+ unit: 'unit',
586
+ },
587
+ ],
588
+ name: 'global',
589
+ },
590
+ transformations: [
591
+ {
592
+ affine: [
593
+ [
594
+ -0.38,
595
+ 58.43,
596
+ 257.07,
597
+ ],
598
+ [
599
+ -58.42,
600
+ -0.38,
601
+ 24102.79,
602
+ ],
603
+ ],
604
+ input: {
605
+ axes: [
606
+ {
607
+ name: 'y',
608
+ type: 'space',
609
+ unit: 'unit',
610
+ },
611
+ {
612
+ name: 'x',
613
+ type: 'space',
614
+ unit: 'unit',
615
+ },
616
+ ],
617
+ name: 'yx',
618
+ },
619
+ output: {
620
+ axes: [
621
+ {
622
+ name: 'x',
623
+ type: 'space',
624
+ unit: 'unit',
625
+ },
626
+ {
627
+ name: 'y',
628
+ type: 'space',
629
+ unit: 'unit',
630
+ },
631
+ ],
632
+ name: 'global',
633
+ },
634
+ type: 'affine',
635
+ },
636
+ ],
637
+ type: 'sequence',
638
+ },
639
+ {
640
+ input: {
641
+ axes: [
642
+ {
643
+ name: 'x',
644
+ type: 'space',
645
+ unit: 'unit',
646
+ },
647
+ {
648
+ name: 'y',
649
+ type: 'space',
650
+ unit: 'unit',
651
+ },
652
+ ],
653
+ name: 'xy',
654
+ },
655
+ output: {
656
+ axes: [
657
+ {
658
+ name: 'x',
659
+ type: 'space',
660
+ unit: 'unit',
661
+ },
662
+ {
663
+ name: 'y',
664
+ type: 'space',
665
+ unit: 'unit',
666
+ },
667
+ ],
668
+ name: 'global',
669
+ },
670
+ scale: [
671
+ 0.25,
672
+ 0.25,
673
+ ],
674
+ type: 'scale',
675
+ },
676
+ ],
677
+ type: 'sequence',
678
+ },
679
+ {
680
+ input: {
681
+ axes: [
682
+ {
683
+ name: 'y',
684
+ type: 'space',
685
+ unit: 'unit',
686
+ },
687
+ {
688
+ name: 'x',
689
+ type: 'space',
690
+ unit: 'unit',
691
+ },
692
+ ],
693
+ name: 'yx',
694
+ },
695
+ output: {
696
+ axes: [
697
+ {
698
+ name: 'x',
699
+ type: 'space',
700
+ unit: 'unit',
701
+ },
702
+ {
703
+ name: 'y',
704
+ type: 'space',
705
+ unit: 'unit',
706
+ },
707
+ ],
708
+ name: 'Visium_HD_Mouse_Small_Intestine_downscaled_lowres',
709
+ },
710
+ transformations: [
711
+ {
712
+ input: {
713
+ axes: [
714
+ {
715
+ name: 'y',
716
+ type: 'space',
717
+ unit: 'unit',
718
+ },
719
+ {
720
+ name: 'x',
721
+ type: 'space',
722
+ unit: 'unit',
723
+ },
724
+ ],
725
+ name: 'yx',
726
+ },
727
+ output: {
728
+ axes: [
729
+ {
730
+ name: 'x',
731
+ type: 'space',
732
+ unit: 'unit',
733
+ },
734
+ {
735
+ name: 'y',
736
+ type: 'space',
737
+ unit: 'unit',
738
+ },
739
+ ],
740
+ name: 'global',
741
+ },
742
+ transformations: [
743
+ {
744
+ affine: [
745
+ [
746
+ -0.38,
747
+ 58.43,
748
+ 257.07,
749
+ ],
750
+ [
751
+ -58.42,
752
+ -0.38,
753
+ 24102.79,
754
+ ],
755
+ ],
756
+ input: {
757
+ axes: [
758
+ {
759
+ name: 'y',
760
+ type: 'space',
761
+ unit: 'unit',
762
+ },
763
+ {
764
+ name: 'x',
765
+ type: 'space',
766
+ unit: 'unit',
767
+ },
768
+ ],
769
+ name: 'yx',
770
+ },
771
+ output: {
772
+ axes: [
773
+ {
774
+ name: 'x',
775
+ type: 'space',
776
+ unit: 'unit',
777
+ },
778
+ {
779
+ name: 'y',
780
+ type: 'space',
781
+ unit: 'unit',
782
+ },
783
+ ],
784
+ name: 'global',
785
+ },
786
+ type: 'affine',
787
+ },
788
+ ],
789
+ type: 'sequence',
790
+ },
791
+ {
792
+ input: {
793
+ axes: [
794
+ {
795
+ name: 'x',
796
+ type: 'space',
797
+ unit: 'unit',
798
+ },
799
+ {
800
+ name: 'y',
801
+ type: 'space',
802
+ unit: 'unit',
803
+ },
804
+ ],
805
+ name: 'xy',
806
+ },
807
+ output: {
808
+ axes: [
809
+ {
810
+ name: 'x',
811
+ type: 'space',
812
+ unit: 'unit',
813
+ },
814
+ {
815
+ name: 'y',
816
+ type: 'space',
817
+ unit: 'unit',
818
+ },
819
+ ],
820
+ name: 'global',
821
+ },
822
+ scale: [
823
+ 0.025,
824
+ 0.025,
825
+ ],
826
+ type: 'scale',
827
+ },
828
+ ],
829
+ type: 'sequence',
830
+ },
831
+ ],
832
+ datasets: [
833
+ {
834
+ coordinateTransformations: [
835
+ {
836
+ scale: [
837
+ 1.0,
838
+ 1.0,
839
+ ],
840
+ type: 'scale',
841
+ },
842
+ ],
843
+ path: '0',
844
+ },
845
+ ],
846
+ name: 'rasterized_016um',
847
+ version: '0.4-dev-spatialdata',
848
+ },
849
+ ],
850
+ spatialdata_attrs: {
851
+ version: '0.2',
852
+ },
853
+ };
854
+ const firstMultiscales = zattrs.multiscales[0];
855
+ const targetCoordinateSystem = 'Visium_HD_Mouse_Small_Intestine';
856
+ const matrix = coordinateTransformationsToMatrixForSpatialData(
857
+ firstMultiscales,
858
+ targetCoordinateSystem,
859
+ );
860
+ expect(matrix).toEqual([
861
+ 58.43, -0.38, 0, 0,
862
+ -0.38, -58.42, 0, 0,
863
+ 0, 0, 1, 0,
864
+ 257.07, 24102.79, 0, 1,
865
+ ]);
866
+ });
867
+ });
321
868
  });