-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
144 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/main/java/org/embl/mobie/lib/hcs/omezarr/OMEZarrHCSHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.embl.mobie.lib.hcs.omezarr; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.reflect.TypeToken; | ||
import org.embl.mobie.io.util.IOHelper; | ||
import org.embl.mobie.lib.serialize.JsonHelper; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class OMEZarrHCSHelper | ||
{ | ||
public static final String ZATTRS = "/.zattrs"; | ||
|
||
public static List< String > sitePathsFromFolderStructure( String hcsDirectory ) throws IOException | ||
{ | ||
List< String > imageSitePaths; | ||
final int minDepth = 3; | ||
final int maxDepth = 3; | ||
final Path rootPath = Paths.get( hcsDirectory ); | ||
final int rootPathDepth = rootPath.getNameCount(); | ||
imageSitePaths = Files.walk( rootPath, maxDepth ) | ||
.filter( e -> e.toFile().isDirectory() ) | ||
.filter( e -> e.getNameCount() - rootPathDepth >= minDepth ) | ||
.map( e -> e.toString() ) | ||
.collect( Collectors.toList() ); | ||
return imageSitePaths; | ||
} | ||
|
||
public static List< String > sitePathsFromMetadata( String hcsDirectory ) throws IOException | ||
{ | ||
List< String > imageSitePaths = new ArrayList<>(); | ||
Gson gson = JsonHelper.buildGson(false); | ||
|
||
String plateUri = hcsDirectory; | ||
final String plateJson = IOHelper.read( plateUri + ZATTRS ); | ||
//System.out.println( plateJson ); | ||
HCSMetadata hcsMetadata = gson.fromJson(plateJson, new TypeToken< HCSMetadata >() {}.getType()); | ||
|
||
int i = 0; | ||
for ( Well well : hcsMetadata.plate.wells ) | ||
{ | ||
System.out.println( "Parsing well: " + well.path ); | ||
String wellPath = well.path; | ||
String wellUri = IOHelper.combinePath( plateUri, wellPath); | ||
final String wellJson = IOHelper.read( wellUri + ZATTRS ); | ||
WellMetadata wellMetadata = gson.fromJson( wellJson, new TypeToken< WellMetadata >() {}.getType() ); | ||
|
||
for ( Image image : wellMetadata.well.images ) | ||
{ | ||
String imageUri = IOHelper.combinePath( wellUri, image.path ); | ||
imageSitePaths.add( imageUri ); | ||
} | ||
|
||
i++; | ||
if ( i > 1 ) break; | ||
} | ||
|
||
return imageSitePaths; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/*- | ||
* #%L | ||
* Fiji viewer for MoBIE projects | ||
* %% | ||
* Copyright (C) 2018 - 2023 EMBL | ||
* %% | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* #L% | ||
*/ | ||
package hcs; | ||
|
||
import mpicbg.spim.data.SpimDataException; | ||
import net.imagej.ImageJ; | ||
import org.embl.mobie.MoBIE; | ||
import org.embl.mobie.MoBIESettings; | ||
|
||
import java.io.IOException; | ||
|
||
class HCSOMEZarrS3 | ||
{ | ||
public static void main( String[] args ) throws SpimDataException, IOException | ||
{ | ||
new ImageJ().ui().showUI(); | ||
|
||
new MoBIE( "https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.1/plates/5966.zarr", new MoBIESettings(), 0.1, 0.0 ); | ||
} | ||
} |