@@ -372,46 +372,6 @@ MakeKVStoreHTTPDriverSpec(nlohmann::json & spec, const std::string & fullPath)
372
372
spec[" kvstore" ][" path" ] = fullPath.substr (fullPath.find_last_of (" /" ) + 1 );
373
373
}
374
374
375
- } // namespace
376
-
377
- struct OMEZarrNGFFImageIO ::TensorStoreData
378
- {
379
- tensorstore::Context tsContext{ tensorstore::Context::Default () };
380
- tensorstore::TensorStore<> store{};
381
- };
382
-
383
- OMEZarrNGFFImageIO::OMEZarrNGFFImageIO ()
384
- : m_TensorStoreData(std::make_unique<TensorStoreData>())
385
- {
386
- this ->AddSupportedWriteExtension (" .zarr" );
387
- this ->AddSupportedWriteExtension (" .zr2" );
388
- this ->AddSupportedWriteExtension (" .zr3" );
389
- this ->AddSupportedWriteExtension (" .zip" );
390
- this ->AddSupportedWriteExtension (" .memory" );
391
-
392
- this ->AddSupportedReadExtension (" .zarr" );
393
- this ->AddSupportedReadExtension (" .zr2" );
394
- this ->AddSupportedReadExtension (" .zr3" );
395
- this ->AddSupportedReadExtension (" .zip" );
396
- this ->AddSupportedWriteExtension (" .memory" );
397
-
398
- this ->Self ::SetCompressor (" " );
399
- this ->Self ::SetMaximumCompressionLevel (9 );
400
- this ->Self ::SetCompressionLevel (2 );
401
- }
402
-
403
- OMEZarrNGFFImageIO::~OMEZarrNGFFImageIO () = default ;
404
-
405
-
406
- void
407
- OMEZarrNGFFImageIO::PrintSelf (std::ostream & os, Indent indent) const
408
- {
409
- Superclass::PrintSelf (os, indent);
410
- os << indent << " DatasetIndex: " << m_DatasetIndex << std::endl;
411
- os << indent << " TimeIndex: " << m_TimeIndex << std::endl;
412
- os << indent << " ChannelIndex: " << m_ChannelIndex << std::endl;
413
- }
414
-
415
375
// JSON file path, e.g. "C:/Dev/ITKIOOMEZarrNGFF/v0.4/cyx.ome.zarr/.zgroup"
416
376
void
417
377
writeJson (nlohmann::json json, std::string path, std::string driver, tensorstore::Context& tsContext)
@@ -466,6 +426,91 @@ jsonRead(const std::string path, nlohmann::json & result, std::string driver, te
466
426
}
467
427
}
468
428
429
+ void
430
+ addCoordinateTransformations (OMEZarrNGFFImageIO * io, nlohmann::json ct)
431
+ {
432
+ itkAssertOrThrowMacro (ct.is_array (), " Failed to parse coordinate transforms" );
433
+ itkAssertOrThrowMacro (ct.size () >= 1 , " Expected at least one coordinate transform" );
434
+ itkAssertOrThrowMacro (ct[0 ].at (" type" ) == " scale" ,
435
+ (" Expected first transform to be \" scale\" but found " +
436
+ std::string (ct[0 ].at (" type" )))); // first transformation must be scale
437
+
438
+ nlohmann::json s = ct[0 ].at (" scale" );
439
+ itkAssertOrThrowMacro (s.is_array (), " Failed to parse scale transform" );
440
+ unsigned dim = s.size ();
441
+ itkAssertOrThrowMacro (dim == io->GetNumberOfDimensions (), " Found dimension mismatch in scale transform" );
442
+
443
+ for (unsigned d = 0 ; d < dim; ++d)
444
+ {
445
+ double dS = s[dim - d - 1 ].get <double >(); // reverse indices KJI into IJK
446
+ io->SetSpacing (d, dS * io->GetSpacing (d));
447
+ io->SetOrigin (d, dS * io->GetOrigin (d)); // TODO: should we update origin like this?
448
+ }
449
+
450
+ if (ct.size () > 1 ) // there is also a translation
451
+ {
452
+ itkAssertOrThrowMacro (ct[1 ].at (" type" ) == " translation" ,
453
+ (" Expected second transform to be \" translation\" but found " +
454
+ std::string (ct[1 ].at (" type" )))); // first transformation must be scale
455
+ nlohmann::json tr = ct[1 ].at (" translation" );
456
+ itkAssertOrThrowMacro (tr.is_array (), " Failed to parse translation transform" );
457
+ dim = tr.size ();
458
+ itkAssertOrThrowMacro (dim == io->GetNumberOfDimensions (), " Found dimension mismatch in translation transform" );
459
+
460
+ for (unsigned d = 0 ; d < dim; ++d)
461
+ {
462
+ double dOrigin = tr[dim - d - 1 ].get <double >(); // reverse indices KJI into IJK
463
+ io->SetOrigin (d, dOrigin + io->GetOrigin (d));
464
+ }
465
+ }
466
+
467
+ if (ct.size () > 2 )
468
+ {
469
+ itkGenericOutputMacro (<< " A sequence of more than 2 transformations is specified in '" << io->GetFileName ()
470
+ << " '. This is currently not supported. Extra transformations are ignored." );
471
+ }
472
+ }
473
+
474
+ } // namespace
475
+
476
+ struct OMEZarrNGFFImageIO ::TensorStoreData
477
+ {
478
+ tensorstore::Context tsContext{ tensorstore::Context::Default () };
479
+ tensorstore::TensorStore<> store{};
480
+ };
481
+
482
+ OMEZarrNGFFImageIO::OMEZarrNGFFImageIO ()
483
+ : m_TensorStoreData(std::make_unique<TensorStoreData>())
484
+ {
485
+ this ->AddSupportedWriteExtension (" .zarr" );
486
+ this ->AddSupportedWriteExtension (" .zr2" );
487
+ this ->AddSupportedWriteExtension (" .zr3" );
488
+ this ->AddSupportedWriteExtension (" .zip" );
489
+ this ->AddSupportedWriteExtension (" .memory" );
490
+
491
+ this ->AddSupportedReadExtension (" .zarr" );
492
+ this ->AddSupportedReadExtension (" .zr2" );
493
+ this ->AddSupportedReadExtension (" .zr3" );
494
+ this ->AddSupportedReadExtension (" .zip" );
495
+ this ->AddSupportedWriteExtension (" .memory" );
496
+
497
+ this ->Self ::SetCompressor (" " );
498
+ this ->Self ::SetMaximumCompressionLevel (9 );
499
+ this ->Self ::SetCompressionLevel (2 );
500
+ }
501
+
502
+ OMEZarrNGFFImageIO::~OMEZarrNGFFImageIO () = default ;
503
+
504
+
505
+ void
506
+ OMEZarrNGFFImageIO::PrintSelf (std::ostream & os, Indent indent) const
507
+ {
508
+ Superclass::PrintSelf (os, indent);
509
+ os << indent << " DatasetIndex: " << m_DatasetIndex << std::endl;
510
+ os << indent << " TimeIndex: " << m_TimeIndex << std::endl;
511
+ os << indent << " ChannelIndex: " << m_ChannelIndex << std::endl;
512
+ }
513
+
469
514
bool
470
515
OMEZarrNGFFImageIO::CanReadFile (const char * filename)
471
516
{
@@ -606,51 +651,6 @@ OMEZarrNGFFImageIO::ConfigureTensorstoreIORegion(const ImageIORegion & ioRegion)
606
651
return storeRegion;
607
652
}
608
653
609
- void
610
- addCoordinateTransformations (OMEZarrNGFFImageIO * io, nlohmann::json ct)
611
- {
612
- itkAssertOrThrowMacro (ct.is_array (), " Failed to parse coordinate transforms" );
613
- itkAssertOrThrowMacro (ct.size () >= 1 , " Expected at least one coordinate transform" );
614
- itkAssertOrThrowMacro (ct[0 ].at (" type" ) == " scale" ,
615
- (" Expected first transform to be \" scale\" but found " +
616
- std::string (ct[0 ].at (" type" )))); // first transformation must be scale
617
-
618
- nlohmann::json s = ct[0 ].at (" scale" );
619
- itkAssertOrThrowMacro (s.is_array (), " Failed to parse scale transform" );
620
- unsigned dim = s.size ();
621
- itkAssertOrThrowMacro (dim == io->GetNumberOfDimensions (), " Found dimension mismatch in scale transform" );
622
-
623
- for (unsigned d = 0 ; d < dim; ++d)
624
- {
625
- double dS = s[dim - d - 1 ].get <double >(); // reverse indices KJI into IJK
626
- io->SetSpacing (d, dS * io->GetSpacing (d));
627
- io->SetOrigin (d, dS * io->GetOrigin (d)); // TODO: should we update origin like this?
628
- }
629
-
630
- if (ct.size () > 1 ) // there is also a translation
631
- {
632
- itkAssertOrThrowMacro (ct[1 ].at (" type" ) == " translation" ,
633
- (" Expected second transform to be \" translation\" but found " +
634
- std::string (ct[1 ].at (" type" )))); // first transformation must be scale
635
- nlohmann::json tr = ct[1 ].at (" translation" );
636
- itkAssertOrThrowMacro (tr.is_array (), " Failed to parse translation transform" );
637
- dim = tr.size ();
638
- itkAssertOrThrowMacro (dim == io->GetNumberOfDimensions (), " Found dimension mismatch in translation transform" );
639
-
640
- for (unsigned d = 0 ; d < dim; ++d)
641
- {
642
- double dOrigin = tr[dim - d - 1 ].get <double >(); // reverse indices KJI into IJK
643
- io->SetOrigin (d, dOrigin + io->GetOrigin (d));
644
- }
645
- }
646
-
647
- if (ct.size () > 2 )
648
- {
649
- itkGenericOutputMacro (<< " A sequence of more than 2 transformations is specified in '" << io->GetFileName ()
650
- << " '. This is currently not supported. Extra transformations are ignored." );
651
- }
652
- }
653
-
654
654
void
655
655
OMEZarrNGFFImageIO::ReadImageInformation ()
656
656
{
0 commit comments