Skip to content

Commit

Permalink
simpler itertools.product
Browse files Browse the repository at this point in the history
  • Loading branch information
ngreenwald committed Apr 24, 2020
1 parent b9cd0d9 commit 6362106
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Expand Up @@ -6,8 +6,7 @@ git:

language: python

python:
- 3.7.1
python:
- 3.6

cache: pip
Expand Down
15 changes: 4 additions & 11 deletions caliban_toolbox/reshape_data.py
Expand Up @@ -336,8 +336,7 @@ def save_npzs_for_caliban(resized_xr, original_xr, log_data, save_dir, blank_lab
os.makedirs(os.path.join(save_dir, 'separate'))

# for each fov, loop through 2D crops and 3D slices
for indices in product(range(fov_len), range(num_crops), range(num_slices)):
fov, crop, slice = indices
for fov, crop, slice in product(range(fov_len), range(num_crops), range(num_slices)):
# generate identifier for crop
npz_id = 'fov_{}_crop_{}_slice_{}'.format(fov_names[fov], crop, slice)

Expand Down Expand Up @@ -461,8 +460,7 @@ def load_npzs(crop_dir, log_data, verbose=True):
saved_files = os.listdir(crop_dir)

# for each fov, loop over each 2D crop and 3D slice
for indices in product(range(fov_len), range(num_crops), range(num_slices)):
fov, crop, slice = indices
for fov, crop, slice in product(range(fov_len), range(num_crops), range(num_slices)):
# load NPZs
if save_format == 'npz':
npz_path = os.path.join(crop_dir, get_saved_file_path(saved_files,
Expand Down Expand Up @@ -527,14 +525,9 @@ def stitch_crops(annotated_data, log_data):
if annotated_data.shape[3] != 1:
raise ValueError('Stacks must be combined before stitching can occur')

print('annotated shape: {}'.format(annotated_data.shape))
print('num rows, num cols {} {}'.format(len(row_starts), len(col_starts)))
# for each fov and stack, loop through rows and columns of crop positions
for indices in product(range(fov_len), range(stack_len),
range(len(row_starts)), range(len(col_starts))):

fov, stack, row, col = indices
print('row, col {} {}'.format(row, col))
for fov, stack, row, col in product(range(fov_len), range(stack_len),
range(len(row_starts)), range(len(col_starts))):

# determine what crop # we're currently working on
crop_counter = row * len(row_starts) + col
Expand Down

0 comments on commit 6362106

Please sign in to comment.