Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/napari_stitcher/_stitcher_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:')

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably this would be self.y_fuse_binning.value for y!

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the case of 3D input data, fusing_spacing would currently loose the 'z' key (I tink best is to just keep it).

}
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]})
Expand Down
6 changes: 6 additions & 0 deletions src/napari_stitcher/_tests/test_stitcher_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The 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):

Expand Down
Loading