diff --git a/make_initial_version.py b/make_initial_version.py index 8bf33d58cf2f03981959de580118663fded9e734..ec1a8bc7480dadf138148d7256e4f4bc9724440f 100755 --- a/make_initial_version.py +++ b/make_initial_version.py @@ -6,7 +6,7 @@ from shutil import copyfile from scripts.files import make_folder_structure from scripts.export import export_segmentation from scripts.files import copy_xml_with_abspath, write_simple_xml -from scripts.files import copy_files_with_pattern +from scripts.files import copy_files_with_pattern, make_bdv_server_file from scripts.attributes import make_nucleus_tables, make_cell_tables @@ -108,6 +108,11 @@ def make_initial_version(): make_tables(folder) + # make the bdv server file + make_bdv_server_file([os.path.join(folder, 'images'), + os.path.join(folder, 'segmentations')], + os.path.join(folder, 'misc', 'bdvserver.txt')) + if __name__ == '__main__': make_initial_version() diff --git a/scripts/files/__init__.py b/scripts/files/__init__.py index 5088d2a8e72f03805bd718d875c74a2980e0fd49..111cf66d66f1ed578a08652377edb4b9e505a24d 100644 --- a/scripts/files/__init__.py +++ b/scripts/files/__init__.py @@ -2,3 +2,4 @@ from .copy_helper import copy_tables, copy_segmentation, copy_static_files from .copy_helper import copy_files_with_pattern from .folders import make_folder_structure from .xml_utils import get_h5_path_from_xml, copy_xml_with_abspath, write_simple_xml +from .bdv_server import make_bdv_server_file diff --git a/scripts/files/bdv_server.py b/scripts/files/bdv_server.py new file mode 100644 index 0000000000000000000000000000000000000000..dbb63ac96f2c2ea8ef2e547bc50d622b780fa17d --- /dev/null +++ b/scripts/files/bdv_server.py @@ -0,0 +1,35 @@ +import os +from .xml_utils import get_h5_path_from_xml + + +# TODO enable filtering for files by some patter. +# e.g. if we don't want to expose the fib dataset to the public yet +def make_bdv_server_file(folders, out_path): + """ Make the bigserver config file from + all xmls in folders. + """ + file_list = {} + for folder in folders: + files = os.listdir(folders) + for ff in files: + path = os.path.join(folder, ff) + + # only add xmls + ext = os.path.splitext(path)[1] + if ext != '.xml': + continue + + # make sure that the h5path linked in the xml exists + h5path = get_h5_path_from_xml(path, return_absolute_path=True) + if not os.path.exists(h5path): + msg = 'Path to h5-file in xml does not exist - %s, %s' % (path, + h5path) + return RuntimeError(msg) + + name = os.path.splitext(ff)[0] + file_list[name] = path + + with open(out_path, 'w') as f: + for name, path in file_list.items(): + line = '%s\t%s\n' % (name, path) + f.write(line)