Skip to content
Merged
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
2 changes: 1 addition & 1 deletion datalab/adapters_metadata/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def append(self, adapter: BaseResultAdapter, obj: SignalObj | ImageObj) -> None:
if "roi_index" in df.columns:
i_roi = int(df.iloc[i_row_res]["roi_index"])
roititle = ""
if i_roi >= 0 and obj.roi is not None:
if i_roi >= 0 and obj.roi is not None and i_roi < len(obj.roi):
roititle = obj.roi.get_single_roi_title(i_roi)
ylabel += f"|{roititle}"
self.ylabels.append(ylabel)
Expand Down
33 changes: 33 additions & 0 deletions datalab/gui/processor/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,30 @@ def register_computations(self) -> None:
self.register_processing()
self.register_analysis()

# pylint: disable=unused-argument
def preprocess_1_to_0(
self,
func: Callable,
param: gds.DataSet | None,
objs: list[SignalObj | ImageObj],
) -> bool:
"""Pre-check hook for 1-to-0 operations (hook method).

This method is called before a 1-to-0 computation starts, before the
progress dialog is opened. Subclasses can override this method to perform
pre-checks or ask for user confirmation. Return ``False`` to abort the
computation.

Args:
func: The computation function that will be called
param: Optional parameter set
objs: List of objects that will be processed

Returns:
True to proceed with the computation, False to abort
"""
return True

# pylint: disable=unused-argument
def postprocess_1_to_0_result(
self, obj: SignalObj | ImageObj, result: GeometryResult | TableResult
Expand Down Expand Up @@ -989,6 +1013,13 @@ def auto_recompute_analysis(
# Get the parameter from processing parameters
param = proc_params.param

# Disable ROI creation during auto-recompute: detection functions store
# create_rois=True in their parameters, but auto-recompute should only
# update analysis results, not recreate ROIs (which would make them
# impossible to delete or modify).
if hasattr(param, "create_rois"):
param.create_rois = False

# Get the actual function from the function name
feature = self.get_feature(proc_params.func_name)

Expand Down Expand Up @@ -1394,6 +1425,8 @@ def compute_1_to_0(
if target_objs is not None
else self.panel.objview.get_sel_objects(include_groups=True)
)
if not self.preprocess_1_to_0(func, param, objs):
return None
current_obj = self.panel.objview.get_current_object()
title = func.__name__ if title is None else title
refresh_needed = False
Expand Down
46 changes: 46 additions & 0 deletions datalab/gui/processor/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from __future__ import annotations

import guidata.dataset as gds
import numpy as np
import sigima.params
import sigima.proc.base as sipb
Expand All @@ -25,6 +26,7 @@
)
from sigima.objects.scalar import GeometryResult, TableResult

from datalab import env
from datalab.config import APP_NAME, _
from datalab.gui.processor.base import BaseProcessor
from datalab.gui.processor.geometry_postprocess import (
Expand Down Expand Up @@ -58,6 +60,50 @@ def _wrap_geometric_transform(self, func, operation: str):
"""
return GeometricTransformWrapper(func, operation)

def preprocess_1_to_0(
self,
func,
param: gds.DataSet | None,
objs: list[ImageObj],
) -> bool:
"""Override to confirm ROI replacement before the progress bar opens.

When the parameter has ``create_rois=True`` and at least one selected
image already has ROIs, the user is warned that the existing ROIs will
be replaced.

Args:
func: The computation function that will be called
param: Optional parameter set
objs: List of image objects that will be processed

Returns:
True to proceed with the computation, False to abort
"""
if (
param is not None
and getattr(param, "create_rois", False)
and not env.execenv.unattended
and any(obj.roi is not None and not obj.roi.is_empty() for obj in objs)
):
return (
QW.QMessageBox.question(
self.mainwindow,
_("Warning"),
_(
"Regions of interest are already defined for this "
"image.<br><br>"
"Creating new ROIs from detection will replace the "
"existing ones, which will be lost.<br><br>"
"Do you want to continue?"
),
QW.QMessageBox.Yes | QW.QMessageBox.No,
QW.QMessageBox.No,
)
== QW.QMessageBox.Yes
)
return True

def postprocess_1_to_0_result(
self, obj: ImageObj, result: GeometryResult | TableResult
) -> bool:
Expand Down
113 changes: 22 additions & 91 deletions datalab/locale/fr/LC_MESSAGES/datalab.po
Original file line number Diff line number Diff line change
Expand Up @@ -953,38 +953,6 @@ msgstr "Troncature de données uint32 en int32."
msgid "No supported data available in HDF5 file(s)."
msgstr "Aucune donnée prise en charge dans le(s) fichier(s) HDF5."

msgid "Generate macro"
msgstr "Générer une macro"

msgid "No compute actions to export."
msgstr "Pas d'actions de calcul à exporter."

#, python-format
msgid "Macro script copied to clipboard (%d actions)."
msgstr "Script de macro copié dans le presse-papier (%d actions)."

msgid ""
"Do you really want to delete the selected items?\n"
"\n"
"Note: deleting an action also removes all subsequent actions in the same session."
msgstr ""
"Êtes-vous sûr de vouloir supprimer le(s) groupe(s) sélectionné(s) ?\n"
"\n"
"Remarque : la suppression d'une action entraîne également la suppression de toutes les actions suivantes dans la même session."

msgid "Do you really want to delete the selected items?"
msgstr "Êtes-vous sûr de vouloir supprimer le(s) groupe(s) sélectionné(s) ?"

msgid "Remove incompatible"
msgstr "Supprimer les actions incompatibles"

msgid "All actions are compatible with the current workspace."
msgstr "Toutes les actions sont compatibles avec l'espace de travail actuel."

#, python-format
msgid "%d incompatible action(s) will be removed. Continue?"
msgstr "%d action(s) incompatible(s) seront supprimées. Continuer ?"

msgid "Macro simple example"
msgstr "Exemple simple de macro"

Expand Down Expand Up @@ -1523,12 +1491,12 @@ msgstr "Supprimer les métadonnées"
msgid "Some selected objects have regions of interest.<br>Do you want to delete them as well?"
msgstr "Certains objets sélectionnés ont des régions d'intérêt.<br>Souhaitez-vous les supprimer également ?"

msgid "Group name:"
msgstr "Nom du groupe :"

msgid "New group"
msgstr "Nouveau groupe"

msgid "Group name:"
msgstr "Nom du groupe :"

msgid "Rename object"
msgstr "Renommer l'objet"

Expand Down Expand Up @@ -2035,6 +2003,9 @@ msgstr "En mode 'pairwise', vous devez sélectionner des objets dans au moins de
msgid "In pairwise mode, you need to select the same number of objects in each group."
msgstr "En mode 'pairwise', vous devez sélectionner le même nombre d'objets dans chaque groupe."

msgid "Parameters"
msgstr "Paramètres"

#, python-format
msgid "Calculating: %s"
msgstr "Calcul : %s"
Expand Down Expand Up @@ -2066,6 +2037,9 @@ msgstr "Supprimer la ROI"
msgid "Are you sure you want to remove ROI '%s'?"
msgstr "Êtes-vous sûr de vouloir supprimer la ROI '%s' ?"

msgid "Regions of interest are already defined for this image.<br><br>Creating new ROIs from detection will replace the existing ones, which will be lost.<br><br>Do you want to continue?"
msgstr "Des régions d'intérêt sont déjà définies pour cette image.<br><br>La création de nouvelles ROI par détection remplacera les existantes, qui seront perdues.<br><br>Voulez-vous continuer ?"

msgid "Sum"
msgstr "Addition"

Expand Down Expand Up @@ -3335,32 +3309,6 @@ msgstr "C'est la fin de la visite guidée !"
msgid "You can show the tour again, or close this dialog box."
msgstr "Vous pouvez afficher la visite guidée à nouveau, ou fermer cette boîte de dialogue."

msgid "Save history file"
msgstr "Enregistrer le fichier d'historique"

msgid "Open history file"
msgstr "Ouvrir le fichier d'historique"

msgid "Imported"
msgstr "Importer"

msgid "Replaying compound 'multiple_1_to_1' actions is not supported yet."
msgstr "La relecture des actions composées 'multiple_1_to_1' n'est pas encore prise en charge."

msgid "Cannot replay 2-to-1 action: source object(s) missing."
msgstr "Impossible de relire l'action 2-à-1 : objet(s) source manquant(s)."

#, python-format
msgid "Failed to deserialize history DataSet kwarg %r."
msgstr "Echec de la désérialisation de l'argument DataSet de l'historique %r."

#, python-format
msgid "Failed to deserialize history DataSet-list kwarg %r."
msgstr "Echec de la désérialisation de l'argument DataSet-list de l'historique %r."

msgid "Session"
msgstr "Session"

msgid "Registered plugins:"
msgstr "Plugins enregistrés :"

Expand Down Expand Up @@ -3427,9 +3375,6 @@ msgstr "Créer une image avec un anneau"
msgid "Create image with a grid of gaussian spots"
msgstr "Créer une image avec une grille de spots gaussiens"

msgid "New signal"
msgstr "Nouveau signal"

msgid "Host application"
msgstr "Application hôte"

Expand Down Expand Up @@ -3505,12 +3450,12 @@ msgstr "Cliquer sur OK pour démarrer la démo.<br><br><u>Note :</u><br>- La dé
msgid "Click OK to end demo."
msgstr "Cliquer sur OK pour terminer la démo."

msgid "Context"
msgstr "Contexte"

msgid "Error:"
msgstr "Erreur:"

msgid "Context"
msgstr "Contexte"

#, python-format
msgid "The file %s could not be read:"
msgstr "Le fichier %s n'a pas pu être ouvert :"
Expand Down Expand Up @@ -3727,18 +3672,18 @@ msgstr "Déplier la sélection"
msgid "HDF5 Browser"
msgstr "Explorateur HDF5"

msgid "Value"
msgstr "Valeur"

msgid "Name"
msgstr "Nom"

msgid "Size"
msgstr "Taille"

msgid "Type"
msgstr "Type"

msgid "Value"
msgstr "Valeur"

msgid "Name"
msgstr "Nom"

msgid "Unsupported data"
msgstr "Données non prises en charge"

Expand Down Expand Up @@ -3775,24 +3720,6 @@ msgstr "Afficher uniquement les données prises en charge"
msgid "Show values"
msgstr "Afficher les valeurs"

msgid "Show details"
msgstr "Afficher les détails"

msgid "Hide details"
msgstr "Masquer les détails"

msgid "Date and time"
msgstr "Date et heure"

msgid "Title"
msgstr "Titre"

msgid "Action is compatible with the current workspace state."
msgstr "L'action est compatible avec l'état actuel de l'espace de travail."

msgid "Action is not compatible with the current workspace state."
msgstr "L'action n'est pas compatible avec l'état actuel de l'espace de travail."

msgid "Image background selection"
msgstr "Sélection de l'arrière-plan de l'image"

Expand Down Expand Up @@ -4074,6 +4001,9 @@ msgstr "Tout sélectionner"
msgid "Adding data to the plot"
msgstr "Ajout des données au graphique"

msgid "Title"
msgstr "Titre"

msgid "X label"
msgstr "Titre X"

Expand Down Expand Up @@ -4227,3 +4157,4 @@ msgstr "Aucun contour n'a été trouvé pour la plage de niveaux sélectionnée.
msgid "Show contour plot..."
msgstr "Afficher le tracé de contours..."


Loading
Loading