-
Notifications
You must be signed in to change notification settings - Fork 4
Adding support for pyramids #129
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
Open
edyoshikun
wants to merge
5
commits into
main
Choose a base branch
from
support_pyramid
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b07f0ad
initial commit adding resolution
edyoshikun 8a137d4
added the pyramid option to the slidingwindow
edyoshikun 0ff15ab
pyramid as string
edyoshikun dd78377
updated type hint
edyoshikun e120680
fix example type in docstring
ziw-liu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
|
@@ -62,5 +62,6 @@ data: | |
- 256 | ||
caching: false | ||
ground_truth_masks: null | ||
pyramid_resolution: "0" | ||
ckpt_path: null | ||
verbose: true |
This file contains hidden or 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 | ||
---|---|---|---|---|
|
@@ -104,6 +104,8 @@ class SlidingWindowDataset(Dataset): | |||
:param ChannelMap channels: source and target channel names, | ||||
e.g. ``{'source': 'Phase', 'target': ['Nuclei', 'Membrane']}`` | ||||
:param int z_window_size: Z window size of the 2.5D U-Net, 1 for 2D | ||||
:param str pyramid_resolution: pyramid level. | ||||
defaults to "0" (full resolution) | ||||
:param DictTransform | None transform: | ||||
a callable that transforms data, defaults to None | ||||
""" | ||||
|
@@ -113,6 +115,7 @@ def __init__( | |||
positions: list[Position], | ||||
channels: ChannelMap, | ||||
z_window_size: int, | ||||
pyramid_resolution: str = "0", | ||||
transform: DictTransform | None = None, | ||||
) -> None: | ||||
super().__init__() | ||||
|
@@ -128,6 +131,7 @@ def __init__( | |||
) | ||||
self.z_window_size = z_window_size | ||||
self.transform = transform | ||||
self.pyramid_resolution = pyramid_resolution | ||||
self._get_windows() | ||||
|
||||
def _get_windows(self) -> None: | ||||
|
@@ -138,7 +142,7 @@ def _get_windows(self) -> None: | |||
self.window_arrays = [] | ||||
self.window_norm_meta: list[NormMeta | None] = [] | ||||
for fov in self.positions: | ||||
img_arr: ImageArray = fov["0"] | ||||
img_arr: ImageArray = fov[str(self.pyramid_resolution)] | ||||
ts = img_arr.frames | ||||
zs = img_arr.slices - self.z_window_size + 1 | ||||
w += ts * zs | ||||
|
@@ -219,7 +223,7 @@ def __getitem__(self, index: int) -> Sample: | |||
sample = { | ||||
"index": sample_index, | ||||
"source": self._stack_channels(sample_images, "source"), | ||||
"norm_meta": norm_meta, | ||||
# "norm_meta": norm_meta, | ||||
} | ||||
if self.target_ch_idx is not None: | ||||
sample["target"] = self._stack_channels(sample_images, "target") | ||||
|
@@ -301,6 +305,8 @@ class HCSDataModule(LightningDataModule): | |||
:param Path | None ground_truth_masks: path to the ground truth masks, | ||||
used in the test stage to compute segmentation metrics, | ||||
defaults to None | ||||
:param str pyramid_resolution: pyramid resolution level. | ||||
defaults to 0 (full resolution) | ||||
""" | ||||
|
||||
def __init__( | ||||
|
@@ -318,6 +324,7 @@ def __init__( | |||
augmentations: list[MapTransform] = [], | ||||
caching: bool = False, | ||||
ground_truth_masks: Path | None = None, | ||||
pyramid_resolution: str = "0", | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #218 used VisCy/viscy/data/mmap_cache.py Line 40 in 1d3261d
|
||||
): | ||||
super().__init__() | ||||
self.data_path = Path(data_path) | ||||
|
@@ -334,6 +341,7 @@ def __init__( | |||
self.caching = caching | ||||
self.ground_truth_masks = ground_truth_masks | ||||
self.prepare_data_per_node = True | ||||
self.pyramid_resolution = pyramid_resolution | ||||
|
||||
@property | ||||
def cache_path(self): | ||||
|
@@ -390,6 +398,7 @@ def _base_dataset_settings(self) -> dict[str, dict[str, list[str]] | int]: | |||
return { | ||||
"channels": {"source": self.source_channel}, | ||||
"z_window_size": self.z_window_size, | ||||
"pyramid_resolution": self.pyramid_resolution, | ||||
} | ||||
|
||||
def setup(self, stage: Literal["fit", "validate", "test", "predict"]): | ||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What is this for?