Browse Source

removed unused files

master
Holger Frey 6 years ago
parent
commit
fe0eed7c95
  1. 52
      mtor/filesort.py
  2. 4
      test_mtor.py

52
mtor/filesort.py

@ -1,52 +0,0 @@
import pathlib
from tqdm import tqdm
from .prescan import LABEL_SELECTED, LABEL_DISCARDED
def stem_file_list(selected_files):
return {pathlib.Path(filename).stem for filename in selected_files}
def rename_color_coded_images(file_stems, settings):
rename_pairs = []
for path in settings.colored_dir.iterdir():
if not path.stem.startswith("."):
label = (
LABEL_SELECTED if path.stem in file_stems else LABEL_DISCARDED
)
new_name = path.with_name(f"{path.stem}_{label}{path.suffix}")
rename_pairs.append((path, new_name))
return rename_pairs
def sort_cut_images(file_stems, settings):
sort_pairs = []
for path in settings.cuts_dir.iterdir():
if not path.stem.startswith("."):
stem = path.stem[:-4] # removes the "_cut" suffix
label = LABEL_SELECTED if stem in file_stems else LABEL_DISCARDED
new_path = (
settings[f"cuts_{label}_dir"]
/ f"{path.stem}_{label}{path.suffix}"
)
sort_pairs.append((path, new_path))
return sort_pairs
def remove_cuts_dir(settings):
for item in settings["cuts_dir"].iterdir():
item.unlink()
settings["cuts_dir"].rmdir()
def filesort_workflow(selected_files, settings):
print("4/4: Sorting images")
file_stems = stem_file_list(selected_files)
cc_rename_pairs = rename_color_coded_images(file_stems, settings)
cut_sort_pairs = sort_cut_images(file_stems, settings)
file_pairs = cc_rename_pairs + cut_sort_pairs
for old_path, new_path in tqdm(file_pairs):
old_path.rename(new_path)
remove_cuts_dir(settings)

4
test_mtor.py

@ -5,5 +5,5 @@ tif_dir = "original_tifs"
#mtor.process_tifs(tif_dir, 50, 910, 300, 660, boost=5) #mtor.process_tifs(tif_dir, 50, 910, 300, 660, boost=5)
mtor.run() #mtor.run()
#mtor.run_data() mtor.run_data()

Loading…
Cancel
Save