Skip to content

Commit

Permalink
Merge branch 'master' into new_som
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-l-kong committed Mar 2, 2021
2 parents 1e3934b + 29d2c4a commit 4929fdb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
7 changes: 3 additions & 4 deletions ark/utils/deepcell_service_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


def create_deepcell_output(deepcell_input_dir, deepcell_output_dir, fovs=None,
suffix='_feature_0', host='https://deepcell.org', job_type='multiplex',
suffix='_feature_0', host='https://deepcell.org', job_type='mesmer',
scale=1.0, timeout=3600, zip_size=100, parallel=False):
""" Handles all of the necessary data manipulation for running deepcell tasks.
Expand Down Expand Up @@ -133,7 +133,7 @@ def _zip_run_extract(fov_group, group_index):


def run_deepcell_direct(input_dir, output_dir, host='https://deepcell.org',
job_type='multiplex', scale=1.0, timeout=3600):
job_type='mesmer', scale=1.0, timeout=3600):
"""Uses direct calls to DeepCell API and saves output to output_dir.
Args:
Expand All @@ -145,8 +145,7 @@ def run_deepcell_direct(input_dir, output_dir, host='https://deepcell.org',
Hostname and port for the kiosk-frontend API server.
Default: 'https://deepcell.org'
job_type (str):
Name of job workflow (multiplex, segmentation, tracking).
Default: 'multiplex'
Name of job workflow (mesmer, segmentation, tracking).
scale (float):
Value to rescale data by
Default: 1.0
Expand Down
27 changes: 22 additions & 5 deletions templates/Segment_Image_Data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### This is a notebook to format your data for segmentation, run the images through the cloud instance of DeepCell, and then extract marker counts and morphological information from all the cells in your images"
"### This is a notebook to format your data for segmentation, run the images through the cloud instance of Mesmer, and then extract marker counts and morphological information from all the cells in your images"
]
},
{
Expand All @@ -25,6 +25,8 @@
"import warnings\n",
"import skimage.io as io\n",
"import matplotlib.pyplot as plt\n",
"import xarray as xr\n",
"import numpy as np\n",
"\n",
"from ark.utils import data_utils, deepcell_service_utils, io_utils, load_utils, io_utils, plot_utils, segmentation_utils\n",
"from ark.segmentation import marker_quantification"
Expand Down Expand Up @@ -152,7 +154,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### load images into notebook, process, and save as deepcell compatable input"
"### load images into notebook, process, and save as Mesmer compatable input"
]
},
{
Expand Down Expand Up @@ -184,7 +186,7 @@
},
"outputs": [],
"source": [
"# load channels to be included in deepcell data\n",
"# load channels to be included in Mesmer data\n",
"channels = (nucs if nucs else []) + (mems if mems else [])\n",
"\n",
"# filter channels for None (just in case)\n",
Expand Down Expand Up @@ -276,11 +278,26 @@
},
"outputs": [],
"source": [
"segmentation_labels = load_utils.load_imgs_from_dir(data_dir=deepcell_output_dir,\n",
"segmentation_labels_cell = load_utils.load_imgs_from_dir(data_dir=deepcell_output_dir,\n",
" xr_dim_name='compartments',\n",
" xr_channel_names=['whole_cell'],\n",
" delimiter='_feature_0',\n",
" force_ints=True)"
" force_ints=True)\n",
"\n",
"segmentation_labels_nuc = load_utils.load_imgs_from_dir(data_dir=deepcell_output_dir,\n",
" xr_dim_name='compartments',\n",
" xr_channel_names=['nuclear'],\n",
" delimiter='_feature_1',\n",
" force_ints=True)\n",
"\n",
"segmentation_labels = xr.DataArray(np.concatenate((segmentation_labels_cell.values,\n",
" segmentation_labels_nuc.values),\n",
" axis=-1),\n",
" coords=[segmentation_labels_cell.fovs, \n",
" segmentation_labels_cell.rows,\n",
" segmentation_labels_cell.cols,\n",
" ['whole_cell', 'nuclear']],\n",
" dims=segmentation_labels_cell.dims)"
]
},
{
Expand Down

0 comments on commit 4929fdb

Please sign in to comment.