From be02bc148a0ea08d45fb15a5abbe51d05ebc8f3e Mon Sep 17 00:00:00 2001 From: Nanguage Date: Mon, 16 Oct 2023 23:15:23 +0800 Subject: [PATCH] update dataset viewer layout --- public/plugins/viewer.imjoy.html | 50 ++++++++++++++++++++ src/views/DatasetView.vue | 80 ++++++++++++++++++++++++++------ 2 files changed, 117 insertions(+), 13 deletions(-) create mode 100644 public/plugins/viewer.imjoy.html diff --git a/public/plugins/viewer.imjoy.html b/public/plugins/viewer.imjoy.html new file mode 100644 index 0000000..7aed062 --- /dev/null +++ b/public/plugins/viewer.imjoy.html @@ -0,0 +1,50 @@ + +{ + "name": "ufish", + "type": "web-python", + "tags": [], + "flags": [], + "ui": "", + "version": "0.1.0", + "cover": "", + "description": "Plugin for read and view tiff files", + "icon": "extension", + "inputs": null, + "outputs": null, + "api_version": "0.1.8", + "env": "", + "permissions": [], + "requirements": ["tifffile"], + "dependencies": [] +} + + + diff --git a/src/views/DatasetView.vue b/src/views/DatasetView.vue index d87c6cd..36ecb0e 100644 --- a/src/views/DatasetView.vue +++ b/src/views/DatasetView.vue @@ -4,10 +4,29 @@ Number of images: {{ csvData?.length }}, spots: {{ csvData?.reduce((acc, cur) => acc + parseInt(cur.num_spots), 0) }} -
-
-
-
+ + +
+ + + + +
+ +
+ + + +
+
All data can be downloaded from this HuggingFace🤗 repo!
@@ -33,8 +52,19 @@ export default { umapCSVUrl: window.location.origin + "/data/dataset_umap.csv", csvData: null as Array | null, viewer: null as any, + imgBaseURL: "https://huggingface.co/datasets/NaNg/TestData/resolve/main/FISH_spots/", + csvBaseURL: "https://huggingface.co/datasets/NaNg/TestData/resolve/main/FISH_spots/", }), + computed: { + kaibuOverlay() { + return this.viewer === null + }, + umapOverlay() { + return this.csvData === null + } + }, + mounted() { this.loadUMAPCSV() this.loadViewer() @@ -59,6 +89,24 @@ export default { } }, + async onClickPoint(data: any) { + if (this.viewer === null) { + return + } else { + const point = data.points[0]; + const imgName = point.text.split("
")[0].split(": ")[1] + console.log(`You clicked on point: ${imgName} at position (x: ${point.x}, y: ${point.y})`) + //const imgURL = this.imgBaseURL + imgName + //await this.viewer.view_image(imgURL, { name: imgName, type: 'itk-vtk' }) + const csvName = imgName.replace(".tif", ".csv") + const csvURL = this.csvBaseURL + csvName + const csvContent = await fetch(csvURL).then(resp => resp.text()) + const csvData = csv.toObjects(csvContent) + const points = csvData.map((d: any) => [d['axis-0'], d['axis-1']]) + await this.viewer.add_points(points, { name: csvName }) + } + }, + async renderUMAP() { const data = this.csvData! const traces = {} as any @@ -103,10 +151,7 @@ export default { const umapPlot = document.getElementById('umap-container') as any; - umapPlot.on('plotly_click', function(data: any){ - const point = data.points[0]; - alert(`You clicked on point at position (x: ${point.x}, y: ${point.y})`); - }) + umapPlot.on('plotly_click', this.onClickPoint) } }, @@ -122,19 +167,28 @@ export default {