Package sc.fiji.snt.io
Class SpimDataUtils
java.lang.Object
sc.fiji.snt.io.SpimDataUtils
Utilities for working with
AbstractSpimData and BigDataViewer XML
descriptors.- Author:
- Tiago Ferreira
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSpimDataUtils.CalibratedSource<T extends net.imglib2.type.numeric.NumericType<T>>Wraps aRandomAccessibleIntervalSourceand overridesSpimDataUtils.CalibratedSource.getVoxelDimensions()to carry the physical unit (e.g.static final recordHolds the sources produced by opening an N5 or OME-Zarr container vian5-ij/n5-universe/n5-viewer_fiji(seeresolvePathToSource(String)). -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisRemoteUrl(String path) Whetherpathis a remote URL (e.g.static voidpatchImsXml(String xmlPath, String base) Patches an IMS XML sidecar file, replacing all"(name not specified)"placeholders with sequential channel names derived from the base name.static SpimDataUtils.N5SourcesresolveN5Selection(org.janelia.saalfeldlab.n5.ui.DataSelection selection, String name) BuildsSpimDataUtils.N5Sourcesfrom a user-madeDataSelection(e.g.static ObjectresolvePathToSource(String filePathOrUrl) Resolves a file path to anAbstractSpimData(for.imsand.xmlfiles), anSpimDataUtils.N5Sources(for.n5/.zarrcontainers), or anImgPlus(fallback).static StringrestoreUrlScheme(String url) Restores a URL's "://" scheme separator ifFile's path normalization collapsed it to a single slash (seeisRemoteUrl(String)).static voidwriteBdvN5Xml(File xmlFile, String n5DirName, long[][] levelDims, double[] voxelSize, String unit, int nTimepoints, String setupName) Writes a BDV-compatible XML descriptor for an N5 dataset.static voidwriteBdvN5Xml(File xmlFile, String n5DirName, long[][] levelDims, double[] voxelSize, String unit, int nTimepoints, String setupName, int nChannels)
-
Method Details
-
resolvePathToSource
Resolves a file path to anAbstractSpimData(for.imsand.xmlfiles), anSpimDataUtils.N5Sources(for.n5/.zarrcontainers), or anImgPlus(fallback).- Parameters:
filePathOrUrl- path or URL to the image file- Returns:
- an
AbstractSpimData,SpimDataUtils.N5Sources, orImgPlus - Throws:
IllegalArgumentException- if the file cannot be opened
-
isRemoteUrl
Whetherpathis a remote URL (e.g.https://.../dataset.ome.zarr,s3://bucket/key,gs://bucket/key) rather than a local filesystem path. Also recognizes the same URLs after their scheme separator has been collapsed from "://" to ":/" byFile's own path normalization (seerestoreUrlScheme(String)) -- this happens whenever a URL is round-tripped through aFile-typed SciJava parameter, e.g. a user typing a URL intoBigDataLoaderCmd's "Main volume" field. Neither Windows drive letters (C:\...) nor UNC paths (\\server\share) match either form, so local paths are never misidentified -
restoreUrlScheme
Restores a URL's "://" scheme separator ifFile's path normalization collapsed it to a single slash (seeisRemoteUrl(String)). A no-op if the separator is already intact. -
patchImsXml
Patches an IMS XML sidecar file, replacing all"(name not specified)"placeholders with sequential channel names derived from the base name.- Parameters:
xmlPath- path to the XML sidecarbase- base name to use (typically the IMS filename without extension)- Throws:
IOException- if the file cannot be read or written
-
resolveN5Selection
public static SpimDataUtils.N5Sources resolveN5Selection(org.janelia.saalfeldlab.n5.ui.DataSelection selection, String name) BuildsSpimDataUtils.N5Sourcesfrom a user-madeDataSelection(e.g. from an interactiveDatasetSelectorDialog), reusing the same source-building logic as the automatic discovery inresolvePathToSource(String). Intended as a fallback UI for containers whose structureresolvePathToSource(String)could not resolve on its own.- Parameters:
selection- the user's dataset selectionname- display name for the resultingSpimDataUtils.N5Sources- Returns:
- the resolved sources
- Throws:
IllegalArgumentException- if no displayable sources are found
-
writeBdvN5Xml
public static void writeBdvN5Xml(File xmlFile, String n5DirName, long[][] levelDims, double[] voxelSize, String unit, int nTimepoints, String setupName) throws IOException Writes a BDV-compatible XML descriptor for an N5 dataset. The resulting XML can be opened by BigDataViewer, BigVolumeViewer, or any BDV-based tool viaXmlIoSpimDataMinimal.load().The descriptor references the N5 container using a relative path (assumes the XML sits next to the N5 directory). A single ViewSetup (id 0) is created with the supplied voxel size and calibration unit.
- Parameters:
xmlFile- the XML file to write (will be overwritten if it exists)n5DirName- name of the N5 container directory (relative to the XML file's parent; e.g.,"dataset_unmixed")levelDims- per-level dimensions:levelDims[level] = {x, y, z}voxelSize- physical voxel size at level 0:{sx, sy, sz}unit- calibration unit (e.g.,"um","pixel")nTimepoints- number of timepoints in the datasetsetupName- display name for the single ViewSetup (e.g.,"unmixed")- Throws:
IOException- if the file cannot be written
-
writeBdvN5Xml
public static void writeBdvN5Xml(File xmlFile, String n5DirName, long[][] levelDims, double[] voxelSize, String unit, int nTimepoints, String setupName, int nChannels) throws IOException - Throws:
IOException
-