Skip to content

Commit

Permalink
Fix crash when no brain detected
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Mar 7, 2024
1 parent a74dbf3 commit 62965d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion emerald/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.2.1'
__version__ = '0.2.2'

DISPLAY_TITLE = r"""
_ _ _
Expand Down
8 changes: 8 additions & 0 deletions emerald/emerald.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pathlib import Path
from typing import Optional, List, Tuple
import logging

import cv2
import numpy as np
Expand All @@ -10,6 +11,8 @@

from emerald.model import Unet

logger = logging.getLogger(__name__)


def getImageData(fname):

Expand Down Expand Up @@ -119,6 +122,11 @@ def emerald(model: Unet, input_path: str, mask_path: Optional[Path], brain_paths
# jennings to sofia: why np.float32 instead of uint8?
res = __resizeData(res.astype(np.float32), target = original_shape)

# some type duct tape
if str(res.dtype) == 'bool':
logger.warning(f'Brain not found in {input_path}')
res = res.astype(np.float32)

#remove extra dimension
res = np.squeeze(res)

Expand Down

0 comments on commit 62965d5

Please sign in to comment.