-
Notifications
You must be signed in to change notification settings - Fork 5
Add binning for fusion #15
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?
Changes from all commits
a5c85da
cf545e9
ce76d19
534eabd
e5ced98
b5b4bf6
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 |
|---|---|---|
|
|
@@ -77,10 +77,14 @@ def __init__(self, napari_viewer): | |
| choices=[], | ||
| tooltip='Choose a file to process using napari-stitcher.') | ||
|
|
||
| self.custom_reg_binning = widgets.CheckBox(value=False, text='Use custom registration binning') | ||
| self.custom_reg_binning = widgets.CheckBox(value=False, text='Use custom binning for registration') | ||
| self.x_reg_binning = widgets.Slider(value=1, min=1, max=10, label='X binning:') | ||
| self.y_reg_binning = widgets.Slider(value=1, min=1, max=10, label='Y binning:') | ||
|
|
||
| self.custom_fuse_binning = widgets.CheckBox(value=False, text='Use custom binning for fusion') | ||
| self.x_fuse_binning = widgets.Slider(value=1, min=1, max=10, label='X binning:') | ||
| self.y_fuse_binning = widgets.Slider(value=1, min=1, max=10, label='Y binning:') | ||
|
|
||
| self.do_quality_filter = widgets.CheckBox(value=False, text='Filter registrations by quality') | ||
| self.quality_threshold = widgets.FloatSlider(value=0.2, min=0, max=1, label='Quality threshold:') | ||
|
|
||
|
|
@@ -135,6 +139,9 @@ def __init__(self, napari_viewer): | |
| self.custom_reg_binning, | ||
| self.x_reg_binning, | ||
| self.y_reg_binning, | ||
| self.custom_fuse_binning, | ||
| self.x_fuse_binning, | ||
| self.y_fuse_binning, | ||
| self.do_quality_filter, | ||
| self.quality_threshold, | ||
| self.pair_pruning_method, | ||
|
|
@@ -377,11 +384,23 @@ def run_fusion(self): | |
| self.times_slider.value[1] + 1)]}) | ||
| for sim in sims] | ||
|
|
||
| # check which keys are in spacing that are missing in fusion_binning and add them | ||
| if self.custom_fuse_binning.value: | ||
| fusion_binning = {'y': self.x_fuse_binning.value, 'x': self.x_fuse_binning.value} | ||
|
Collaborator
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. Probably this would be |
||
| fusing_spacing = spatial_image_utils.get_spacing_from_sim(sims[0]) | ||
| fusing_spacing = { | ||
| key: fusing_spacing[key] * fusion_binning[key] | ||
| for key in fusing_spacing.keys() if key in fusion_binning | ||
|
Collaborator
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. In the case of 3D input data, |
||
| } | ||
| else: | ||
| fusing_spacing = None | ||
|
|
||
| fused = fusion.fuse( | ||
| sims, | ||
| transform_key='affine_registered' | ||
| if self.visualization_type_rbuttons.value == CHOICE_REGISTERED | ||
| else 'affine_metadata', | ||
| output_spacing=fusing_spacing, | ||
| ) | ||
|
|
||
| fused = fused.expand_dims({'c': [sims[0].coords['c'].values]}) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -224,6 +224,12 @@ def test_fusion_without_registration(make_napari_viewer): | |
| #check that fusion can also be run twice | ||
| stitcher_widget.run_fusion() | ||
|
|
||
| # turn on custom binning | ||
| stitcher_widget.custom_reg_binning.value = True | ||
|
Collaborator
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. I think it would be great to iterate through both reg and fus binning on and off in the tests. |
||
|
|
||
| #run fusion with binning | ||
| stitcher_widget.run_fusion() | ||
|
|
||
|
|
||
| def test_vanilla_layers_2D_no_time(make_napari_viewer): | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.