Skip to content

Commit

Permalink
Use defaultdict
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikl committed Jun 12, 2020
1 parent 7f2d8f1 commit 2075756
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/omero_rois/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import numpy as np
from collections import defaultdict
from omero.gateway import ColorHolder
from omero.model import MaskI
from omero.rtypes import (
Expand Down Expand Up @@ -154,7 +155,7 @@ def masks_from_3d_label_image(
({} if no labels found)
"""
masks = {}
masks = defaultdict(list)
for i, plane in enumerate(planes):
if z_stack:
plane_masks = masks_from_label_image(plane, rgba, i, c, t,
Expand All @@ -163,8 +164,6 @@ def masks_from_3d_label_image(
plane_masks = masks_from_label_image(plane, rgba, z, c, i,
text, False)
for label, mask in enumerate(plane_masks):
if label not in masks:
masks[label] = []
if mask.getBytes().any():
masks[label].append(mask)
return masks

1 comment on commit 2075756

@mtbc
Copy link
Member

@mtbc mtbc commented on 2075756 Jun 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.