Skip to content

Commit

Permalink
Draft: Include support for neuroglancer url for umembargoed zarr and …
Browse files Browse the repository at this point in the history
…nifti
  • Loading branch information
Aaron Kanzer authored and Aaron Kanzer committed Oct 30, 2024
1 parent 49205b3 commit 4054676
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions web/src/views/FileBrowserView/FileBrowser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@
<v-list-item
v-for="el in item.services"
:key="el.name"
:href="el.url"
@click="el.isPublicNeuroglancer ? redirectNeuroglancerUrl(item) : null"
:href="!el.isPublicNeuroglancer ? el.url : null"
target="_blank"
rel="noreferrer"
>
Expand Down Expand Up @@ -330,7 +331,6 @@ const EXTERNAL_SERVICES = [
maxsize: 1e9,
endpoint: 'http://nwbexplorer.opensourcebrain.org/nwbfile=$asset_url$',
},
{
name: 'VTK/ITK Viewer',
regex: /\.ome\.zarr$/,
Expand All @@ -351,19 +351,23 @@ const EXTERNAL_SERVICES = [
maxsize: Infinity,
endpoint: 'https://neurosift.app?p=/nwb&url=$asset_dandi_url$&dandisetId=$dandiset_id$&dandisetVersion=$dandiset_version$', // eslint-disable-line max-len
},
{
name: 'Neurosift',
regex: /\.nwb\.lindi\.(json|tar)$/,
maxsize: Infinity,
endpoint: 'https://neurosift.app?p=/nwb&url=$asset_dandi_url$&st=lindi&dandisetId=$dandiset_id$&dandisetVersion=$dandiset_version$', // eslint-disable-line max-len
},
{
name: 'Neurosift',
regex: /\.avi$/,
maxsize: Infinity,
endpoint: 'https://neurosift.app?p=/avi&url=$asset_dandi_url$&dandisetId=$dandiset_id$&dandisetVersion=$dandiset_version$', // eslint-disable-line max-len
},
{
name: 'Neuroglancer',
regex: /\.nii(\.gz)?$|\.zarr$/,
maxsize: Infinity,
endpoint: '', // defaults to redirectNeuroglancerUrl logic
}
];
type Service = typeof EXTERNAL_SERVICES[0];
Expand Down Expand Up @@ -441,7 +445,7 @@ function getExternalServices(path: AssetPath, info: {dandisetId: string, dandise
// used, but we're forced to supply the internal DANDI URL for embargoed
// dandisets (since the ready-made S3 URL will prevent access in that case).
const assetUrl = embargoed.value ? assetDandiUrl : assetS3Url;
return EXTERNAL_SERVICES
.filter((service) => servicePredicate(service, path))
.map((service) => ({
Expand All @@ -453,6 +457,7 @@ function getExternalServices(path: AssetPath, info: {dandisetId: string, dandise
assetDandiUrl,
assetS3Url,
}),
isPublicNeuroglancer: service.name === 'Neuroglancer' && !embargoed.value,
}));
}
Expand Down Expand Up @@ -557,6 +562,30 @@ async function deleteAsset() {
itemToDelete.value = null;
}
function redirectNeuroglancerUrl(item: any) {
const assetS3Url = trimEnd((item.asset as AssetFile).url, '/');
const baseUrl = `https://neuroglancer-demo.appspot.com/#!`; // Public neuroglancer instance
const jsonObject = {
layers: [
{
type: "new",
source: assetS3Url.includes("zarr") ? `zarr://${assetS3Url}` : `nifti://${assetS3Url}`,
tab: "source",
name: item.asset.asset_id
}
],
selectedLayer: {
visible: true,
layer: item.asset.asset_id
},
layout: "4panel"
};
const jsonStr = JSON.stringify(jsonObject);
const encodedJson = encodeURIComponent(jsonStr);
window.open(`${baseUrl}${encodedJson}`);
}
// Update URL if location changes
watch(location, () => {
const { location: existingLocation } = route.query;
Expand Down

0 comments on commit 4054676

Please sign in to comment.