-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: Deep zoom #929
feat: Deep zoom #929
Conversation
@@ -145,6 +146,7 @@ | |||
"@types/lodash.uniq": "^4.5.6", | |||
"@types/lodash.zip": "^4.2.6", | |||
"@types/node": "^20.10.6", | |||
"@types/openseadragon": "^3.0.10", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WARNING: There's only v3 types, but we're using v4 library 😭
There's a ticket for this: https://app.zenhub.com/workspaces/single-cell-5e2a191dad828d52cc78b028/issues/gh/chanzuckerberg/single-cell-explorer/899
@@ -34,7 +34,7 @@ import { packDiffExPdu, DiffExMode, DiffExArguments } from "../util/diffexpdu"; | |||
import { track } from "../analytics"; | |||
import { EVENTS } from "../analytics/events"; | |||
import AnnoMatrix from "../annoMatrix/annoMatrix"; | |||
import { checkFeatureFlags } from "../util/featureFlags/featureFlags"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move checkFeatureFlags
to /src/index.tsx
, so we do the check ASAP
client/src/actions/index.ts
Outdated
// save isCellGuideCxg to the reducer store | ||
dispatch({ type: "initial data load complete", isCellGuideCxg }); | ||
// save `isCellGuideCxg` and `s3URI` to the reducer store | ||
dispatch({ type: "initial data load complete", isCellGuideCxg, s3URI }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding s3URI
to the store, since now we need to parse s3URI
to find the right deep zoom assets in S3
import { spatialEmbeddingKeyword } from "../globals"; | ||
import { RootState } from "../reducers"; | ||
|
||
export function isSpatialMode(props: Partial<RootState>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create a new selectors file to add selectors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we really should type our state at some point. RootState
is just a masked any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is safe to remove now. But there's probably more MVP related code that needs to be removed in a subsequent PR
this.canvas, | ||
clientX, | ||
clientY, | ||
projectionInvTF | ||
); | ||
this.zoomAt(1 / Math.exp(scale / height), pos[0], pos[1]); | ||
|
||
this.zoomAt({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
passing more args to zoom, since OSD needs the info
viewChanged = this.wheelZoom( | ||
e as unknown as WheelEvent, | ||
projectionTF, | ||
openseadragon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
passing openseadragon instance here
const params = getParams(); | ||
|
||
const paramValue = params?.get(key); | ||
|
||
if (paramValue !== undefined) { | ||
setFeatureFlag(key, paramValue || ""); | ||
return paramValue === ParamBoolean.TRUE; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This resolves the following bug:
- Clear local storage
- Load http://localhost:3000/d/super-cool-spatial.cxg?spatial=true&dl=true
getFeatureFlag("spatial")
actually returnsfalse
instead oftrue
, because the getter is called before the setter
The solution is to prioritize param as the source of truth for feature flag state, and also set the local storage proactively
server/common/utils/uns.py
Outdated
# Preparing data for pyvips from the cropped numpy array | ||
|
||
# NOTE: Flip the image vertically, since somehow the client flips the image | ||
image_pil = image_pil.transpose(Image.FLIP_TOP_BOTTOM) | ||
|
||
# Convert the flipped PIL Image back to a numpy array | ||
flipped_array_uint8 = np.array(image_pil) | ||
|
||
h, w, bands = flipped_array_uint8.shape | ||
linear = flipped_array_uint8.reshape(w * h * bands) | ||
vipsImage = pyvips.Image.new_from_memory(linear.data, w, h, bands, "uchar") | ||
|
||
# Save as Deep Zoom Image (this will create a directory with tiles and a .dzi file) | ||
vipsImage.dzsave("./server/common/web/static/deep_zoom/spatial", suffix=".jpeg") | ||
|
||
h = w = min(h, w) # Adjust for 1:1 aspect ratio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code to generate deep zoom assets locally. We have another ticket to clean this up here:
import { spatialEmbeddingKeyword } from "../globals"; | ||
import { RootState } from "../reducers"; | ||
|
||
export function isSpatialMode(props: Partial<RootState>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we really should type our state at some point. RootState
is just a masked any
const fractionToUse = isSpatialMode ? 1 : 0.95; // fraction of min dimension to use | ||
const topGutterSizePx = isSpatialMode ? 0 : 32; // top gutter for tools | ||
const bottomGutterSizePx = isSpatialMode ? 0 : 32; // bottom gutter for tools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to conduct extra QA of centroid labels
return `${url}spatial.dzi`; | ||
} | ||
|
||
function getSpatialUrl(s3URI: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should just provide this URL on /config
like we do with similar pieces of information
discussed with the team that we have enough e2e test coverage to merge this feature branch into main now to get more days for stakeholders to test the feature. And I will write more e2e tests this week to cover new features added! #yolo |
This is the feature branch for the Deep Zoom feature. Deep Zoom related PRs will be merged against this branch
5/10:
Screen.Recording.2024-05-10.at.2.42.26.PM-2.mov