From aaf45535556c34d325a8ac0c2e8a2be5838804d9 Mon Sep 17 00:00:00 2001 From: HaneenT Date: Mon, 23 Sep 2024 16:13:57 -0400 Subject: [PATCH 1/2] KPMP-5556: getPublicFileLink for zarr, getFileLink for all other file types --- src/components/SpatialViewer/viewConfigHelper.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/SpatialViewer/viewConfigHelper.js b/src/components/SpatialViewer/viewConfigHelper.js index 8effc4e..6fff825 100644 --- a/src/components/SpatialViewer/viewConfigHelper.js +++ b/src/components/SpatialViewer/viewConfigHelper.js @@ -48,20 +48,22 @@ export const populateViewConfig = async (viewConfig, selectedDataset) => { selectedDataset['relatedfiles'].forEach(function (item, index) { relatedFiles.push(JSON.parse(item)); }); - let dataUrl = getPublicFileLink(selectedDataset["packageid"], relatedFiles[0]['filename']); + let ext = relatedFiles[0]['filename'].split('.').pop(); + let dataUrl = (ext == "zarr") + ? getPublicFileLink(selectedDataset["packageid"], relatedFiles[0]['filename']) + : await getFileLink(relatedFiles[0]['packageid'] + "/" + relatedFiles[0]['filename']); stringifiedConfig = stringifiedConfig.replace(//gi, dataUrl); if (selectedDataset["configtype"] === "Segmentation Masks & Pathomics Vectors") { stringifiedConfig = stringifiedConfig.replace('', selectedDataset["filename"]); stringifiedConfig = stringifiedConfig.replace('', imageUrlResponse.data); - let wsiUrl = await getFileLink(relatedFiles[0]['packageid'] + "/" + relatedFiles[0]['filename']); - const loaders = await loadOmeTiff(wsiUrl.data); + const loaders = await loadOmeTiff(dataUrl.data); const physicalSizeX = unit(loaders.metadata.Pixels.PhysicalSizeX, (loaders.metadata.Pixels.PhysicalSizeXUnit.replace(/[µ|?]/g, 'u'))).to("um").toNumber(); const physicalSizeY = unit(loaders.metadata.Pixels.PhysicalSizeY, (loaders.metadata.Pixels.PhysicalSizeYUnit.replace(/[µ|?]/g, 'u'))).to("um").toNumber(); stringifiedConfig = stringifiedConfig.replace('""', physicalSizeX); stringifiedConfig = stringifiedConfig.replace('""', physicalSizeY); - selectedDataset = relatedFiles[0] - imageUrlResponse = wsiUrl + selectedDataset = relatedFiles[0]; + imageUrlResponse = dataUrl; } } stringifiedConfig = stringifiedConfig.replace('', selectedDataset["filename"]); From eb87121418f06b8d1e21d98500e52512c6604453 Mon Sep 17 00:00:00 2001 From: HaneenT Date: Tue, 24 Sep 2024 11:16:10 -0400 Subject: [PATCH 2/2] fix eqeq --- src/components/SpatialViewer/viewConfigHelper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SpatialViewer/viewConfigHelper.js b/src/components/SpatialViewer/viewConfigHelper.js index 6fff825..27e427c 100644 --- a/src/components/SpatialViewer/viewConfigHelper.js +++ b/src/components/SpatialViewer/viewConfigHelper.js @@ -49,7 +49,7 @@ export const populateViewConfig = async (viewConfig, selectedDataset) => { relatedFiles.push(JSON.parse(item)); }); let ext = relatedFiles[0]['filename'].split('.').pop(); - let dataUrl = (ext == "zarr") + let dataUrl = (ext === "zarr") ? getPublicFileLink(selectedDataset["packageid"], relatedFiles[0]['filename']) : await getFileLink(relatedFiles[0]['packageid'] + "/" + relatedFiles[0]['filename']); stringifiedConfig = stringifiedConfig.replace(//gi, dataUrl);