Skip to content
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

Augmentation strategy for mantis data #23

Closed
ziw-liu opened this issue Jul 28, 2023 · 5 comments
Closed

Augmentation strategy for mantis data #23

ziw-liu opened this issue Jul 28, 2023 · 5 comments

Comments

@ziw-liu
Copy link
Collaborator

ziw-liu commented Jul 28, 2023

Label-free datasets acquired on the mantis have similar in-plane pixel size as hummingbird@63x, where a lot of the training data was acquired. To apply 2.5D virtual staining across microscopes, however, axial spatial augmentation is needed to match training data distribution (250 nm) to the wide range of existing (570 nm, czbiohub-sf/shrimPy#69) and future (205 nm) Z-sampling on mantis.

@talonchandler suggests that trilinear is a good interpolation to start with (0.4x to 1.2x scaling in Z). We will also investigate the unit of voxel intensity values in the reconstructed phase images, since mantis has a different illumination wavelength (450 nm) than hummingbird (532 nm).

Pinging @Soorya19Pradeep and @edyoshikun in case these numbers are not accurate.

@ziw-liu
Copy link
Collaborator Author

ziw-liu commented Jul 28, 2023

This is related to #16 but more specific to mantis data.

@ziw-liu
Copy link
Collaborator Author

ziw-liu commented Jul 28, 2023

For this scaling range and a 5-slice output, the input stack needs to be 11-slice.

import torch
import matplotlib.pyplot as plt
from monai.transforms import RandAffine

# C, Z, Y, X
x = torch.ones((1, 11, 12, 3))

t = RandAffine(
    prob=1,
    rotate_range=(3.14, 0, 0),
    shear_range=(0, (0.05), (0.05)),
    scale_range=((-0.2, 1.4), 0.3, 0.3),
    padding_mode="zeros",
    mode="trilinear",
)

f, ax = plt.subplots(1, 10, figsize=(20, 4), sharey=True)

for i in range(10):
    y = t(x)
    ax[i].imshow(y[0].numpy())

plt.tight_layout()

image

Figure: Z-Y projection of output of random affine transform, white pixels are resampled solely from in-grid data (not from padding).

Z-only:
image

This augmentation will use more I/O bandwidth (2x).

@mattersoflight
Copy link
Member

mattersoflight commented Jul 30, 2023

@ziw-liu thanks for starting this discussion on axial spatial augmentation.

We will also investigate the unit of voxel intensity values in the reconstructed phase images, since mantis has a different illumination wavelength (450 nm) than hummingbird (532 nm).

Examining the XY and XZ cross sections of the phase and fluorescence volumes from both microscopes will be very informative. I look forward to that data.

For this scaling range and a 5-slice output, the input stack needs to be 11-slice.

I don't see images in your last comment, so I ran the snippet above, and see this:
image

It does make sense that we read more z-slices to make sure that we don't have boundary artifacts.

Some other comments:

  • The training data acquired on hummingbird and test data from mantis has sufficient spatial resolution and sampling in z to capture the shape and texture of nuclei and membrane. In other words, 205nm, 250nm, and 570nm are all sufficient sampling intervals to resolve nuclei and cell contours. 570nm sampling is likely insufficient for the membrane.
  • We will collect a lot of data on membrane with mantis.

@mattersoflight
Copy link
Member

mattersoflight commented Aug 12, 2023

The solution to this issue is in progress.

#27 and #29 were merged into the main to make it easy to install viscy from the main during the DL@MBL course.

@ziw-liu can you elaborate on #28? Should it be merged while testing the 2D UNet?

@ziw-liu
Copy link
Collaborator Author

ziw-liu commented Aug 12, 2023

@ziw-liu can you elaborate on #28? Should it be merged while testing the 2D UNet?

Yes, that PR has 2 bug fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants