-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2175b4
commit 2a6cd20
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
applications/contrastive_phenotyping/figures/save_patches.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
# %% script to save 128 by 128 image patches from napari viewer | ||
|
||
import napari | ||
import numpy as np | ||
from pathlib import Path | ||
import sys | ||
|
||
sys.path.append("/hpc/mydata/soorya.pradeep/scratch/viscy_infection_phenotyping/VisCy") | ||
# from viscy.data.triplet import TripletDataModule | ||
from viscy.representation.evaluation import dataset_of_tracks | ||
|
||
|
||
# %% input parameters | ||
|
||
data_path = Path( | ||
"/hpc/projects/intracellular_dashboard/viral-sensor/2024_02_04_A549_DENV_ZIKV_timelapse/8-train-test-split/registered_test.zarr" | ||
) | ||
tracks_path = Path( | ||
"/hpc/projects/intracellular_dashboard/viral-sensor/2024_02_04_A549_DENV_ZIKV_timelapse/8-train-test-split/track_test.zarr" | ||
) | ||
|
||
fov_name = '/B/4/8' | ||
track_id = 12 | ||
source_channel = ["Phase3D", "RFP"] | ||
|
||
# %% load dataset | ||
|
||
prediction_dataset = dataset_of_tracks( | ||
data_path, | ||
tracks_path, | ||
[fov_name], | ||
[track_id], | ||
source_channel=source_channel, | ||
) | ||
whole = np.stack([p["anchor"] for p in prediction_dataset]) | ||
phase = whole[:, 0] | ||
fluor = whole[:, 1] | ||
|
||
# use the following if you want to visualize a specific phase slice with max projected fluor | ||
# phase = whole[:, 0, 3] # 3 is the slice number | ||
# fluor = np.max(whole[:, 1], axis=1) | ||
|
||
# load image | ||
v = napari.Viewer() | ||
v.add_image(phase) | ||
v.add_image(fluor) | ||
|
||
# %% save patches as png images | ||
|
||
# use sliders on napari to get the deisred contrast and make other adjustments | ||
# then use save screenshot if saving the image patch manually | ||
# you can add code to automate the process if desired |