@@ -1107,13 +1106,14 @@ export default {
if (this.mapImp) {
if (flag) {
for (const [key, value] of Object.entries(this.anatomyImages)) {
- this.mapImp.addMarker(key, { className: "slandered-marker", cluster: false })
+ this.mapImp.addMarker(key, { className: "standard-marker", cluster: false })
const id = this.mapImp.addImage(key, value[0].thumbnail)
if (id) this.imageIds.push(id)
}
} else {
this.mapImp.clearMarkers();
this.imageIds.forEach((id) => this.mapImp.removeImage(id))
+ this.imageIds = []
}
}
},
From 3021eaa2b578591736142177512d585a96a717ca Mon Sep 17 00:00:00 2001
From: "David J. Yu" <87633683+ddjnw1yu@users.noreply.github.com>
Date: Fri, 16 Aug 2024 15:28:44 +1200
Subject: [PATCH 07/47] Update flatmap-viewer version
---
package-lock.json | 8 ++++----
package.json | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 9ec79a49..6b9207b7 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,7 +9,7 @@
"version": "1.4.0",
"license": "Apache-2.0",
"dependencies": {
- "@abi-software/flatmap-viewer": "3.1.0",
+ "@abi-software/flatmap-viewer": "3.1.2",
"@abi-software/map-utilities": "1.0.0-beta.1",
"@abi-software/sparc-annotation": "0.3.1",
"@abi-software/svg-sprite": "1.0.0",
@@ -43,9 +43,9 @@
}
},
"node_modules/@abi-software/flatmap-viewer": {
- "version": "3.1.0",
- "resolved": "https://registry.npmjs.org/@abi-software/flatmap-viewer/-/flatmap-viewer-3.1.0.tgz",
- "integrity": "sha512-5X8KgSv95qFWg7cYFRnsiIOgfZMrE0j3ZznIjUIljKMtid/FhuuopmqMTY/YKEwaHIAW8rQvBss4edybPsPhnA==",
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/@abi-software/flatmap-viewer/-/flatmap-viewer-3.1.2.tgz",
+ "integrity": "sha512-fwpBE+LsJtxqkwnfJXCD0BrP1wdfw6632cKOaXRUnfQ5LnzXuvbbJL5NAo6K7PmmWsvnJYTqy/ssBEgmltCmNw==",
"dependencies": {
"@deck.gl/core": "^9.0.17",
"@deck.gl/geo-layers": "^9.0.18",
diff --git a/package.json b/package.json
index c964ce9a..214b0b16 100644
--- a/package.json
+++ b/package.json
@@ -43,7 +43,7 @@
"./src/*": "./src/*"
},
"dependencies": {
- "@abi-software/flatmap-viewer": "3.1.0",
+ "@abi-software/flatmap-viewer": "3.1.2",
"@abi-software/map-utilities": "1.0.0-beta.1",
"@abi-software/sparc-annotation": "0.3.1",
"@abi-software/svg-sprite": "1.0.0",
From 08e94b7f7a8b211b20627f37dfbf55a487344dbc Mon Sep 17 00:00:00 2001
From: "David J. Yu" <87633683+ddjnw1yu@users.noreply.github.com>
Date: Mon, 19 Aug 2024 14:17:51 +1200
Subject: [PATCH 08/47] Add select box for selecting different image type
---
package-lock.json | 2 +-
package.json | 2 +-
src/components/FlatmapVuer.vue | 85 +++++++++++++++++++++++++++-------
3 files changed, 70 insertions(+), 19 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 6b9207b7..9d52dd9e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,7 +10,7 @@
"license": "Apache-2.0",
"dependencies": {
"@abi-software/flatmap-viewer": "3.1.2",
- "@abi-software/map-utilities": "1.0.0-beta.1",
+ "@abi-software/map-utilities": "^1.0.0-beta.1",
"@abi-software/sparc-annotation": "0.3.1",
"@abi-software/svg-sprite": "1.0.0",
"@element-plus/icons-vue": "^2.3.1",
diff --git a/package.json b/package.json
index 214b0b16..97cac0de 100644
--- a/package.json
+++ b/package.json
@@ -44,7 +44,7 @@
},
"dependencies": {
"@abi-software/flatmap-viewer": "3.1.2",
- "@abi-software/map-utilities": "1.0.0-beta.1",
+ "@abi-software/map-utilities": "^1.0.0-beta.1",
"@abi-software/sparc-annotation": "0.3.1",
"@abi-software/svg-sprite": "1.0.0",
"@element-plus/icons-vue": "^2.3.1",
diff --git a/src/components/FlatmapVuer.vue b/src/components/FlatmapVuer.vue
index dee39440..2c8456c6 100644
--- a/src/components/FlatmapVuer.vue
+++ b/src/components/FlatmapVuer.vue
@@ -503,14 +503,37 @@ Please use `const` to assign meaningful names to them...
View Image
-
- Hide
- Show
-
+
+
+ Hide
+ Show
+
+
+
+
+
+
+ {{ item }}
+
+
+
+
Flight path display
@@ -1096,24 +1119,50 @@ export default {
this.addAnnotationFeature()
}
},
+ removeImageFromMap: function () {
+ if (this.mapImp) {
+ this.mapImp.clearMarkers();
+ this.imageIds.forEach((id) => this.mapImp.removeImage(id))
+ this.imageIds = []
+ }
+ },
+ populateImageToMap: function () {
+ if (this.mapImp) {
+ for (const [key, value] of Object.entries(this.anatomyImages)) {
+ this.mapImp.addMarker(key, { className: "standard-marker", cluster: false })
+ const id = this.mapImp.addImage(key, value[0].thumbnail)
+ if (id) this.imageIds.push(id)
+ }
+ }
+ },
/**
* @vuese
- * Function to switch the type of person who annotated.
+ * Function to switch the type of displayed image.
+ * @arg flag
+ */
+ setImageType: function (flag) {
+ this.imageType = flag
+ if (this.mapImp) {
+ if (flag === 'Biolucida') {
+ this.populateImageToMap()
+ } else {
+ console.log('switch to', flag);
+ this.removeImageFromMap()
+ }
+ }
+ },
+ /**
+ * @vuese
+ * Function to switch show or hide images.
* @arg flag
*/
setImage: function (flag) {
this.imageRadio = flag
if (this.mapImp) {
if (flag) {
- for (const [key, value] of Object.entries(this.anatomyImages)) {
- this.mapImp.addMarker(key, { className: "standard-marker", cluster: false })
- const id = this.mapImp.addImage(key, value[0].thumbnail)
- if (id) this.imageIds.push(id)
- }
+ this.setImageType(this.imageType)
} else {
- this.mapImp.clearMarkers();
- this.imageIds.forEach((id) => this.mapImp.removeImage(id))
- this.imageIds = []
+ this.removeImageFromMap()
}
}
},
@@ -2811,6 +2860,8 @@ export default {
}),
imageRadio: false,
imageIds: [],
+ imageType: 'Biolucida',
+ imageTypes: ['Biolucida', 'Plot', 'Scaffold', 'Segmentation'],
}
},
computed: {
From 3ee9039fa72fd6b037389ee7fa5e547b984c90d7 Mon Sep 17 00:00:00 2001
From: "David J. Yu" <87633683+ddjnw1yu@users.noreply.github.com>
Date: Tue, 20 Aug 2024 16:36:21 +1200
Subject: [PATCH 09/47] Modify image selector based on new image api
---
src/App.vue | 14 +-
src/components/FlatmapVuer.vue | 48 ++--
src/components/MultiFlatmapVuer.vue | 8 -
src/mixins/imageMixin.js | 369 +++++++++++++++-------------
4 files changed, 233 insertions(+), 206 deletions(-)
diff --git a/src/App.vue b/src/App.vue
index 49e33907..26b8e3d6 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -83,7 +83,6 @@
@open-pubmed-url="onOpenPubmedUrl"
@pathway-selection-changed="onPathwaySelectionChanged"
@flatmapChanged="onFlatmapChanged"
- :anatomyImages="anatomyImages"
/>
{
let featureGeometry = { lng: 0, lat: 0, }
@@ -773,6 +774,7 @@ const createUnfilledTooltipData = function () {
*/
export default {
name: 'FlatmapVuer',
+ mixins:[imageMixin],
components: {
Button,
Col,
@@ -1128,27 +1130,38 @@ export default {
},
populateImageToMap: function () {
if (this.mapImp) {
- for (const [key, value] of Object.entries(this.anatomyImages)) {
- this.mapImp.addMarker(key, { className: "standard-marker", cluster: false })
- const id = this.mapImp.addImage(key, value[0].thumbnail)
- if (id) this.imageIds.push(id)
+ for (const [key, value] of Object.entries(this.anatomyImages[this.imageType])) {
+ if (value.length) {
+ const id = this.mapImp.addImage(key, value[0].thumbnail)
+ if (id) {
+ this.imageIds.push(id)
+ this.mapImp.addMarker(key, { className: "standard-marker", cluster: false })
+ }
+ }
}
}
},
/**
* @vuese
* Function to switch the type of displayed image.
- * @arg flag
+ * @arg type
*/
- setImageType: function (flag) {
- this.imageType = flag
+ setImageType: async function (type) {
+ this.imageType = type
if (this.mapImp) {
- if (flag === 'Biolucida') {
- this.populateImageToMap()
+ this.loading = true
+ const anatomicalIdentifiers = this.mapImp.anatomicalIdentifiers
+ this.removeImageFromMap()
+ if (type === 'Image' && !(type in this.anatomyImages)) {
+ this.anatomyImages[type] = await this.getBiolucidaThumbnails("id", anatomicalIdentifiers)
+ } else if (type === 'Segmentation' && !(type in this.anatomyImages)) {
+ this.anatomyImages[type] = await this.getSegmentationThumbnails("id", anatomicalIdentifiers)
} else {
- console.log('switch to', flag);
- this.removeImageFromMap()
+ console.log('switch to', type);
}
+ this.populateMapWithImages(this.mapImp, this.anatomyImages[type], type)
+ // this.populateImageToMap()
+ this.loading = false
}
},
/**
@@ -1790,8 +1803,8 @@ export default {
if (data.feature.type === 'marker') {
this.tooltipType = 'image'
- if (data.resource[0] in this.anatomyImages) {
- this.imageEntry = this.anatomyImages[data.resource[0]]
+ if (data.resource[0] in this.anatomyImages[this.imageType]) {
+ this.imageEntry = this.anatomyImages[this.imageType][data.resource[0]]
}
// this.displayTooltip(data.feature.models)
@@ -2725,10 +2738,6 @@ export default {
type: Boolean,
default: false,
},
- anatomyImages: {
- type: Object,
- default: {},
- },
},
provide() {
return {
@@ -2858,10 +2867,11 @@ export default {
without: true,
}
}),
+ anatomyImages: {},
imageRadio: false,
imageIds: [],
- imageType: 'Biolucida',
- imageTypes: ['Biolucida', 'Plot', 'Scaffold', 'Segmentation'],
+ imageType: 'Image',
+ imageTypes: ['Image', 'Plot', 'Scaffold', 'Segmentation'],
}
},
computed: {
diff --git a/src/components/MultiFlatmapVuer.vue b/src/components/MultiFlatmapVuer.vue
index 53502ba1..1ea3adf8 100644
--- a/src/components/MultiFlatmapVuer.vue
+++ b/src/components/MultiFlatmapVuer.vue
@@ -82,7 +82,6 @@
:flatmapAPI="flatmapAPI"
:rootURL="rootURL"
:sparcAPI="sparcAPI"
- :anatomyImages="anatomyImages"
/>
@@ -725,13 +724,6 @@ export default {
type: Boolean,
default: false,
},
- /**
- * The option to show connectivity information in sidebar
- */
- anatomyImages: {
- type: Object,
- default: {},
- },
},
data: function () {
return {
diff --git a/src/mixins/imageMixin.js b/src/mixins/imageMixin.js
index fc4b520f..ca8b4365 100644
--- a/src/mixins/imageMixin.js
+++ b/src/mixins/imageMixin.js
@@ -1,189 +1,222 @@
-const imageQuery = '"*jp2* OR *vnd.ome.xml* OR *jpx*"';
-
-const getView2DImageLink = (rootURL, datasetId, datasetVersion, filePath) => {
- return `${rootURL}datasets/file/${datasetId}/${datasetVersion}?path=files/${filePath}`;
-};
-
-const getView3DImageLink = (
- rootURL,
- datasetId,
- datasetVersion,
- dataset_image
-) => {
- const viewEncoding = dataset_image.share_link.replace(
- "https://sparc.biolucida.net/image?c=",
- ""
- );
- return (
- rootURL +
- "datasets/biolucidaviewer/" +
- dataset_image.image_id +
- "?view=" +
- viewEncoding +
- "&dataset_version=" +
- datasetVersion +
- "&dataset_id=" +
- datasetId +
- "&item_id=" +
- dataset_image.sourcepkg_id
- );
-};
-
-const getBiolucidaInfo = async function (sparcAPI, datasetId) {
- return new Promise((resolve, reject) => {
- const endpoint = `${sparcAPI}image_search/${datasetId}`;
- fetch(endpoint)
- .then((response) => response.json())
- .then((data) => {
- if (data.status == "success") {
- let imageObjects = {};
- data.dataset_images.forEach((image) => {
- if (!(image.image_id in imageObjects)) {
- imageObjects[image.image_id] = image;
- }
- });
- resolve(imageObjects);
- } else {
- reject(data.reason);
- }
- });
+const getFilesInfo = async (api, key, idsList, types) => {
+ let params = new URLSearchParams();
+ types.forEach((type) => {
+ params.append("arrayparams", type);
+ params.append("arrayparams", type);
});
-};
-
-const getAnnotatedBiolucida = function (data) {
- let bioList = [];
- let bio2DIds = [];
- if ("biolucida-2d" in data) {
- const bio2DLength = data["biolucida-2d"].length;
- for (let i = 0; i < bio2DLength; i++) {
- const biolucida = data["biolucida-2d"][i];
- if (biolucida.biolucida) {
- bioList.push(biolucida);
- bio2DIds.push(biolucida.biolucida.identifier);
- }
+ let response = await fetch(`${api}get-organ-curies/?${params}`);
+ let data = await response.json();
+ const identifiers = [];
+ data.uberon.array.forEach((pair) => {
+ const identifier = {
+ id: pair.id.toUpperCase(),
+ name: pair.name,
+ };
+ if (idsList.includes(identifier[key])) {
+ identifiers.push(identifier);
}
- }
- if ("biolucida-3d" in data) {
- const bio3DLength = data["biolucida-3d"].length;
- for (let i = 0; i < bio3DLength; i++) {
- const biolucida = data["biolucida-3d"][i];
- if (biolucida.biolucida) {
- bioList.push(biolucida);
- }
- }
- }
- return { bioList, bio2DIds };
+ });
+ const keys = identifiers.map((item) => item[key]);
+ response = await fetch(`${api}get-files-info-for-curies`, {
+ method: "POST",
+ body: JSON.stringify({
+ filetypes: types,
+ curies: keys,
+ }),
+ headers: {
+ "Content-Type": "application/json",
+ },
+ });
+ data = await response.json();
+ return data;
};
export default {
- // Note that the setting store is included in MapContent.vue
methods: {
- populateAnatomyImageObjects: function (datasets) {
- let anatomyCurieImageObjects = {};
- let anatomyNameImageObjects = {};
- const datasetsLength = datasets.length;
- for (let i = 0; i < datasetsLength; i++) {
- const dataset = datasets[i];
- if (dataset.value && dataset.value.length) {
- const imagesLength = dataset.value.length;
- for (let j = 0; j < imagesLength; j++) {
- const image = dataset.value[j];
- if (image.anatomy && image.anatomy.length) {
- const anatomyLength = image.anatomy.length;
- for (let k = 0; k < anatomyLength; k++) {
- const anatomy = image.anatomy[k];
- if (!(anatomy.curie in anatomyCurieImageObjects)) {
- anatomyCurieImageObjects[anatomy.curie] = [];
- }
- anatomyCurieImageObjects[anatomy.curie].push(image);
- if (!(anatomy.name in anatomyNameImageObjects)) {
- anatomyNameImageObjects[anatomy.name] = [];
+ getBiolucidaThumbnails: async function (key, idsList) {
+ try {
+ const data = await getFilesInfo(this.sparcAPI, key, idsList, [
+ "biolucida-2d",
+ "biolucida-3d",
+ ]);
+ if (data["files_info"]) {
+ const images = {};
+ for (const [key, value] of Object.entries(data["files_info"])) {
+ if (value.length > 0) {
+ const list = [];
+ value.forEach((entry) => {
+ if (entry.biolucida_id) {
+ let image = {
+ thumbnail: this.getBiolucidaThumbnailURL(
+ entry.biolucida_id
+ ),
+ id: entry.id,
+ title: entry.file_path.substring(
+ entry.file_path.lastIndexOf("/") + 1
+ ),
+ type: "Image",
+ link: `https://sparc.biolucida.net/api/v1/thumbnail/${entry.biolucida_id}`,
+ mimetype: 'image/png'
+ };
+ list.push(image);
}
- anatomyNameImageObjects[anatomy.name].push(image);
- }
+ });
+ images[key] = list;
}
}
+ return images;
}
- }
- return {
- "anatomyCurie": anatomyCurieImageObjects,
- "anatomyName": anatomyNameImageObjects
- };
- },
-
- processResults: async function (results) {
- try {
- let datasets = [];
- const dataType = "Image";
- console.log("starting promise list");
- let promiseList = results.map(async (result) => {
- const datasetId = result.dataset_identifier;
- const datasetVersion = result.dataset_version;
- const biolucidaInfo = await getBiolucidaInfo(
- this.sparcAPI,
- datasetId
- );
- const imageIds = Object.values(biolucidaInfo).map(
- (image) => image.image_id
- );
- const { bioList, bio2DIds } = getAnnotatedBiolucida(result);
- return bioList
- .filter((bioImage) =>
- imageIds.includes(bioImage.biolucida.identifier)
- )
- .map((bioImage) => {
- const datasetImage = biolucidaInfo[bioImage.biolucida.identifier];
- const link = bio2DIds.includes(bioImage.biolucida.identifier)
- ? getView2DImageLink(
- this.rootURL,
- datasetId,
- datasetVersion,
- bioImage.dataset.path
- )
- : getView3DImageLink(
- this.rootURL,
- datasetId,
- datasetVersion,
- datasetImage
- );
- return {
- title: bioImage.name,
- anatomy: result.organs,
- species: result.organisms,
- datasetId: datasetId,
- datasetVersion: datasetVersion,
- link: link,
- type: dataType,
- thumbnail: datasetImage.thumbnail_url,
- };
- });
- });
- console.log("promiseList:", promiseList);
- let promiseResult = await Promise.allSettled(promiseList);
- datasets = promiseResult.flat();
- console.log("promiseResult:", promiseResult);
- return datasets;
} catch (error) {
console.error("Error:", error);
- return [];
}
+ return {};
},
-
- getImageDatasetFromScicrunch: async function () {
- const endpoint =
- `${this.sparcAPI}multiple_dataset_info/using_multiple_mimetype/?` +
- `${new URLSearchParams({ q: imageQuery })}`;
+ getBiolucidaThumbnailURL: function (biolucidaId) {
+ return `${this.sparcAPI}thumbnail/${biolucidaId}`;
+ },
+ getSegmentationThumbnails: async function (key, idsList) {
try {
- const response = await fetch(endpoint);
- const data = await response.json();
- if (data.numberOfHits >= 1) {
- let datasets = await this.processResults(data.results);
- return { success: true, datasets: datasets };
+ const data = await getFilesInfo(this.sparcAPI, key, idsList, [
+ "mbf-segmentation",
+ ]);
+ if (data["files_info"]) {
+ const images = {};
+ for (const [key, value] of Object.entries(data["files_info"])) {
+ if (value.length > 0) {
+ const list = [];
+ value.forEach((entry) => {
+ let image = {
+ thumbnail: this.getSegmentationThumbnailURL(
+ entry.id,
+ entry.version,
+ entry.file_path
+ ),
+ id: entry.id,
+ title: entry.file_path.substring(
+ entry.file_path.lastIndexOf("/") + 1
+ ),
+ type: "Segmentation",
+ link: this.getBiolucidaThumbnailURL(entry.biolucida_id),
+ };
+ list.push(image);
+ });
+ images[key] = list;
+ }
+ }
+ return images;
}
- return { success: false, error: "No datasets found" };
} catch (error) {
- return { success: false, error: error };
+ console.error("Error:", error);
+ }
+ return {};
+ },
+ getSegmentationThumbnailURL: function (
+ datasetId,
+ datasetVersion,
+ filePath
+ ) {
+ return `${this.sparcAPI}/thumbnail/neurolucida?datasetId=${datasetId}&version=${datasetVersion}&path=files/${filePath}`;
+ },
+ populateMapWithImages: function (mapImp, images, type) {
+ for (const [key, list] of Object.entries(images)) {
+ this.downloadAndCreateImageThumbnailMarkerUrl(mapImp, key, list, type);
}
},
+ downloadAndCreateImageThumbnailMarkerUrl: function (
+ mapImp,
+ key,
+ list,
+ type
+ ) {
+ const count = list.length;
+ if (count > 0) {
+ //Pick a random image
+ const index = Math.floor(Math.random() * count);
+ const thumbnail = list[index].thumbnail;
+ this.getThumbnail(thumbnail, type)
+ .then((wrappedElement) => {
+ this.createImageThumbnailMarkerUrl(mapImp, key, wrappedElement);
+ })
+ .catch(() => {
+ //Failed to download, pick another one
+ list.splice(index);
+ this.downloadAndCreateImageThumbnailMarkerUrl(
+ mapImp,
+ key,
+ list,
+ type
+ );
+ });
+ }
+ },
+ getThumbnail: async function (url, type) {
+ return new Promise((resolve, reject) => {
+ if (type === "Segmentation" || type === "Image") {
+ this.getBinaryThumbnail(url)
+ .then((response) => resolve(response))
+ .catch((response) => reject(response));
+ } else {
+ this.getGenericThumbnail(url)
+ .then((response) => resolve(response))
+ .catch((response) => reject(response));
+ }
+ });
+ },
+ getBinaryThumbnail: async function (url) {
+ return new Promise((resolve, reject) => {
+ fetch(url)
+ .then((response) => {
+ if (response.status >= 200 && response.status < 300) {
+ return response.text();
+ } else {
+ reject();
+ }
+ })
+ .then((data) => {
+ if (data) {
+ let img = new Image();
+ let wrapperElement = document.createElement("div");
+ img.style = "height: auto;width: 50px;margin-right: 80px;";
+ img.onload = function () {
+ wrapperElement.appendChild(img);
+ resolve(wrapperElement);
+ };
+ img.onerror = function () {
+ reject(new Error("Failed to load image at " + url));
+ };
+ img.src = `data:'image/png';base64,${data}`;
+ } else {
+ reject(new Error("Failed to load image at " + url));
+ }
+ });
+ });
+ },
+ getGenericThumbnail: async function (url) {
+ return new Promise((resolve, reject) => {
+ let img = new Image();
+ let wrapperElement = document.createElement("div");
+ img.style = "height: auto;width: 50px;margin-right: 80px;";
+ img.onload = function () {
+ wrapperElement.appendChild(img);
+ resolve(wrapperElement);
+ };
+ img.onerror = function () {
+ reject(new Error("Failed to load image at " + url));
+ };
+ img.src = url;
+ });
+ },
+ createImageThumbnailMarkerUrl: function (mapImp, id, wrapperElement) {
+ // add it to the flatmap
+ const markerIdentifier = mapImp.addMarker(id, {
+ element: wrapperElement,
+ className: "highlight-marker",
+ cluster: false,
+ type: "image",
+ });
+
+ const marker = mapImp.addMarker(id);
+ return marker;
+ },
},
};
From e23211ea3117b882151671411a49e228e18eae9e Mon Sep 17 00:00:00 2001
From: alan-wu
Date: Wed, 21 Aug 2024 14:43:23 +1200
Subject: [PATCH 10/47] Support scaffold in display image mode.
---
src/components/FlatmapVuer.vue | 8 +++-
src/mixins/flatmapImageMixin.js | 3 +-
src/services/scicrunchMixin.js | 72 +++++++++++++++++++++++++++++----
3 files changed, 73 insertions(+), 10 deletions(-)
diff --git a/src/components/FlatmapVuer.vue b/src/components/FlatmapVuer.vue
index 5705b1cc..6c155a13 100644
--- a/src/components/FlatmapVuer.vue
+++ b/src/components/FlatmapVuer.vue
@@ -2491,7 +2491,11 @@ export default {
if (this.mapImp) {
this.mapImp.clearMarkers()
const anatomicalIdentifiers = this.mapImp.anatomicalIdentifiers
- if (type === "Segmentations") {
+ if (type === "Scaffolds") {
+ let images = await this.getScaffoldThumbnails("id", anatomicalIdentifiers)
+ this.images = images
+ this.populateFlatmapWithImages(this.mapImp, images, type)
+ } else if (type === "Segmentations") {
let images = await this.getSegmentationsThumbnails("id", anatomicalIdentifiers)
this.images = images
this.populateFlatmapWithImages(this.mapImp, images, type)
@@ -2788,7 +2792,7 @@ export default {
drawnType: 'All tools',
drawnTypes: ['All tools', 'Point', 'LineString', 'Polygon', 'None'],
imageType: 'None',
- imageTypes: ['Segmentations', 'Images', 'None'],
+ imageTypes: ['Images', 'Scaffolds', 'Segmentations', 'None'],
annotatedType: 'Anyone',
annotatedTypes: ['Anyone', 'Me', 'Others'],
openMapRef: undefined,
diff --git a/src/mixins/flatmapImageMixin.js b/src/mixins/flatmapImageMixin.js
index 6d15df92..e2c28288 100644
--- a/src/mixins/flatmapImageMixin.js
+++ b/src/mixins/flatmapImageMixin.js
@@ -63,7 +63,8 @@ export default {
getThumbnail: async function(url, type) {
return new Promise((resolve, reject) => {
if (type === "Segmentations" ||
- type === "Images") {
+ type === "Images" ||
+ type === "Scaffolds") {
this.getBinaryThumbnail(url)
.then((response) => resolve(response))
.catch((response) => reject(response))
diff --git a/src/services/scicrunchMixin.js b/src/services/scicrunchMixin.js
index 954d7355..fa38cc89 100644
--- a/src/services/scicrunchMixin.js
+++ b/src/services/scicrunchMixin.js
@@ -25,8 +25,7 @@ const getBiolucidaInfo = async (sparcAPI, datasetId) => {
const getFilesInfo = async (api, key, idsList, types) => {
let params = new URLSearchParams();
types.forEach((type) => {
- params.append('arrayparams', type);
- params.append('arrayparams', type);
+ params.append('filetypes', type);
});
let response = await fetch(`${api}/get-organ-curies/?${params}`);
let data = await response.json();
@@ -60,12 +59,9 @@ const getFilesInfo = async (api, key, idsList, types) => {
export default {
// Note that the setting store is included in MapContent.vue
methods: {
- getThumbnailURL: function(thumbnailId) {
+ getBiolucidaThumbnailURL: function(thumbnailId) {
return `${this.sparcAPI}/thumbnail/${thumbnailId}`
},
- getSegmentationThumbnailURL: function(datasetId, datasetVersion, filePath) {
- return `${this.sparcAPI}/thumbnail/neurolucida?datasetId=${datasetId}&version=${datasetVersion}&path=files/${filePath}`;
- },
getBiolucidaThumbnails: async function (key, idsList) {
try {
const data = await getFilesInfo(this.sparcAPI, key, idsList, ["biolucida-2d", "biolucida-3d"]);
@@ -77,7 +73,8 @@ export default {
value.forEach((entry) => {
if (entry.biolucida_id) {
let image = {
- thumbnail: this.getThumbnailURL(entry.biolucida_id),
+ thumbnail: this.getBiolucidaThumbnailURL(entry.biolucida_id),
+ resource: entry.file_path,
datasetId: entry.id,
}
list.push(image);
@@ -93,6 +90,63 @@ export default {
}
return {};
},
+ findEntryWithPathInArray(entry, list, type) {
+ if (entry && list) {
+ for (let i = 0; i < entry.isSourceOf.length; i++) {
+ for (let l = 0; l < list.length; l++) {
+ const item = list[l];
+ if (entry.id === item.id && (!type || item.type === type) &&
+ entry.isSourceOf[i] === item.file_path) {
+ return item;
+ }
+ }
+ }
+ }
+ return undefined
+ },
+ getScaffoldThumbnailURL: function(entry, list) {
+ const viewEntry = this.findEntryWithPathInArray(
+ entry, list, "abi-scaffold-view-file");
+ const thumbnailEntry = this.findEntryWithPathInArray(
+ viewEntry, list, "abi-thumbnail");
+ if (thumbnailEntry) {
+ return `${this.sparcAPI}/s3-resource/${thumbnailEntry.id}/files/${thumbnailEntry.file_path}?${new URLSearchParams({encodeBase64: true})}`;
+ }
+ return undefined;
+ },
+ getScaffoldThumbnails: async function (key, idsList) {
+ try {
+ const data = await getFilesInfo(this.sparcAPI, key, idsList,
+ ["abi-thumbnail", "abi-scaffold-metadata-file", 'abi-scaffold-view-file']);
+ if (data['files_info']) {
+ const images = {};
+ for (const [key, value] of Object.entries(data['files_info'])) {
+ if (value.length > 0) {
+ const list = [];
+ value.forEach((entry) => {
+ if (entry.type === "abi-scaffold-metadata-file") {
+ const thumbnailURL = this.getScaffoldThumbnailURL(entry, value);
+ if (thumbnailURL) {
+ let image = {
+ thumbnail: thumbnailURL,
+ resource: entry.file_path,
+ datasetId: entry.id,
+ }
+ list.push(image);
+ }
+ }
+ });
+ images[key] = list;
+ }
+ }
+ return images;
+ }
+ } catch (error) {
+ console.error('Error:', error);
+ }
+ return {};
+ },
+
//Get representative segmentations thumbnails
// key - can either be
// id - use the uberon id as key or
@@ -111,6 +165,7 @@ export default {
let image = {
thumbnail: this.getSegmentationThumbnailURL(entry.id,
entry.version, entry.file_path),
+ resource: entry.file_path,
datasetId: entry.id,
}
list.push(image);
@@ -125,6 +180,9 @@ export default {
}
return {};
},
+ getSegmentationThumbnailURL: function(datasetId, datasetVersion, filePath) {
+ return `${this.sparcAPI}/thumbnail/neurolucida?datasetId=${datasetId}&version=${datasetVersion}&path=files/${filePath}`;
+ },
getImagesFromScicrunch: async function () {
try {
const response = await fetch(`${this.sparcAPI}/multiple_dataset_info/using_multiple_mimetype/?${new URLSearchParams({q: imageQuery})}`);
From c0dbe1bbeb904a41ca56b64929fd5ade64814f76 Mon Sep 17 00:00:00 2001
From: "David J. Yu" <87633683+ddjnw1yu@users.noreply.github.com>
Date: Wed, 21 Aug 2024 15:46:24 +1200
Subject: [PATCH 11/47] Modify code and add scaffold support
---
src/App.vue | 5 +-
src/components/FlatmapVuer.vue | 47 ++----
src/components/MultiFlatmapVuer.vue | 10 +-
src/mixins/imageMixin.js | 119 +---------------
src/mixins/scicrunchMixin.js | 213 ++++++++++++++++++++++++++++
5 files changed, 228 insertions(+), 166 deletions(-)
create mode 100644 src/mixins/scicrunchMixin.js
diff --git a/src/App.vue b/src/App.vue
index 26b8e3d6..6a6658d0 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -77,7 +77,6 @@
:displayMinimap="true"
:enableOpenMapUI="true"
:flatmapAPI="flatmapAPI"
- :rootURL="rootURL"
:sparcAPI="sparcAPI"
:disableUI="disableUI"
@open-pubmed-url="onOpenPubmedUrl"
@@ -286,13 +285,11 @@ export default {
useHelpModeDialog: true,
multiflatmapRef: null,
mapSettings: [],
- rootURL: "http://localhost:3000/",
sparcAPI: import.meta.env.VITE_SPARC_API,
- flatmapAPI: import.meta.env.FLATMAP_API,
//flatmapAPI: "https://mapcore-demo.org/current/flatmap/v2/"
//flatmapAPI: "https://mapcore-demo.org/devel/flatmap/v3/"
//flatmapAPI: "https://mapcoe-demo.org/current/flatmap/v3/",
- // flatmapAPI: 'https://mapcore-demo.org/devel/flatmap/v4/',
+ flatmapAPI: 'https://mapcore-demo.org/devel/flatmap/v4/',
//flatmapAPI: "https://mapcore-demo.org/fccb/flatmap/"
//flatmapAPI: "https://mapcore-demo.org/staging/flatmap/v1/"
// flatmapAPI: "https://mapcore-demo.org/devel/flatmap/v1/",
diff --git a/src/components/FlatmapVuer.vue b/src/components/FlatmapVuer.vue
index 93e8e6d0..e4acfbac 100644
--- a/src/components/FlatmapVuer.vue
+++ b/src/components/FlatmapVuer.vue
@@ -501,7 +501,7 @@ Please use `const` to assign meaningful names to them...