-
Notifications
You must be signed in to change notification settings - Fork 3
added cristae model and single channel transfrom #100
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| import time | ||
| import warnings | ||
| from glob import glob | ||
| from typing import Dict, Optional, Tuple, Union | ||
| from typing import Dict, List, Optional, Tuple, Union | ||
|
|
||
| # # Suppress annoying import warnings. | ||
| # with warnings.catch_warnings(): | ||
|
|
@@ -85,6 +85,7 @@ def get_prediction( | |
| model: Optional[torch.nn.Module] = None, | ||
| verbose: bool = True, | ||
| with_channels: bool = False, | ||
| channels_to_normalize: Optional[List[int]] = [0], | ||
| mask: Optional[np.ndarray] = None, | ||
| ) -> np.ndarray: | ||
| """Run prediction on a given volume. | ||
|
|
@@ -99,6 +100,7 @@ def get_prediction( | |
| tiling: The tiling configuration for the prediction. | ||
| verbose: Whether to print timing information. | ||
| with_channels: Whether to predict with channels. | ||
| channels_to_normalize: List of channels to normalize. Defaults to 0. | ||
| mask: Optional binary mask. If given, the prediction will only be run in | ||
| the foreground region of the mask. | ||
|
|
||
|
|
@@ -120,8 +122,10 @@ def get_prediction( | |
| # We standardize the data for the whole volume beforehand. | ||
| # If we have channels then the standardization is done independently per channel. | ||
| if with_channels: | ||
| input_volume = input_volume.astype(np.float32, copy=False) | ||
| # TODO Check that this is the correct axis. | ||
| input_volume = np.stack([torch_em.transform.raw.normalize(input_volume[0]), input_volume[1]], axis=0) | ||
| for ch in channels_to_normalize: | ||
| input_volume[ch] = torch_em.transform.raw.normalize(input_volume[ch]) | ||
|
||
| else: | ||
| input_volume = torch_em.transform.raw.standardize(input_volume) | ||
|
|
||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Optionalimplies that this value can beNone. What happens if it isNone?I think in this case all channels should be normalized (independently).
I would also set this as the default, and for the cristae model pass
channels_to_normalize=[0].