Skip to content
Snippets Groups Projects
Commit c3a620f0 authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Auto-increment folder number from highest number in root folder, tolerant of deleted intermediaries

parent c4884883
No related branches found
No related tags found
No related merge requests found
......@@ -16,9 +16,13 @@ if __name__ == '__main__':
'c:/Users/rhodes/projects/proj0011-plankton-seg/exp0009/output'
)
yyyymmdd = strftime('%Y%m%d', localtime())
idx = 0
while Path(where_output_root / f'batch-output-{yyyymmdd}-{idx:04d}').exists():
idx += 1
for ff in Path(where_output_root).iterdir():
ma = re.match(f'batch-output-{yyyymmdd}-([\d]+)', ff.name)
if ma:
idx = max(idx, int(ma.groups()[0]) + 1 )
where_output = Path(
where_output_root / f'batch-output-{yyyymmdd}-{idx:04d}'
)
......@@ -26,14 +30,15 @@ if __name__ == '__main__':
csv_args = {'mode': 'w', 'header': True} # when creating file
px_ilp = Path.home() / 'model-server' / 'ilastik' / 'AF405-bodies_boundaries.ilp'
# TODO: try/catch blocks and error handling around workflow calls
# TODO: pack JSON-serializable workflow inputs
#TODO: try/catch blocks and error handling around workflow calls
#TODO: pack JSON-serializable workflow inputs
for ff in where_czi.iterdir():
pattern = 'Selection--W([\d]+)--P([\d]+)-T([\d]+)'
ma = re.match(pattern, ff.stem)
print(ff)
if not ff.suffix.upper() == '.CZI':
if not ff.suffix.upper () == '.CZI':
continue
if int(ma.groups()[1]) > 10: # skip second half of set
continue
......
......@@ -3,10 +3,12 @@ import re
from time import localtime, strftime
from typing import Dict
import numpy as np
import pandas as pd
from skimage.filters import gaussian, sobel
from extensions.ilastik.models import IlastikPixelClassifierModel
from extensions.chaeo.products import export_3d_patches_with_focus_metrics
from extensions.chaeo.products import export_3d_patches_with_focus_metrics, export_patches_from_zstack
from extensions.chaeo.zmask import build_zmask_from_object_mask
from model_server.accessors import generate_file_accessor, InMemoryDataAccessor, write_accessor_data_to_file
from model_server.workflows import Timer
......@@ -64,12 +66,24 @@ def export_patch_focus_metrics_from_multichannel_zstack(
stack.get_one_channel_data(patches_channel),
zmask_meta,
prefix=fstem,
draw_bounding_box=False,
rescale_clip=0.0,
make_3d=True,
annotate_focus_metric=annotate_focus_metric,
)
ti.click('export_patches')
ti.click('export_3d_patches')
files = export_patches_from_zstack(
Path(where_output) / '2d_patches',
stack.get_one_channel_data(patches_channel),
zmask_meta,
prefix=fstem,
draw_bounding_box=True,
rescale_clip=0.0,
# focus_metric=lambda x: np.max(sobel(x)),
focus_metric='max_sobel',
make_3d=False,
)
ti.click('export_2d_patches')
return {
'pixel_model_id': px_model.model_id,
......@@ -101,6 +115,9 @@ if __name__ == '__main__':
px_ilp = Path.home() / 'model-server' / 'ilastik' / 'AF405-bodies_boundaries.ilp'
for ff in where_czi.iterdir():
if ff.stem != 'Selection--W0000--P0009-T0001':
continue
pattern = 'Selection--W([\d]+)--P([\d]+)-T([\d]+)'
ma = re.match(pattern, ff.stem)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment