From efe2127afba50c8ed9150479340e50c918b26e57 Mon Sep 17 00:00:00 2001 From: jaknapper Date: Thu, 15 May 2025 18:02:43 +0100 Subject: [PATCH 1/8] Mount scans to app on startup --- .../server/serve_static_files.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/openflexure_microscope_server/server/serve_static_files.py b/src/openflexure_microscope_server/server/serve_static_files.py index d87e5dec..4f5ad96c 100644 --- a/src/openflexure_microscope_server/server/serve_static_files.py +++ b/src/openflexure_microscope_server/server/serve_static_files.py @@ -44,3 +44,10 @@ def add_static_files(app: FastAPI) -> None: StaticFiles(directory=fpath), name=f"static_{fname}", ) + + # Mount the scan directory to .../scans/, to allow dzi viewing + app.mount( + "/scans/", + StaticFiles(directory="/var/openflexure/scans/"), + name="scans", + ) From cc3620d2ed016966c97dc278f67efe0cb32c8838 Mon Sep 17 00:00:00 2001 From: jaknapper Date: Thu, 15 May 2025 18:03:07 +0100 Subject: [PATCH 2/8] Stitch with dzi by default, and check for dzi available in scans() --- src/openflexure_microscope_server/things/smart_scan.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/openflexure_microscope_server/things/smart_scan.py b/src/openflexure_microscope_server/things/smart_scan.py index a83a598b..1af69b69 100644 --- a/src/openflexure_microscope_server/things/smart_scan.py +++ b/src/openflexure_microscope_server/things/smart_scan.py @@ -77,6 +77,7 @@ class ScanInfo(BaseModel): modified: datetime number_of_images: int stitch_available: bool + dzi: Optional[str] DOWNLOADABLE_SCAN_FILES = ( @@ -819,6 +820,11 @@ class SmartScanThing(Thing): ] number_of_images = len(scan_images) stitch_available = len(stitches) > 0 + dzi = [i for i in folder_contents if i.endswith("dzi")] + if len(dzi) > 0: + dzi = str(dzi[0]) + else: + dzi = None else: number_of_images = 0 stitch_available = False @@ -831,6 +837,7 @@ class SmartScanThing(Thing): modified=modified, number_of_images=number_of_images, stitch_available=stitch_available, + dzi=dzi, ) ) return scans @@ -1096,6 +1103,7 @@ class SmartScanThing(Thing): "--stitching_mode", "all", f"{tiff_arg}", + "--stitch_dzi", "--minimum_overlap", f"{round(overlap * 0.9, 2)}", images_folder, From a9b94bc0d856dbbd448489afda039bb01ce3236f Mon Sep 17 00:00:00 2001 From: jaknapper Date: Thu, 15 May 2025 18:04:23 +0100 Subject: [PATCH 3/8] OpenSeadragon viewer implemented --- webapp/package.json | 1 + .../openSeadragonViewer.vue | 96 +++++++++++++++++++ .../tabContentComponents/scanListContent.vue | 77 +++++++++++++-- 3 files changed, 166 insertions(+), 8 deletions(-) create mode 100644 webapp/src/components/tabContentComponents/scanListComponents/openSeadragonViewer.vue diff --git a/webapp/package.json b/webapp/package.json index 014bfbcc..10550b76 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -17,6 +17,7 @@ "material-design-icons": "^3.0", "material-symbols": "^0.14.3", "mousetrap": "^1.6.5", + "openseadragon": "^5.0.0", "vue-observe-visibility": "^0.4" }, "devDependencies": { diff --git a/webapp/src/components/tabContentComponents/scanListComponents/openSeadragonViewer.vue b/webapp/src/components/tabContentComponents/scanListComponents/openSeadragonViewer.vue new file mode 100644 index 00000000..6f0be39c --- /dev/null +++ b/webapp/src/components/tabContentComponents/scanListComponents/openSeadragonViewer.vue @@ -0,0 +1,96 @@ + + + + + \ No newline at end of file diff --git a/webapp/src/components/tabContentComponents/scanListContent.vue b/webapp/src/components/tabContentComponents/scanListContent.vue index 20f4d461..6892ec5c 100644 --- a/webapp/src/components/tabContentComponents/scanListContent.vue +++ b/webapp/src/components/tabContentComponents/scanListContent.vue @@ -1,8 +1,7 @@ @@ -285,6 +332,20 @@ export default { margin-bottom: 20px; } +#openseadragon { + width: 100%; + height: 100%; +} +#info-panel { + position: absolute; + top: 10px; + left: 10px; + background-color: rgba(255, 255, 255, 0.7); + padding: 5px; + border-radius: 1px; + z-index: 1000; +} + /deep/ .capture-card { width: 300px; height: 100%; // Used to have all cards in a row match their heights From 51e2d420ace534dd25b07d41a7fe77470f91d805 Mon Sep 17 00:00:00 2001 From: jaknapper Date: Fri, 16 May 2025 15:15:48 +0100 Subject: [PATCH 4/8] Update package-lock.json --- webapp/package-lock.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/webapp/package-lock.json b/webapp/package-lock.json index 3c8a67ec..38a12b77 100644 --- a/webapp/package-lock.json +++ b/webapp/package-lock.json @@ -13,6 +13,7 @@ "material-design-icons": "^3.0", "material-symbols": "^0.14.3", "mousetrap": "^1.6.5", + "openseadragon": "^5.0.0", "vue-observe-visibility": "^0.4" }, "devDependencies": { @@ -10539,6 +10540,14 @@ "opener": "bin/opener-bin.js" } }, + "node_modules/openseadragon": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/openseadragon/-/openseadragon-5.0.1.tgz", + "integrity": "sha512-a/hjouW9i3UfWxRADVYN2MyRhXMGnE7x9VVL7/4jXCcDLFyO4UM5o4RStYtqa5BfaHw/wMNAaD2WbxQF8f1pJg==", + "funding": { + "url": "https://opencollective.com/openseadragon" + } + }, "node_modules/opn": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/opn/-/opn-5.5.0.tgz", From 4f98e17b5f98cbda2f3e7c7eeab238d1f6ce4073 Mon Sep 17 00:00:00 2001 From: Joe Knapper Date: Tue, 20 May 2025 12:29:31 +0100 Subject: [PATCH 5/8] Only open preview from button or thumbnail, warn if no DZI available, recentre list --- .../tabContentComponents/scanListContent.vue | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/webapp/src/components/tabContentComponents/scanListContent.vue b/webapp/src/components/tabContentComponents/scanListContent.vue index 6892ec5c..47724cc1 100644 --- a/webapp/src/components/tabContentComponents/scanListContent.vue +++ b/webapp/src/components/tabContentComponents/scanListContent.vue @@ -69,7 +69,7 @@

-
+
@@ -112,14 +113,29 @@ :modal-progress="true" @error="modalError" /> + + +
+
  • {{ item.number_of_images }} images
  • created: {{ formatDate(item.created) }}
  • modified: {{ formatDate(item.modified) }}
  • -
  • Not enough images to stitch
  • -
  • Scan not stitched
-
+
  • Not enough images to stitch
  • +
  • Interactive preview not available
  • +
  • High quality stitch not available
  • +
    @@ -232,7 +248,7 @@ export default { scans.forEach(scan => { scan.modified = Date.parse(scan.modified); scan.created = Date.parse(scan.created); - scan.can_stitch = !scan.stitch_available && scan.number_of_images > 3 || !scan.dzi && scan.number_of_images > 3; + scan.can_stitch = !scan.stitch_available && scan.number_of_images > 3; }); scans.sort((a, b) => { return b.modified - a.modified; @@ -357,5 +373,6 @@ ul { display: inline-block; text-align: center; list-style-type:none; + margin: 5px 0px 10px 0px; } \ No newline at end of file From a499d9230c888efc58fceab292fe3a5673373cc6 Mon Sep 17 00:00:00 2001 From: jaknapper Date: Wed, 21 May 2025 15:06:23 +0100 Subject: [PATCH 6/8] Switch to updated "preview stitch" mode in stitching --- src/openflexure_microscope_server/things/smart_scan.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/openflexure_microscope_server/things/smart_scan.py b/src/openflexure_microscope_server/things/smart_scan.py index 1af69b69..7d819bb3 100644 --- a/src/openflexure_microscope_server/things/smart_scan.py +++ b/src/openflexure_microscope_server/things/smart_scan.py @@ -932,7 +932,7 @@ class SmartScanThing(Thing): raise FileNotFoundError("No latest scan found") images_dir = self.images_dir_for_scan(self.latest_scan_name) - stitch_path = os.path.join(images_dir, "stitched_from_stage.jpg") + stitch_path = os.path.join(images_dir, "preview.jpg") if not os.path.isfile(stitch_path): raise FileNotFoundError("Latest scan has no preview stitch") return stitch_path @@ -987,7 +987,7 @@ class SmartScanThing(Thing): [ STITCHING_CMD, "--stitching_mode", - "only_stage_stitch", + "preview_stitch", "--minimum_overlap", f"{min_overlap}", self._ongoing_scan_images_dir, @@ -1166,6 +1166,7 @@ class SmartScanThing(Thing): "stitched_from", "stitched.om", "stitching_correlations", + "preview.jp", ] with zipfile.ZipFile(zip_fname, mode="a") as scan_zip: From e52dedf0fe3a8631ff7ae6e9012bd39e2622f4cc Mon Sep 17 00:00:00 2001 From: jaknapper Date: Wed, 21 May 2025 15:17:42 +0100 Subject: [PATCH 7/8] Remove padding around viewer, warnings in orange, stitch button if no DZI --- .../tabContentComponents/scanListContent.vue | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/webapp/src/components/tabContentComponents/scanListContent.vue b/webapp/src/components/tabContentComponents/scanListContent.vue index 47724cc1..16899053 100644 --- a/webapp/src/components/tabContentComponents/scanListContent.vue +++ b/webapp/src/components/tabContentComponents/scanListContent.vue @@ -35,8 +35,8 @@ -
    -
    +
    +

    {{ selectedScan.name }} @@ -106,7 +106,7 @@ submit-label="Stitch Images" thing="smart_scan" action="stitch_scan" - v-if="item.can_stitch" + v-if="item.can_stitch | !item.dzi" :can-terminate="false" :submit-data="{ scan_name: item.name }" :button-primary="false" @@ -119,12 +119,6 @@ > Show Stitched Scan -

      @@ -134,7 +128,7 @@
  • Not enough images to stitch
  • Interactive preview not available
  • -
  • High quality stitch not available
  • +
  • High quality stitch not available
  • From 943564d2066aad01b19405e38f1b84660f9e8b45 Mon Sep 17 00:00:00 2001 From: jaknapper Date: Wed, 21 May 2025 16:04:36 +0100 Subject: [PATCH 8/8] Alert and warning message as CSS classes --- .../tabContentComponents/scanListContent.vue | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/webapp/src/components/tabContentComponents/scanListContent.vue b/webapp/src/components/tabContentComponents/scanListContent.vue index 16899053..293b9d0c 100644 --- a/webapp/src/components/tabContentComponents/scanListContent.vue +++ b/webapp/src/components/tabContentComponents/scanListContent.vue @@ -126,9 +126,9 @@
  • created: {{ formatDate(item.created) }}
  • modified: {{ formatDate(item.modified) }}
  • -
  • Not enough images to stitch
  • -
  • Interactive preview not available
  • -
  • High quality stitch not available
  • +
  • Not enough images to stitch
  • +
  • Interactive preview not available
  • +
  • High quality stitch not available
  • @@ -369,4 +369,16 @@ ul { list-style-type:none; margin: 5px 0px 10px 0px; } + +.warning-msg { + color: red; + text-align: center; + font-weight: bold; +} + +.alert-msg{ + color: orange; + text-align: center; + font-weight: bold; +} \ No newline at end of file