Skip to content

Commit

Permalink
minimal changes from main
Browse files Browse the repository at this point in the history
  • Loading branch information
srivarra committed Oct 15, 2022
1 parent 691e4d2 commit 4c11df4
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 296 deletions.
3 changes: 1 addition & 2 deletions ark/utils/example_dataset_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from email.generator import Generator
import pathlib
from typing import Callable, Iterator
from typing import Callable, Iterator, Generator
import itertools
import pytest
from ark.utils.example_dataset import ExampleDataset, get_example_dataset
Expand Down
39 changes: 17 additions & 22 deletions ark/utils/notebooks_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def flowsom_pixel_setup(tb, flowsom_dir, create_seg_dir=True, img_shape=(50, 50)
tb.execute_cell('import')

# create data which will be loaded into img_xr
tiff_dir = os.path.join(flowsom_dir, "image_data")
tiff_dir = os.path.join(flowsom_dir, "input_data")
os.mkdir(tiff_dir)

if is_mibitiff:
Expand All @@ -173,14 +173,11 @@ def flowsom_pixel_setup(tb, flowsom_dir, create_seg_dir=True, img_shape=(50, 50)

# generate sample segmentation labels so we can load them in
if create_seg_dir:
seg_dir = os.path.join(flowsom_dir, "segmentation")
deepcell_output_dir = os.path.join(seg_dir, "deepcell_output")
os.makedirs(seg_dir)
os.makedirs(deepcell_output_dir)
generate_sample_feature_tifs(fovs, deepcell_output_dir, img_shape)
seg_dir = os.path.join(flowsom_dir, 'deepcell_output')
os.mkdir(seg_dir)
generate_sample_feature_tifs(fovs, seg_dir, img_shape)

seg_dir = "\"%s\"" % seg_dir
deepcell_output_dir = "\"%s\"" % deepcell_output_dir
else:
seg_dir = None

Expand All @@ -190,12 +187,10 @@ def flowsom_pixel_setup(tb, flowsom_dir, create_seg_dir=True, img_shape=(50, 50)
tiff_dir = "%s"
img_sub_folder = None
segmentation_dir = %s
deepcell_output_dir = %s
seg_suffix = '_feature_0.tif'
MIBItiff = %s
mibitiff_suffix = '%s'
""" % (flowsom_dir, tiff_dir, str(seg_dir), str(deepcell_output_dir), is_mibitiff,
mibitiff_suffix)
""" % (flowsom_dir, tiff_dir, str(seg_dir), is_mibitiff, mibitiff_suffix)
tb.inject(define_data_paths, after='file_path')

if fovs is not None:
Expand Down Expand Up @@ -233,15 +228,15 @@ def flowsom_pixel_setup(tb, flowsom_dir, create_seg_dir=True, img_shape=(50, 50)

# if seg_dir is set, test filtering with exclude = True for the second channel,
# and exclude = False for the third channel
if deepcell_output_dir:
if seg_dir:
run_chan_filtering_exclude = """
filter_channel = '%s'
nuclear_exclude = True
pixel_cluster_utils.filter_with_nuclear_mask(
fovs,
tiff_dir,
deepcell_output_dir,
segmentation_dir,
filter_channel,
img_sub_folder,
nuclear_exclude
Expand All @@ -256,7 +251,7 @@ def flowsom_pixel_setup(tb, flowsom_dir, create_seg_dir=True, img_shape=(50, 50)
pixel_cluster_utils.filter_with_nuclear_mask(
fovs,
tiff_dir,
deepcell_output_dir,
segmentation_dir,
filter_channel,
img_sub_folder,
nuclear_exclude
Expand Down Expand Up @@ -312,9 +307,9 @@ def flowsom_pixel_cluster(tb, flowsom_dir, fovs, channels,
"""

# get path to the data
data_path = os.path.join(flowsom_dir + "/segmentation/",
data_path = os.path.join(flowsom_dir,
'%s_pixel_output_dir' % pixel_prefix,
'pixel_mat_data')
'%s_pixel_mat_data' % pixel_prefix)

# make sample consensus data for each fov
for fov in fovs:
Expand Down Expand Up @@ -349,9 +344,9 @@ def flowsom_pixel_cluster(tb, flowsom_dir, fovs, channels,
avg_channels_som['pixel_som_cluster'] = range(1, 101)
avg_channels_som['pixel_meta_cluster'] = np.repeat(range(1, 21), 5)
avg_channels_som.to_csv(
os.path.join(flowsom_dir + "/segmentation/",
os.path.join(flowsom_dir,
'%s_pixel_output_dir' % pixel_prefix,
'pixel_channel_avg_som_cluster.csv'),
'%s_pixel_channel_avg_som_cluster.csv' % pixel_prefix),
index=False
)

Expand All @@ -364,9 +359,9 @@ def flowsom_pixel_cluster(tb, flowsom_dir, fovs, channels,
)
avg_channels_meta['pixel_meta_cluster'] = range(1, 21)
avg_channels_meta.to_csv(
os.path.join(flowsom_dir + "/segmentation/",
os.path.join(flowsom_dir,
'%s_pixel_output_dir' % pixel_prefix,
'pixel_channel_avg_meta_cluster.csv'),
'%s_pixel_channel_avg_meta_cluster.csv' % pixel_prefix),
index=False
)

Expand Down Expand Up @@ -398,9 +393,9 @@ def flowsom_pixel_visualize(tb, flowsom_dir, fovs, pixel_prefix='test'):
remap_data['metacluster'] = np.repeat(range(1, 11), 10)
remap_data['mc_name'] = np.repeat(['meta_' + str(i) for i in range(1, 11)], 10)
remap_data.to_csv(
os.path.join(flowsom_dir + "/segmentation/",
os.path.join(flowsom_dir,
'%s_pixel_output_dir' % pixel_prefix,
'pixel_meta_cluster_mapping.csv'),
'%s_pixel_meta_cluster_mapping.csv' % pixel_prefix),
index=False
)

Expand All @@ -410,7 +405,7 @@ def flowsom_pixel_visualize(tb, flowsom_dir, fovs, pixel_prefix='test'):
# generate the colormap to use
tb.execute_cell('pixel_cmap_gen')

# define the FOVs to use for the cell-pixel overlay
# define the FOVs to use for the cpixelell overlay
if len(fovs) <= 2:
fovs_overlay = fovs
else:
Expand Down
Loading

0 comments on commit 4c11df4

Please sign in to comment.