-
Notifications
You must be signed in to change notification settings - Fork 1
Affinity updates #64
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
base: main
Are you sure you want to change the base?
Affinity updates #64
Changes from all commits
2f6ec79
8663ac0
c79aaaf
7c83d09
59fc08d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |||||
| import threading | ||||||
| from scipy.ndimage import label | ||||||
| import mwatershed as mws | ||||||
| from scipy.ndimage import measurements | ||||||
| from scipy.ndimage import measurements, gaussian_filter | ||||||
| import fastremap | ||||||
| from funlib.math import cantor_number | ||||||
| import fastmorph | ||||||
|
|
@@ -131,7 +131,9 @@ def is_segmentation(self): | |||||
| class AffinityPostprocessor(PostProcessor): | ||||||
| def __init__( | ||||||
| self, | ||||||
| bias: float = 0.0, | ||||||
| adjacent_edge_bias: float = -0.4, | ||||||
| lr_bias_ratio: float = -0.175, | ||||||
| filter_val: float = 0.5, | ||||||
| neighborhood: str = """[ | ||||||
| [1, 0, 0], | ||||||
| [0, 1, 0], | ||||||
|
|
@@ -145,36 +147,106 @@ def __init__( | |||||
| ]""", | ||||||
| ): | ||||||
| use_exact = "True" | ||||||
| self.bias = float(bias) | ||||||
| self.adjacent_edge_bias = float(adjacent_edge_bias) | ||||||
| self.lr_bias_ratio = float(lr_bias_ratio) | ||||||
| self.filter_val = float(filter_val) | ||||||
| self.neighborhood = ast.literal_eval(neighborhood) | ||||||
| self.use_exact = use_exact == "True" | ||||||
| self.use_exact = use_exact == "False" | ||||||
| self.num_previous_segments = 0 | ||||||
|
|
||||||
| def _process(self, data, chunk_num_voxels, chunk_corner): | ||||||
| data = data / 255.0 | ||||||
| n_channels = data.shape[0] | ||||||
| self.neighborhood = self.neighborhood[:n_channels] | ||||||
| # raise Exception(data.max(), data.min(), self.neighborhood) | ||||||
| import numpy as np | ||||||
| from scipy.ndimage import measurements | ||||||
|
||||||
| from scipy.ndimage import measurements |
Copilot
AI
Aug 5, 2025
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.
Imports should be at the top of the file, not inside a method. Move this import to the top of the file with other imports.
| import numpy as np | |
| from scipy.ndimage import measurements |
Copilot
AI
Aug 5, 2025
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.
Accessing .data attribute on affs_data may fail if affs_data is a numpy array rather than an object with a .data attribute. Use affs_data directly instead of affs_data.data.
| average_affs: float = np.mean(affs_data.data, axis=0) | |
| average_affs: float = np.mean(affs_data, axis=0) |
Copilot
AI
Aug 5, 2025
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.
Remove commented-out code that is not being used. This line appears to be leftover development code.
| # replace: np.ndarray = np.zeros_like(filtered_fragments) |
Copilot
AI
Aug 5, 2025
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.
The shape for the zeros array should match the spatial dimensions of the data, but data.shape includes the channel dimension. Use data.shape[1:] instead of data.shape to exclude the channel dimension.
| data.shape, dtype=np.uint64 if self.use_exact else np.uint16 | |
| data.shape[1:], dtype=np.uint64 if self.use_exact else np.uint16 |
Copilot
AI
Aug 5, 2025
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.
Remove commented-out code. These lines appear to be leftover from the previous implementation.
| # fragment_ids = fastremap.unique(segmentation[segmentation > 0]) |
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.
The logic appears inverted - setting
use_exact = use_exact == "False"meansuse_exactwill be True when the string is "False" and False otherwise. This seems counterintuitive and likely incorrect.