Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V05 dev2 #36

Merged
merged 44 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
425c53f
Handle 404 for /zarr.json AND /.zattrs
will-moore Jun 7, 2024
d709352
Load v0.5 schemas from github PR branch
will-moore Jun 7, 2024
23d9b26
Fix display of Array info for Zarr v3
will-moore Jun 12, 2024
190c0b7
Fix display of .zarray .zattrs and zarr.json in UI
will-moore Jun 12, 2024
6940281
Update loading of zarr chunks with zarrita
will-moore Jun 13, 2024
f6de93d
Handle 0.5-dev version
will-moore Jun 14, 2024
1054356
Top of 3D cube - align lines with front face
will-moore Jun 14, 2024
f650c1e
Update to zarrita.js 0.4.0-next.14
will-moore Jun 25, 2024
e5b5bef
Update version check to correspond to fix in schemas PR
will-moore Jun 28, 2024
fdd8a55
Handle v0.5-dev2 data
will-moore Jul 3, 2024
e150aa9
Load version.schema for v0.5 schemas
will-moore Jul 4, 2024
e12265f
Check dimension_names for all zarr.json
will-moore Jul 4, 2024
4f54cb4
Temporarily hard-code zarr3 for neuroglancer
joshmoore Jul 11, 2024
8070bc5
Fix loading of zarr v3 plates
will-moore Jul 11, 2024
3a1ecfb
Temporarily hard-code a zarrita-version of vizarr
joshmoore Jul 15, 2024
205ce33
Revert "Temporarily hard-code a zarrita-version of vizarr"
will-moore Aug 7, 2024
56b21f4
Support display of shards
will-moore Aug 14, 2024
7d1f32a
Handle labels for v0.5 data
will-moore Aug 16, 2024
290a066
Update zarrita to 0.4.0-next.15
will-moore Aug 16, 2024
723a104
Load and display Ro-create json
will-moore Aug 21, 2024
5159b0c
Check Ro-Crate name, description, license
will-moore Aug 21, 2024
b816514
Handle data with no sharding codecs
will-moore Aug 22, 2024
0256c07
Try to parse and lookup Organism and Imaging method from Ro-crate
will-moore Aug 22, 2024
e596e00
Use different warning levels for missing metadata
will-moore Aug 22, 2024
e09b012
Improve version checking. Handle missing version 0.4
will-moore Sep 2, 2024
d2dfb1f
Fix bioformats2raw page with v0.5 data
will-moore Sep 3, 2024
0efe2a2
Fix validation of Wells in Plate view
will-moore Sep 3, 2024
1d55e98
Add ro-crate-metadata support to bioformats2raw component
will-moore Sep 24, 2024
c0374f5
Load _version schema. Validate using 'attributes' as JSON root
will-moore Sep 27, 2024
4341aaa
remove console.trace()
will-moore Sep 27, 2024
eb21241
Only validate jsonData.attributes for v0.5 data
will-moore Sep 27, 2024
b1216b6
Handle /OME/zarr.json series metadata for bf2raw data
will-moore Oct 1, 2024
2853654
Fix bytesPerPixel for Zarr v3 dtypes
will-moore Oct 2, 2024
106f6ab
Fix copy-and-paste error in lookupImagingMethod()
will-moore Oct 12, 2024
2522eef
Add OME Logo to nav bar
will-moore Oct 14, 2024
3d4f4b4
Use omeLinkBlue for links etc
will-moore Oct 14, 2024
be301c6
Backgroud white
will-moore Oct 15, 2024
7298e01
Only Open With vizarr for v0.5 data
will-moore Oct 17, 2024
e0cfb42
Fix RO-Crate capitalisation
will-moore Oct 17, 2024
f8ceade
Add links from terms to Ontologies
will-moore Oct 17, 2024
ce6162a
Show Open-with on bioformats2raw page
will-moore Oct 21, 2024
6acf3b2
Fix Open-with links from bioformats2raw page
will-moore Oct 22, 2024
775c3d2
Cleanup and use schema from ome branch on NGFF repo
will-moore Oct 25, 2024
74f4e6f
Fix new-line at end of file
will-moore Oct 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@
cursor: default;
}
body {
--omeRed: #df283f;
--omeGreen: #128669;
--omeLinkBlue: #1d8dcd;
padding: 0;
font-family: "Overpass", -apple-system, BlinkMacSystemFont, "Segoe UI",
Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
Expand All @@ -230,7 +233,7 @@
background: white;
margin: 10px 0;
text-align: center;
box-shadow: 10px 10px 20px rgba(125, 22, 2, 0.5);
box-shadow: 10px 10px 20px rgba(212, 239, 253, 0.5);
width: 100%;
position: relative;
}
Expand Down
248 changes: 178 additions & 70 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
},
"dependencies": {
"ajv": "^8.11.0",
"ndarray": "^1.0.19",
"svelte-icons-pack": "^1.4.6",
"svelte-simple-modal": "^1.4.1",
"zarr": "^0.6.0"
"zarrita": "^0.4.0-next.15"
}
}
2 changes: 1 addition & 1 deletion public/ngff_viewers.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"name": "neuroglancer",
"logo": "/neuroglancer.png",
"//": "NB: The {URL} in the href is replaced with NGFF image URL",
"href": "https://neuroglancer-demo.appspot.com/#!{%22layers%22:[{%22source%22:%22zarr://{URL}%22,%22name%22:%22OME-NGFF%22}]}"
"href": "https://neuroglancer-demo.appspot.com/#!{%22layers%22:[{%22source%22:%22zarr3://{URL}%22,%22name%22:%22OME-NGFF%22}]}"
will-moore marked this conversation as resolved.
Show resolved Hide resolved
},
{
"name": "Allen Cell Feature Explorer 3D viewer",
Expand Down
43 changes: 43 additions & 0 deletions public/ome-main-nav.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 10 additions & 32 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import Modal from "svelte-simple-modal";
import SplashScreen from "./SplashScreen.svelte";

import { getJson } from "./utils";
import { getZarrGroupAttrs } from "./utils";
import CheckMark from "./CheckMark.svelte";

const searchParams = new URLSearchParams(window.location.search);
Expand All @@ -15,14 +15,17 @@
source = source.slice(0, -1);
}

let location = window.location.href;

let promise;

if (source) {
// load JSON to be validated...
console.log("Loading JSON... " + source + "/.zattrs");
promise = getJson(source + "/.zattrs");
console.log("Loading JSON... " + source);
promise = getZarrGroupAttrs(source);
}

function isBioFormats2Raw(data) {
let omeAttrs = data?.attributes?.ome || data;
return omeAttrs["bioformats2raw.layout"] === 3 && !omeAttrs.plate;
}
</script>

Expand All @@ -38,7 +41,7 @@
{:then data}
<Title {source} zattrs={data} />
<div>
{#if data["bioformats2raw.layout"] === 3 && !data.plate}
{#if isBioFormats2Raw(data)}
<Bioformats2rawLayout rootAttrs={data} {source} />
{:else}
<JsonValidator rootAttrs={data} {source} />
Expand Down Expand Up @@ -74,24 +77,7 @@
width: 100%;
flex: 1;
padding: 15px 0;
background: #ff512f; /* fallback for old browsers */
background: -webkit-linear-gradient(
to right,
#f09819,
#ff512f
); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(
to right,
#f09819,
#ff512f
); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
/* https://uigradients.com/ */
/* OME green->blue rgb(61,132,107), rgb(68,139,200) */
}

article {
width: 90%;
margin: auto;
background: white;
}

section > div {
Expand All @@ -108,14 +94,6 @@
section > div {
flex-direction: row;
}

article {
width: 60%;
margin: auto;
}
a {
white-space: nowrap;
}
}

.error {
Expand Down
105 changes: 87 additions & 18 deletions src/Bioformats2rawLayout/index.svelte
Original file line number Diff line number Diff line change
@@ -1,27 +1,83 @@
<script>
import { getXmlDom, getJson, validate } from "../utils";
import {
getJson,
getXmlDom,
getZarrGroupAttrs,
validate,
getVersion,
getZarrGroupAttrsFileName,
} from "../utils";
import JsonBrowser from "../JsonBrowser/index.svelte";
import ImageContainer from "../JsonValidator/Well/ImageContainer.svelte";
import RoCrate from "../JsonValidator/RoCrate/index.svelte";
import OpenWith from "../JsonValidator/OpenWithViewers/index.svelte";

export let source;
export let rootAttrs;

const metadataName = "OME/METADATA.ome.xml";

const version = getVersion(rootAttrs);
console.log("BF2RAW version", version, rootAttrs);
const zarrAttrsFileName = getZarrGroupAttrsFileName(version);
console.log("zarrAttrsFileName", zarrAttrsFileName);

// source/OME/METADATA.ome.xml
const metadataUrl = `${source}/${metadataName}`;

async function loadXml(url) {
let dom = await getXmlDom(url);
async function loadXmlOrSeries(url) {
// We can get the series info from /OME/METADATA.ome.xml or
// /OME/zarr.json group attributes
// returns {images: [{name, id}]} or {error: message}
let dom;
try {
dom = await getXmlDom(url);
} catch (error) {}
let xmlRsp;
if (dom) {
xmlRsp = parseXml(dom);
}
// Try to get series info
let rsp = {};
let series;
try {
let zarrAttrs = await getJson(`${source}/OME/${zarrAttrsFileName}`);
series = zarrAttrs?.attributes?.ome?.series || zarrAttrs.series;
} catch (error) {}

if (series && xmlRsp && xmlRsp?.images) {
// MUST match if we have both...
if (series.length !== xmlRsp.images.length) {
rsp.errors = [
`Length mismatch: series: ${series.length} != ome.xml: ${5}`,
will-moore marked this conversation as resolved.
Show resolved Hide resolved
];
}
}
if (series) {
rsp.images = series.map((seriesName) => ({
name: seriesName,
path: seriesName,
}));
} else if (xmlRsp) {
rsp = xmlRsp;
} else {
rsp.errors = ["No OME/METADATA.ome.xml or /OME series found"];
}
return rsp;
}

function parseXml(dom) {
const root = dom.documentElement;

let rsp = { images: [] };
let index = 0;
for (const child of root.children) {
console.log(child.tagName);
if (child.tagName === "Image") {
rsp.images.push({
name: child.getAttribute("Name"),
id: child.getAttribute("ID"),
path: "" + index++,
});
}
// error handling - parsererror gives html doc
Expand All @@ -35,12 +91,12 @@
}
return rsp;
}
const promise = loadXml(metadataUrl);
const promise = loadXmlOrSeries(metadataUrl);

// wait for schema to be cached, so we don't load them multiple times
// let schemasPromise = getSchema("0.2", "image");
async function preloadSchema(imagePath) {
let imgAttrs = await getJson(imagePath + "/.zattrs");
let imgAttrs = getZarrGroupAttrs(imagePath);
console.log("preloadSchema", imgAttrs);
let errs = await validate(imgAttrs);
return errs;
Expand All @@ -53,32 +109,36 @@
</script>

<article>
Reading: <a href={source}>/{zarrName}/.zattrs</a>

<div class="json">
<JsonBrowser name="" version="" contents={rootAttrs} expanded />
</div>
Reading: <a href={source}>/{zarrName}/{zarrAttrsFileName}</a>

Loading metadata:<a href={metadataUrl}>{metadataName}</a><br />

{#await promise}
<div>loading {metadataUrl}...</div>
{:then metadataJson}
<!-- Show list of Images -->
<h1>Images</h1>
<h1>{metadataJson.images.length} Images</h1>
<ol>
{#await preloadSchema(source + "/0")}
<div>loading schema...</div>
{:then ok}
<ul>
{#each metadataJson.images as image, i}
{#each metadataJson.images as image}
<li class="image">
/{i}
<a title="Open Image" href="{url}?source={source}/{i}/"
/{image.path}
<a title="Open Image" href="{url}?source={source}/{image.path}/"
>{image.name}</a
>

<ImageContainer {source} path={i} />
<ImageContainer {source} path={image.path} />

<a title="Open Image" href="{url}?source={source}/{image.path}/"
>Open in validator</a
>

<div style="margin-top: 10px">
<OpenWith source={`${source}/${image.path}`} dtype={"image"} {version} />
</div>
</li>
{/each}
</ul>
Expand All @@ -87,10 +147,15 @@
{/await}
</ol>

<h3>{zarrName}/{zarrAttrsFileName}</h3>
<div class="json">
<JsonBrowser name="" version="" contents={rootAttrs} expanded />
</div>

<!-- Error handling... -->
{#if metadataJson.errors}
<div class="error">
<h2>Error parsing {metadataName}</h2>
<h3>Error loading series metadata:</h3>
{#each metadataJson.errors as err, i}
<div>{err}</div>
{/each}
Expand All @@ -99,16 +164,20 @@
{:catch error}
<p style="color: red">{error.message}</p>
{/await}

<!-- for v0.5+ we check for ro-crate-metadata.json -->
{#if !["0.1", "0.2", "0.3", "0.4"].includes(version)}
<RoCrate {source}></RoCrate>
{/if}
</article>

<style>

h1 {
margin-top: 20px;
}
a,
a:visited {
color: #ff512f;
color: var(--omeLinkBlue);
}

.json {
Expand Down
31 changes: 31 additions & 0 deletions src/JsonBrowser/DetailsPrePanel.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@


<script>
export let jsonData;
export let summary;
</script>

<details>
<summary>{summary}</summary>
<pre><code>{JSON.stringify(jsonData, null, 2)}</code></pre>
</details>


<style>

details {
font-size: 1.1em;
text-align: left;
margin: 0 15px;
}
pre {
margin-top: 10px;
color: #faebd7;
background-color: #2c3e50;
padding: 10px;
font-size: 14px;
border-radius: 10px;
overflow: auto;
}

</style>
will-moore marked this conversation as resolved.
Show resolved Hide resolved
Loading