Skip to content

Commit 8482b1e

Browse files
committed
Fix cross-panel computation group handling for image-to-signal operations
When running cross-panel computations (image → signal) on a group of images, results are now properly organized in a new signal group instead of being added to the current group. Previously, operations like "Analysis > Histogram" or "Radial profile" on image groups would add results to the current signal group, inconsistent with same-panel operations that create new groups. Modified _compute_1_to_1_subroutine() to use _create_group_for_result() and _add_object_to_appropriate_panel() for both native and cross-panel computations, ensuring consistent group handling. Added test_cross_panel_image_to_signal_group() to verify the fix.
1 parent 7b02154 commit 8482b1e

4 files changed

Lines changed: 88 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,12 @@ See DataLab [roadmap page](https://datalab-platform.com/en/contributing/roadmap.
486486
* Users can now work smoothly with images containing extensive analysis results without performance degradation
487487
* This enhancement particularly benefits workflows involving blob detection, contour analysis, or peak detection that generate many geometric shapes
488488

489+
* **Cross-panel computation group handling**: Fixed inconsistent behavior when running cross-panel computations (image to signal) on groups of objects
490+
* When applying operations like "Analysis > Histogram" or "Operations > Intensity profiles > Radial profile" to a group of images, results are now organized in a new signal group (as expected)
491+
* Previously, results were incorrectly added to the current signal group instead of creating a dedicated group
492+
* This fix ensures consistent behavior between same-panel operations (e.g., signal → signal) and cross-panel operations (e.g., image → signal)
493+
* Group creation now works uniformly for all 1-to-1 processing patterns regardless of whether results are native or non-native objects
494+
489495
* **Action enable states not updated after operations**: Fixed issue where menu action states
490496
were not updated after performing annotation or metadata operations
491497
* After copying/pasting/deleting annotations or metadata, action states now refresh immediately

datalab/gui/processor/base.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,28 +1051,22 @@ def _compute_1_to_1_subroutine(
10511051
)
10521052
insert_processing_parameters(new_obj, pp)
10531053

1054-
# Is new object a native object (i.e. a Signal object for a Signal
1055-
# Panel, or an Image object for an Image Panel) ?
1056-
# (example of non-native object use case: image profile extraction)
1057-
is_new_obj_native = isinstance(new_obj, self.panel.PARAMCLASS)
1058-
10591054
new_gid = None
1060-
if grps and is_new_obj_native:
1055+
if grps:
10611056
# If groups are selected, then it means that there is no
10621057
# individual object selected: we work on groups only
10631058
old_gid = self.panel.objmodel.get_object_group_id(obj)
10641059
new_gid = new_gids.get(old_gid)
10651060
if new_gid is None:
10661061
# Create a new group for each selected group
10671062
old_g = self.panel.objmodel.get_group(old_gid)
1068-
new_g = self.panel.add_group(
1069-
f"{name}({get_short_id(old_g)})"
1063+
new_gid = self._create_group_for_result(
1064+
new_obj, f"{name}({get_short_id(old_g)})"
10701065
)
1071-
new_gids[old_gid] = new_gid = get_uuid(new_g)
1072-
if is_new_obj_native:
1073-
self.panel.add_object(new_obj, group_id=new_gid)
1074-
else:
1075-
self.panel.mainwindow.add_object(new_obj)
1066+
new_gids[old_gid] = new_gid
1067+
self._add_object_to_appropriate_panel(
1068+
new_obj, group_id=new_gid, use_group_for_non_native=True
1069+
)
10761070
# Select newly created groups, if any
10771071
for group_id in new_gids.values():
10781072
self.panel.objview.set_current_item_id(group_id, extend=True)

datalab/tests/features/common/interactive_processing_test.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,64 @@ def test_cross_panel_image_to_signal():
535535
assert not np.allclose(signal.y, original_signal_data)
536536

537537

538+
def test_cross_panel_image_to_signal_group():
539+
"""Test cross-panel processing with groups: Image group → Signal group"""
540+
with qt_app_context():
541+
with datalab_test_app_context() as win:
542+
image_panel = win.imagepanel
543+
signal_panel = win.signalpanel
544+
image_processor = image_panel.processor
545+
546+
# Create a group of test images
547+
group_name = "Test Images"
548+
group = image_panel.add_group(group_name)
549+
group_id = get_uuid(group)
550+
551+
# Create multiple test images in the group
552+
n_images = 3
553+
for i in range(n_images):
554+
image_param = Gauss2DParam.create(
555+
x0=50.0 + i * 5,
556+
y0=50.0 + i * 5,
557+
sigma=10.0,
558+
a=100.0,
559+
height=100,
560+
width=100,
561+
)
562+
image_panel.new_object(param=image_param, edit=False)
563+
# The new objects are automatically added to the current group
564+
565+
# Select the entire group
566+
image_panel.objview.set_current_item_id(group_id, extend=False)
567+
568+
# Get the initial number of groups in signal panel
569+
signal_groups_before = len(signal_panel.objmodel.get_groups())
570+
571+
# Apply radial_profile to the entire group (Image → Signal cross-panel)
572+
profile_param = RadialProfileParam.create(x0=50, y0=50)
573+
image_processor.run_feature("radial_profile", param=profile_param)
574+
575+
# Verify a NEW group was created in the signal panel
576+
signal_groups_after = len(signal_panel.objmodel.get_groups())
577+
assert signal_groups_after == signal_groups_before + 1, (
578+
"Expected a new group to be created for cross-panel computation results"
579+
)
580+
581+
# Verify that the new group contains the correct number of signals
582+
signal_groups = signal_panel.objmodel.get_groups()
583+
new_group = signal_groups[-1] # Get the last (newly created) group
584+
signals_in_group = new_group.get_objects()
585+
assert len(signals_in_group) == n_images, (
586+
f"Expected {n_images} signals in new group, got {len(signals_in_group)}"
587+
)
588+
589+
# Verify the group name follows the expected pattern
590+
assert "radial_profile" in new_group.title.lower(), (
591+
f"Expected group name to contain 'radial_profile', "
592+
f"got '{new_group.title}'"
593+
)
594+
595+
538596
def test_cross_panel_signal_to_image():
539597
"""Test cross-panel processing: Signal → Image (combine signals into image)"""
540598
with qt_app_context():
@@ -756,6 +814,7 @@ def test_select_source_objects_deleted_source():
756814
test_apply_processing_parameters_image()
757815
test_apply_processing_parameters_missing_source()
758816
test_cross_panel_image_to_signal()
817+
test_cross_panel_image_to_signal_group()
759818
test_cross_panel_signal_to_image()
760819
test_select_source_objects_same_panel()
761820
test_select_source_objects_cross_panel()

doc/locale/fr/LC_MESSAGES/changelog.po

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: DataLab \n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2025-11-09 12:20+0100\n"
10+
"POT-Creation-Date: 2025-11-09 18:55+0100\n"
1111
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1212
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313
"Language: fr\n"
@@ -1387,6 +1387,21 @@ msgstr "Les utilisateurs peuvent désormais travailler sans problème avec des i
13871387
msgid "This enhancement particularly benefits workflows involving blob detection, contour analysis, or peak detection that generate many geometric shapes"
13881388
msgstr "Cette amélioration bénéficie particulièrement aux flux de travail impliquant la détection de blobs, l'analyse de contours ou la détection de pics qui génèrent de nombreuses formes géométriques."
13891389

1390+
msgid "**Cross-panel computation group handling**: Fixed inconsistent behavior when running cross-panel computations (image to signal) on groups of objects"
1391+
msgstr "**Gestion des groupes de calcul inter-panneaux** : Correction d'un comportement incohérent lors de l'exécution de calculs inter-panneaux (image vers signal) sur des groupes d'objets"
1392+
1393+
msgid "When applying operations like \"Analysis > Histogram\" or \"Operations > Intensity profiles > Radial profile\" to a group of images, results are now organized in a new signal group (as expected)"
1394+
msgstr "Lors de l'application d'opérations telles que \"Analyse > Histogramme\" ou \"Opérations > Profils d'intensité > Profil radial\" à un groupe d'images, les résultats sont désormais organisés dans un nouveau groupe de signaux (comme prévu)."
1395+
1396+
msgid "Previously, results were incorrectly added to the current signal group instead of creating a dedicated group"
1397+
msgstr "Auparavant, les résultats étaient incorrectement ajoutés au groupe de signaux actuel au lieu de créer un groupe dédié."
1398+
1399+
msgid "This fix ensures consistent behavior between same-panel operations (e.g., signal → signal) and cross-panel operations (e.g., image → signal)"
1400+
msgstr "Cette correction garantit un comportement cohérent entre les opérations dans le même panneau (par exemple, signal → signal) et les opérations inter-panneaux (par exemple, image → signal)."
1401+
1402+
msgid "Group creation now works uniformly for all 1-to-1 processing patterns regardless of whether results are native or non-native objects"
1403+
msgstr "La création de groupes fonctionne désormais de manière uniforme pour tous les modèles de traitement 1-à-1, qu'il s'agisse d'objets natifs ou non natifs."
1404+
13901405
msgid "**Action enable states not updated after operations**: Fixed issue where menu action states were not updated after performing annotation or metadata operations"
13911406
msgstr "**Les états d'activation des actions ne sont pas mis à jour après les opérations** : Correction d'un problème où les états des actions de menu n'étaient pas mis à jour après l'exécution d'opérations d'annotation ou de métadonnées"
13921407

@@ -3876,4 +3891,3 @@ msgstr "Symétrie (verticale/horizontale)"
38763891

38773892
msgid "Console: added configurable external editor (default: VSCode) to follow the traceback links to the source code"
38783893
msgstr "Console : ajout d'un éditeur externe configurable (par défaut : VSCode) pour suivre les liens de poursuite vers le code source"
3879-

0 commit comments

Comments
 (0)