Skip to content

Commit

Permalink
Fix: broken histogram view due to problems with the latest TypeScript…
Browse files Browse the repository at this point in the history
… update.

Updated Jest snapshots.
  • Loading branch information
plankter committed Jun 4, 2021
1 parent b16d3e8 commit 97b8009
Show file tree
Hide file tree
Showing 16 changed files with 730 additions and 658 deletions.
2 changes: 1 addition & 1 deletion .env.template
Expand Up @@ -9,7 +9,7 @@ PROTOCOL=http
DOMAIN=localhost

## Production docker image settings (change it according to your own Docker Hub account).
DOCKER_TAG=2.1.0
DOCKER_TAG=2.1.1
DOCKER_IMAGE_BACKEND=dqbm/histocat-backend
DOCKER_IMAGE_WORKER=dqbm/histocat-worker
DOCKER_IMAGE_FRONTEND=dqbm/histocat-frontend
Expand Down
@@ -1,10 +1,11 @@
import os
from typing import Sequence, Union

import numpy as np
import tifffile
from deepcell.applications import Mesmer
from imctools.io.ometiff.ometiffparser import OmeTiffParser
from skimage import io, measure
from skimage import measure
from sqlalchemy.orm import Session

from histocat.core.acquisition import service as acquisition_service
Expand All @@ -14,6 +15,20 @@
from histocat.core.utils import timeit


def normalize_by_minmax(img: Sequence[Union[np.ndarray, np.ndarray]]):
channel_mins = np.nanmin(img, axis=(1, 2), keepdims=True)
channel_maxs = np.nanmax(img, axis=(1, 2), keepdims=True)
img = (img - channel_mins) / (channel_maxs - channel_mins)
return img


def normalize_by_zscore(img: Sequence[Union[np.ndarray, np.ndarray]]):
channel_means = np.nanmean(img, axis=(1, 2), keepdims=True)
channel_stds = np.nanstd(img, axis=(1, 2), keepdims=True)
img = (img - channel_means) / channel_stds
return img


@timeit
def process_acquisition(
db: Session, acquisition_id: int, params: SegmentationSubmissionDto, model, dataset: DatasetModel
Expand All @@ -25,19 +40,16 @@ def process_acquisition(
parser = OmeTiffParser(acquisition.location)
acquisition_data = parser.get_acquisition_data()

IA_stack = np.zeros((acquisition_data.image_data.shape[1], acquisition_data.image_data.data.shape[2], 2))

# sum up nuclear markers
for c in params.nuclei_channels:
img = acquisition_data.get_image_by_name(c)
IA_stack[:, :, 0] = IA_stack[:, :, 0] + img
nuclei_channels = acquisition_data.get_image_stack_by_names(params.nuclei_channels)
# nuclei_channels = normalize_by_zscore(nuclei_channels)
nuclei_channels = np.nanmean(nuclei_channels, axis=0)

# sum up cytoplasmic/membranous markers
for c in params.cytoplasm_channels:
img = acquisition_data.get_image_by_name(c)
IA_stack[:, :, 1] = IA_stack[:, :, 1] + img
cytoplasm_channels = acquisition_data.get_image_stack_by_names(params.cytoplasm_channels)
# cytoplasm_channels = normalize_by_zscore(cytoplasm_channels)
cytoplasm_channels = np.nanmean(cytoplasm_channels, axis=0)

im = np.stack((IA_stack[:, :, 0], IA_stack[:, :, 1]), axis=-1)
# Combined together and expand to 4D
im = np.stack((nuclei_channels, cytoplasm_channels), axis=-1)
im = np.expand_dims(im, 0)

app = Mesmer(model)
Expand Down
Expand Up @@ -37,7 +37,7 @@ def process_segmentation(db: Session, project_id: int, params: SegmentationSubmi
# tf.config.threading.set_intra_op_parallelism_threads(4)
# tf.config.threading.set_inter_op_parallelism_threads(4)

# load UNET model
# load Keras model
keras_model = tf.keras.models.load_model(model.location, compile=False)

dataset_params = DatasetCreateDto(
Expand Down

0 comments on commit 97b8009

Please sign in to comment.