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

Exported single-channel TIFs for purposes of ilastik classifier development

parent 0c3a9a03
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,19 @@ from pathlib import Path
from extensions.chaeo.util import autonumber_new_directory, get_matching_files, loop_workflow
from extensions.chaeo.workflows import export_patches_from_multichannel_zstack
from model_server.accessors import CziImageFileAccessor, write_accessor_data_to_file
def export_single_channel_tif_from_multichannel_czi(files, where_output, channel):
for czif in files:
in_acc = CziImageFileAccessor(czif)
outf = Path(where_output) / (Path(czif).stem + '.tif')
write_accessor_data_to_file(
outf,
in_acc.get_one_channel_data(channel),
)
print(f'Wrote file: {outf}')
if __name__ == '__main__':
where_czi = 'c:/Users/rhodes/projects/proj0012-trec-handoff/owncloud-sync/TREC-HD/Images/TREC_STOP_15_Kristineberg/230805_automic_AI_PA/20230805-122525_AI_PA_successfulrun_recognitiononPLL405cilindionas/Selection'
where_output = autonumber_new_directory(
......@@ -17,7 +30,7 @@ if __name__ == '__main__':
'pxmap_threshold': 0.25,
'pixel_class': 0,
'zmask_channel': 0,
'patches_channel': 4,
'patches_channel': 2,
'mask_type': 'boxes',
'zmask_filters': {'area': (1e3, 1e8)},
'zmask_expand_box_by': (128, 3),
......@@ -31,12 +44,18 @@ if __name__ == '__main__':
input_files = get_matching_files(where_czi, 'czi')
loop_workflow(
input_files,
where_output,
export_patches_from_multichannel_zstack,
params,
catch_and_continue=False,
)
tif_export_params = {
'channel': 0
}
export_single_channel_tif_from_multichannel_czi(input_files, where_output, 0)
# loop_workflow(
# input_files,
# where_output,
# export_single_channel_tif_from_multichannel_czi,
# tif_export_params,
# catch_and_continue=False,
# )
print('Finished')
\ No newline at end of file
......@@ -26,7 +26,7 @@ def autonumber_new_file(where: str, prefix: str, ext: str) -> str:
idx = max(idx, int(ma.groups()[0]) + 1)
return f'{prefix}-{idx:04d}.{ext}'
def get_matching_files(where: str, ext: str, coord_filter: dict={}) -> str:
def get_matching_files(where: str, ext: str, coord_filter: dict={}) -> list:
files = []
def is_filtered_out(ff):
......@@ -54,7 +54,7 @@ def loop_workflow(files, where_output, workflow_func, params,
failures = []
for ii, ff in enumerate(files):
export_kwargs = {
'input_zstack_path': ff,
'input_zstack_path': ff, # TODO: use a more generic name for implied args
'where_output': where_output,
**params,
}
......
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