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

Include support for neuroglancer url for umembargoed zarr and nifti #2063

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
39 changes: 35 additions & 4 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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as for embargoed -- we are providing URLs unconditionally ATM but they would not even work for embargoed. Filed more generic:

target="_blank"
rel="noreferrer"
>
Expand Down Expand Up @@ -288,6 +289,7 @@ const FILES_PER_PAGE = 15;
interface AssetService {
name: string,
url: string,
isPublicNeuroglancer: boolean,
}

interface ExtendedAssetPath extends AssetPath {
Expand Down Expand Up @@ -330,7 +332,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 +352,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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should aim for adjusting the "schema" here to reflect this new need -- that we need

Suggested change
endpoint: '', // defaults to redirectNeuroglancerUrl logic
item_handler: 'redirectNeuroglancerUrl',

and then use that in the service code?

}
];
type Service = typeof EXTERNAL_SERVICES[0];
Expand Down Expand Up @@ -453,6 +458,7 @@ function getExternalServices(path: AssetPath, info: {dandisetId: string, dandise
assetDandiUrl,
assetS3Url,
}),
isPublicNeuroglancer: service.name === 'Neuroglancer' && !embargoed.value,
}));
}

Expand Down Expand Up @@ -557,6 +563,31 @@ 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