![]() |
StrokeSegLab
|
Public Member Functions | |
| None | __init__ (self, str input_path, bool only_preprocessing, bool save_preprocessing, bool keep_MNI, bool save_pmap, bool skip_BET, float threshold, str model_name, str suffix, str viewer) |
| bool | check_stop (self) |
| update_status (self, s) | |
Protected Member Functions | |
| _restore_warning_window (self) | |
| _show_warning (self) | |
| None | _check_path_filled (self) |
| None | _on_model_change (self, tk.Event event=None) |
| None | _on_mode_change (self, tk.Event event=None) |
| None | _show_threshold (self) |
| None | _show_about (self) |
| None | _show_help (self) |
| None | _show_import_model (self) |
| None | _select_model (self) |
| None | _import_model (self) |
| None | _select_input_folder (self) |
| None | _select_input_file (self) |
| None | _on_close (self) |
| None | _stop (self) |
| None | _run (self) |
| None | _run_prediction (self) |
| None | _predict (self) |
| None | _run_bet (self) |
| None | _bet (self) |
| None | _update_result (self) |
| None | _update_stringvar (self, tk.StringVar stringvar, str s) |
| str | _check_device (self) |
Protected Attributes | |
| _logger = logging.getLogger() | |
| _option = Option() | |
| _config = Config() | |
| _preprocessor = Preprocessor(gui=self) | |
| _postprocessor = Postprocessor(gui=self) | |
| _inference = Inference(gui=self) | |
| bool | _running = False |
| dict | _nii_paths = {} |
| _window = tk.Tk() | |
| _on_close | |
| _keep_MNI = tk.BooleanVar(value=keep_MNI) | |
| _save_pmap = tk.BooleanVar(value=save_pmap) | |
| _save_preproc = tk.BooleanVar(value=save_preprocessing) | |
| _skip_BET = tk.BooleanVar(value=skip_BET) | |
| _channel_text = tk.StringVar() | |
| _status_text = tk.StringVar() | |
| _working_on_text = tk.StringVar() | |
| _result_text = tk.StringVar() | |
| _subject_number_text = tk.StringVar() | |
| _option_menu = Menu(menubar,tearoff=0) | |
| _run_button = tk.Button(frame, text='run', command=self._run, state="disabled") | |
| _entry_input_path = tk.Entry(frame, textvariable=self.input_path, state='readonly', width=50) | |
| _label_suffix = tk.Label(frame, text="Suffix : ") | |
| _entry_suffix = tk.Entry(frame, textvariable=self.suffix, width=20) | |
| _label_model = tk.Label(frame, text="Model : ") | |
| list | _models = self._config.get("default","models").split(',') |
| _label_channel = tk.Label(frame,textvariable=self._channel_text,fg="blue") | |
| _combo_models = ttk.Combobox(frame,values=self._models,state="readonly") | |
| _on_model_change | |
| _label_open_viewer = tk.Label(frame, text="Open viewer : ") | |
| _viewer_button = tk.Checkbutton(frame, text="ON/OFF", variable=self.open_viewer) | |
| list | _viewers = [v for v in v if self._config.get("ViewerPath", v)] |
| _label_keep_MNI = tk.Label(frame,text=" Output in MNI space ") | |
| _keep_MNI_button = tk.Checkbutton(frame, text="YES/NO", variable=self._keep_MNI) | |
| _label_exec_mode = tk.Label(frame, text="Execution mode : ") | |
| _combo_modes = ttk.Combobox(frame,values=execution_modes,state="readonly") | |
| _on_mode_change | |
| _label_working_on = tk.Label(frame, textvariable=self._working_on_text, fg="blue") | |
| _label_subject_number_text = tk.Label(frame, textvariable=self._subject_number_text, fg="blue") | |
| _label_status = tk.Label(frame, textvariable=self._status_text) | |
| _label_result = tk.Label(frame, textvariable=self._result_text, font=("Arial", 14, "bold")) | |
| bool | _stop_requested = False |
| _stop_button = tk.Button(frame, text="Stop", command=self._stop) | |
| _update_stringvar | |
| _update_result = False | |
Graphical interface of the brain segmentation application This class initialize the Tkinter window, manage user inputs, run preprocessing, inference, postprocessing and updates the GUI
| None StrokeSegLab.entrypoints.gui.GUIMain.__init__ | ( | self, | |
| str | input_path, | ||
| bool | only_preprocessing, | ||
| bool | save_preprocessing, | ||
| bool | keep_MNI, | ||
| bool | save_pmap, | ||
| bool | skip_BET, | ||
| float | threshold, | ||
| str | model_name, | ||
| str | suffix, | ||
| str | viewer ) |
Initialize the graphical interface with all the Tkinter widgets and run the main Tkinter loop (mainloop). **Args:** - `input_path` (str): The input path. - `only_preprocessing` (bool): If True, the app performs brain extraction only. - `save_preprocessing` (bool): If True, save all preprocessing steps. - `keep_MNI` (bool): If True, save the input image and segmentation in MNI space. - `save_pmap` (bool): If True, save the probability map in addition to the binary mask. - `threshold` (float): Segmentation threshold (default: 0.5 if None). - `skip_BET` (bool): If True, skip the brain extraction step. - `model_name` (str): Name of the model located in the models folder to be used. - `suffix` (str): Suffix for the output segmentation (use default if None). - `viewer` (str): Name of the viewer used to open the first input image and its segmentation. These parameters are used to pre-fill the corresponding fields in the graphical interface.
|
protected |
@public Run the BET pipeline for all subjects. It creates a temporary directory and then, for each subject : - Run preprocessing - Checks periodically if a stop is requested - Update the UI during the process using self._window.after because Tkinter isn't thread safe, we can't modify the UI from a secondary thread. So 'after' is scheduling an update in the main thread
|
protected |
@public
Check Cuda if available
Returns:
str: The selected execution provider ('CUDAExecutionProvider' or 'CPUExecutionProvider')
|
protected |
@public Enable the run button only if the input path is set and there is model available
|
protected |
@public Try to import a model, update the model list and the status message : - Call update_model to refresh the list of model available - Call add_model to add the model to the models directory - Update the list used by the combobox - Handle the potential error and display a status message
|
protected |
@public Check if a prediction is running, and destroy the window if not
|
protected |
@public
Update the app based on the selected mode:
- Brain extraction only : all the fields are deleted execpt input path, some option are disable
- Prediction : all the fields are displayed
Args:
event (tk.Event, optional): The event triggered by the mode selection. Defaults to None.
|
protected |
@public
Update the app based on the selected model
- Disbale the run button if there isn't a model available
- Display an appropriate message based on the model
Args:
event (tk.Event, optional): The event triggered by the model selection. Defaults to None
|
protected |
@public Run the prediction pipeline for all subjects. Depending on the model: - 2 channels (FLAIR and T1), 't1' is the T1 image and 'flair' is the FLAIR image. - 1 channel, 't1' contains either the T1 or the FLAIR image, and 'flair' is None. It creates a temporary directory and then, for each subject : - Run preprocessing, inference and postprocessing - Checks periodically if a stop is requested - Update the UI during the process using self._window.after because Tkinter isn't thread safe, we can't modify the UI from a secondary thread. So 'after' is scheduling an update in the main thread
|
protected |
@public The entry point of the processing Update the UI, set various variables used during the processing task, and call either _run_prediction or _run_bet depending on the selected mode.
|
protected |
@public Configure the BET settings and launch it in a separate thread in order to not freeze the UI
|
protected |
@public Configure the prediction settings and launch it in a separate thread in order to not freeze the UI : - Retrieves and configures runtime option - Call find_nii_files to construct a dictionary of NIFTI path and check T1/FLAIR consistency - Display warning message if needed and other informations to the users - Start the prediction in a thread
|
protected |
@public Handle the input file selection Open a filedialog, set the input path and call for _check_path_filled
|
protected |
@public Handle the input folder selection Open a filedialog, set the input path and call for _check_path_filled
|
protected |
@public Open a filedialog to select a model file. If a file is selected, store the path and clear the import status message
|
protected |
@public Display the about window A notebook is used to display 3 frame in different tabs : developpers, license and publications
|
protected |
@public Display the help window
|
protected |
@public Display the import model window with 3 button to select and import the model and close the window
|
protected |
@public Display the threshold window with a slider and an entry field linked to the threshold of the segmentation
|
protected |
@public Method used to stop a prediction (or BET) - Since the prediction (or BET) runs in a separate thread and can take a long time, this method does not stop the process immediately. Instead, it sets a variable (self._stop_requested) that is checked periodically during the processing loop. When detected, the process will terminate. - Update the UI to inform the user
|
protected |
@public Update the UI based on the result of the processing
|
protected |
@public
Update the value of a StringVar with the given string
Args:
stringvar (tk.StringVar): The StringVar to update
s (str): The new string value to set
| bool StrokeSegLab.entrypoints.gui.GUIMain.check_stop | ( | self | ) |
@public
The method used during the process to check if a stop is requested by the user
Returns:
bool: True if a stop was requested, otherwise False