From 112d546e71fa0e0a2129050f50a190a8cd78b8e9 Mon Sep 17 00:00:00 2001 From: Christian Tischer Date: Thu, 26 Oct 2023 19:42:13 +0200 Subject: [PATCH] Compiles --- src/main/java/org/embl/mobie/MoBIE.java | 18 ++++++++++++++++-- .../java/org/embl/mobie/lib/MoBIEHelper.java | 15 +++++++++++++++ .../java/org/embl/mobie/lib/hcs/Plate.java | 2 ++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/embl/mobie/MoBIE.java b/src/main/java/org/embl/mobie/MoBIE.java index d7bfc0a9b..21d5ca0fc 100644 --- a/src/main/java/org/embl/mobie/MoBIE.java +++ b/src/main/java/org/embl/mobie/MoBIE.java @@ -744,9 +744,23 @@ private void initDataSource( DataSource dataSource, String log ) return new CachedCellImage<>( name, storageLocation.absolutePath, storageLocation.getChannel(), imageDataFormat, ThreadHelper.sharedQueue ); } - if ( storageLocation instanceof Site ) + if ( storageLocation instanceof Site ) // HCS data { - return new SpimDataImage( ( Site ) storageLocation, name, ThreadHelper.sharedQueue ); + final Site site = ( Site ) storageLocation; + + if ( site.getImageDataFormat().equals( ImageDataFormat.SpimData ) ) + { + // the whole plate is already initialised as one big SpimData + // note that channel <=> setupID + return new SpimDataImage( site.getSpimData(), site.channel, name, false ); + } + + if ( site.getImageDataFormat().equals( ImageDataFormat.OmeZarr ) ) + { + return new SpimDataImage( ImageDataFormat.OmeZarr, site.absolutePath, site.channel, name, ThreadHelper.sharedQueue, false ); + } + + return new SpimDataImage( site, name, ThreadHelper.sharedQueue ); } final String imagePath = getImageLocation( imageDataFormat, storageLocation ); diff --git a/src/main/java/org/embl/mobie/lib/MoBIEHelper.java b/src/main/java/org/embl/mobie/lib/MoBIEHelper.java index 6873b692b..e76170bf1 100644 --- a/src/main/java/org/embl/mobie/lib/MoBIEHelper.java +++ b/src/main/java/org/embl/mobie/lib/MoBIEHelper.java @@ -253,6 +253,21 @@ public static Metadata getMetadataFromSource( ImageDataSource imageDataSource ) return metadata; } + public static ImagePlus openOMEZarrAsImagePlus( String path, int setupID ) + { + try + { + AbstractSpimData< ? > spimData = new SpimDataOpener().open( path, ImageDataFormat.OmeZarr ); + final SpimSource< ? > spimSource = new SpimSource( spimData, setupID, "" ); + final ImagePlus imagePlus = new SourceToImagePlusConverter<>( spimSource ).getImagePlus( 0 ); + return imagePlus; + } catch ( SpimDataException e ) + { + e.printStackTrace(); + throw new RuntimeException( e ); + } + } + public static String createAbsolutePath( String rootFolder, String fileName, String folderName ) { // The "root" is AutoMic table specific diff --git a/src/main/java/org/embl/mobie/lib/hcs/Plate.java b/src/main/java/org/embl/mobie/lib/hcs/Plate.java index b8b39d9b8..df9237634 100644 --- a/src/main/java/org/embl/mobie/lib/hcs/Plate.java +++ b/src/main/java/org/embl/mobie/lib/hcs/Plate.java @@ -41,6 +41,7 @@ import org.embl.mobie.io.ImageDataFormat; import org.embl.mobie.io.SpimDataOpener; import org.embl.mobie.io.toml.TPosition; +import org.embl.mobie.lib.MoBIEHelper; import org.embl.mobie.lib.color.ColorHelper; import ch.epfl.biop.bdv.img.bioformats.entity.SeriesIndex; @@ -174,6 +175,7 @@ private void buildPlateMap( List< String > paths ) channel = new Channel( channelName ); channelWellSites.put( channel, new HashMap<>() ); + // FIXME Replace with MoBIEHelper.getMetadataFromImageFile ImagePlus singleChannelImagePlus = operettaMetadata == null ? openImagePlus( path, channelName ) : null; // set channel metadata