utils.segmentation_utils

Classes

SegmentationMixin

Mixin class for the segmentation functionality of the RANO module.

Module Contents

class utils.segmentation_utils.SegmentationMixin[source]

Mixin class for the segmentation functionality of the RANO module. This class handles the segmentation of the input volumes and the loading of the results into Slicer. It also handles the progress bar and the cancellation of the segmentation process.

start_time_t1 = None

Start time for the first segmentation process

start_time_t2 = None

Start time for the second segmentation process

onCalcSegmentationsButton()[source]

Run processing when user clicks the “Calculate Segmentations” button.

onCliNodeStatusUpdate(cliNode, event, progressBar, task_dir, tmp_path_out, output_segmentation, input_volume_list, timepoint, original_log_level=32)[source]

Callback function to handle the status update of the CLI node.

Parameters:
  • cliNode – The CLI node that is being observed.

  • event – The event that triggered the callback.

  • progressBar – The progress bar to update.

  • task_dir – The task directory for the segmentation.

  • tmp_path_out – The temporary output path for the segmentation.

  • output_segmentation – The output segmentation node.

  • input_volume_list – The list of input volume nodes.

  • timepoint – The timepoint for the segmentation (‘timepoint1’ or ‘timepoint2’).

  • original_log_level – The original log level for the Slicer application.

onSegmentationCliNodeSuccess(input_volume_list, output_segmentation, task_dir, timepoint, tmp_path_out)[source]

Callback function to handle the success of the CLI node. This function loads the output segmentation into Slicer and applies the transformation if required.

Parameters:
  • input_volume_list – The list of input volume nodes.

  • output_segmentation – The output segmentation node.

  • task_dir – The task directory for the segmentation.

  • timepoint – The timepoint for the segmentation (‘timepoint1’ or ‘timepoint2’).

  • tmp_path_out – The temporary output path for the segmentation.

onCancel(cliNode, progressBar)[source]
static ImportLabelmapToSegmentationNodeWithBackgroundSegment(loadedLabelVolumeNode, output_segmentation)[source]

Import the labelVolumeNode into the segmentation node. The labels in the labelVolumeNode are increased by 1 temporarily to include the background label (0) and then decreased by 1 again to have the original labels. (This is because slicer.modules.segmentations.logic().ImportLabelmapToSegmentationNode ignores the background label) Finally, the segmentIDs are reduced by 1 to have the correct segmentIDs in the segmentation node.

Args: loadedLabelVolumeNode: The label volume node to import. output_segmentation: The output segmentation node to import the label volume into.

setDefaultSegmentFor2DMeasurements(defaultSegmentName='ETC')[source]

Set the default segment for 2D measurements in the segment selector widget. This function checks if the default segment exists in either of the segmentations and sets it as the current segment in the segment selector widget.

Parameters:

defaultSegmentName – The name of the default segment to set.

static get_task_dir(model_key, parameterNode)[source]

Get the task directory for the given model key.

Parameters:
  • model_key – The key of the model to get the task directory for.

  • parameterNode – The parameter node for the RANO module.

Returns:

The task directory for the given model key.