diff --git a/web/src/views/FileBrowserView/FileBrowser.vue b/web/src/views/FileBrowserView/FileBrowser.vue index a18072688..62ab51bc3 100644 --- a/web/src/views/FileBrowserView/FileBrowser.vue +++ b/web/src/views/FileBrowserView/FileBrowser.vue @@ -230,7 +230,8 @@ @@ -330,7 +331,6 @@ const EXTERNAL_SERVICES = [ maxsize: 1e9, endpoint: 'http://nwbexplorer.opensourcebrain.org/nwbfile=$asset_url$', }, - { name: 'VTK/ITK Viewer', regex: /\.ome\.zarr$/, @@ -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]; @@ -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) => ({ @@ -453,6 +457,7 @@ function getExternalServices(path: AssetPath, info: {dandisetId: string, dandise assetDandiUrl, assetS3Url, }), + isPublicNeuroglancer: service.name === 'Neuroglancer' && !embargoed.value, })); } @@ -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;