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

Rl/process dic timelapses #19

Merged
merged 3 commits into from
Jul 19, 2024
Merged

Rl/process dic timelapses #19

merged 3 commits into from
Jul 19, 2024

Conversation

lanery
Copy link
Collaborator

@lanery lanery commented Jul 13, 2024

This PR is a sort of crude and minimal implementation for processing DIC time lapses of agar microchambers such that it could be used to (quickly) process old in-house datasets.

The modalityFlag tag is parsed from the nd2 metadata to determine the imaging modality of the time lapse -- or at least whether or not it is brightfield. The only real change in processing this triggers is how the thresholding is done for the time lapses (see below). This approach was tested on a handful of in-house DIC time lapses acquired previously, but is not expected to be very robust. The DIC data was previously processed and analyzed using a different pipeline for the pub: "Phenotypic differences between interfertile Chlamydomonas species". While this dataset will not be included or discussed in the pub associated with this repository, the idea is to still be able to use this repository to process DIC time lapses for the sake of convenience.

  • Brightfield --> Li thresholding (same as before)
  • DIC --> Otsu thresholding

This PR also includes some changes to default parameter values and some minor refactoring changes.

PR checklist

  • Describe the changes you've made.
  • If you've added new functionality, make sure that the documentation is updated accordingly.

- add dask-compatible function for Li thresholding
- change default number of central frames to extract during processing
This is a sort of crude and minimal implementation for processing DIC time lapses of agar microchambers such that it could be used to (quickly) process old in-house datasets.
@lanery lanery requested a review from keithchev July 13, 2024 01:22
Copy link
Member

@keithchev keithchev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor comments and caught what I think might be some bugs/typos.

src/chlamytracker/pool_processor.py Outdated Show resolved Hide resolved
src/chlamytracker/pool_processor.py Outdated Show resolved Hide resolved
src/chlamytracker/pool_processor.py Outdated Show resolved Hide resolved
src/chlamytracker/pool_processor.py Outdated Show resolved Hide resolved
src/chlamytracker/pool_processor.py Outdated Show resolved Hide resolved
src/chlamytracker/stack_processing.py Outdated Show resolved Hide resolved
@lanery
Copy link
Collaborator Author

lanery commented Jul 18, 2024

After seeing how many issues/quirks you found in pool_processor.has_cells() I felt the need to provide some evidence that it worked at all....

Screenshot 2024-07-18 at 4 04 34 PM

Code to generate above plot
from pathlib import Path
import skimage as ski
import numpy as np
import matplotlib.pyplot as plt
from mpl_interactions import hyperslicer
from chlamytracker.timelapse import Timelapse
from chlamytracker.pool_finder import PoolFinder

nd2_file = Path(
    "/Users/ryanlane/Projects/2024-unicellular-tracking/pub_videos/pools_data/s1-cr3-t-timelapse_#6.nd2"
)

poolfinder = PoolFinder(nd2_file)
pools = poolfinder.extract_pools()

%matplotlib ipympl

ncols, nrows = max(pools)
fig, axes = plt.subplots(
    nrows=nrows + 1,
    ncols=ncols + 1,
    figsize=(2.5 * ncols, 2.5 * nrows),
)

for (ix, iy), pool in pools.items():

    has_cells = pool.has_cells()

    if ix == iy == 0:
        slider = hyperslicer(
            pool.raw_data,
            vmin=14786,
            vmax=35060,
            cmap="Greys_r",
            display_controls=True,
            ax=axes[iy, ix],
        )

    else:
        slider = hyperslicer(
            pool.raw_data,
            vmin=14786,
            vmax=35060,
            cmap="Greys_r",
            controls=slider,
            display_controls=False,
            ax=axes[iy, ix],
        )

    axes[iy, ix].set_title(f"Cells :: {has_cells}")
    axes[iy, ix].axis("off")

@lanery lanery requested a review from keithchev July 18, 2024 23:44
@keithchev
Copy link
Member

After seeing how many issues/quirks you found in pool_processor.has_cells() I felt the need to provide some evidence that it worked at all....

Lol, nice. I would guess that the cells are so dark compared to the rest of the image that exactly how std or var are called won't matter that much...

@lanery lanery merged commit 298033c into main Jul 19, 2024
1 check passed
@lanery lanery deleted the rl/process-DIC-timelapses branch July 19, 2024 23:55
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

Successfully merging this pull request may close these issues.

2 participants