Skip to content
Snippets Groups Projects
Commit f860222d authored by Constantin Pape's avatar Constantin Pape
Browse files

Update name lookup scripts

parent 410f6a1e
No related branches found
No related tags found
No related merge requests found
from .copy_helper import (copy_tables, copy_segmentation, copy_image_data,
copy_misc_data, copy_release_folder)
from .bdv_server import make_bdv_server_file
from .folders import make_folder_structure
from .sources import add_image, add_segmentation, add_postprocessing, add_source
......
......@@ -191,20 +191,20 @@ def migrate_version(version):
version_folder = os.path.join(ROOT, version)
# 1.) make new folder structure
new_folder_structure(version_folder)
# new_folder_structure(version_folder)
# 2.) iterate over all images and segmentations, replace names (if necessary),
# move the files and make the new images.json dict
update_image_data(version_folder)
# update_image_data(version_folder)
# 3.) iterate over all table links and repair them
update_segmentation_data(version_folder)
# update_segmentation_data(version_folder)
# 4.) update the tables
update_tables(version_folder)
# 5.) clean up:
clean_up(version_folder)
# clean_up(version_folder)
# migrate all the data in the raw folder
......@@ -366,15 +366,13 @@ if __name__ == '__main__':
# change names and xmls in the rawfolder
# migrate_rawfolder()
# version = '0.0.1'
# migrate_version(version)
version = '0.6.5'
migrate_version(version)
version = '0.6.5'
copied = make_n5_files(version)
with open('/g/kreshuk/pape/copied_to_n5.json', 'w') as f:
json.dump(copied, f)
# x = json.dumps(copied, indent=2, sort_keys=True)
# print(x)
# version = '0.6.5'
# update_n5_xmls(version)
......@@ -50,6 +50,7 @@ DYNAMIC_SEGMENTATIONS = ['sbem-6dpf-1-whole-segmented-cells',
ROOT = '/g/arendt/EM_6dpf_segmentation/platy-browser-data/data'
FILE_NAME_LUT = {}
LUT_PATH = os.path.join(ROOT, 'new_name_lut.json')
IMAGE_PROPERTIES = {}
......@@ -60,18 +61,19 @@ IMAGE_PROPERTIES = {}
# - segmentations -> get rid of '-labels' postifx
def update_name_lut():
global FILE_NAME_LUT
if os.path.exists(LUT_PATH):
with open(LUT_PATH, 'r') as f:
FILE_NAME_LUT.update(json.load(f))
return
# update files according to the last version folder
folder = os.path.join(ROOT, '0.6.5')
image_names = os.listdir(os.path.join(folder, 'images'))
image_names = [os.path.splitext(name)[0] for name in image_names
if os.path.splitext(name)[1] == '.xml']
if os.path.exists(os.path.join(folder, 'segmentations')):
seg_names = os.listdir(os.path.join(folder, 'segmentations'))
seg_names = [os.path.splitext(name)[0] for name in seg_names
if os.path.splitext(name)[1] == '.xml']
else:
seg_names = []
seg_names = os.listdir(os.path.join(folder, 'segmentations'))
seg_names = [os.path.splitext(name)[0] for name in seg_names
if os.path.splitext(name)[1] == '.xml']
file_names = image_names + seg_names
for name in file_names:
......@@ -213,7 +215,5 @@ def get_dynamic_segmentation_properties(name):
if __name__ == '__main__':
# x = json.dumps(FILE_NAME_LUT, sort_keys=True, indent=2)
# print(x)
with open('/g/kreshuk/pape/new_names.json', 'w') as f:
with open(LUT_PATH, 'w') as f:
json.dump(FILE_NAME_LUT, f, sort_keys=True, indent=2)
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