From af197440bec37209c351db8c201c04eca6981966 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Mon, 27 Jun 2022 16:03:28 +0100 Subject: [PATCH] Return layers from add_registered_image_layers --- brainreg_napari/register.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/brainreg_napari/register.py b/brainreg_napari/register.py index f0ffbbc..2531dd7 100644 --- a/brainreg_napari/register.py +++ b/brainreg_napari/register.py @@ -3,7 +3,7 @@ import pathlib from collections import namedtuple from enum import Enum -from typing import Dict, List +from typing import Dict, List, Tuple import napari from fancylog import fancylog @@ -23,10 +23,17 @@ def add_registered_image_layers( viewer: napari.Viewer, *, registration_directory: pathlib.Path -) -> None: +) -> Tuple[napari.layers.Image, napari.layers.Labels]: """ Read in saved registration data and add as layers to the napari viewer. + + Returns + ------- + boundaries : + Registered boundaries. + labels : + Registered brain regions. """ layers: List[LayerDataTuple] = [] @@ -40,8 +47,9 @@ def add_registered_image_layers( f"'brainreg.json' file not found in {registration_directory}" ) - for layer in layers: - viewer.add_layer(napari.layers.Layer.create(*layer)) + boundaries = viewer.add_layer(napari.layers.Layer.create(*layers[0])) + labels = viewer.add_layer(napari.layers.Layer.create(*layers[1])) + return boundaries, labels def get_layer_labels(widget):