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

Fix some path issues and error handling in bdv script

parent 306dc8f3
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<BasePath type="relative">.</BasePath> <BasePath type="relative">.</BasePath>
<SequenceDescription> <SequenceDescription>
<ImageLoader format="bdv.hdf5"> <ImageLoader format="bdv.hdf5">
<hdf5 type="relative">../rawdata/prospr-6dpf-1-whole-ref-SPM.h5</hdf5> <hdf5 type="relative">../../rawdata/prospr-6dpf-1-whole-ref-SPM.h5</hdf5>
</ImageLoader> </ImageLoader>
<ViewSetups> <ViewSetups>
<ViewSetup> <ViewSetup>
......
...@@ -207,9 +207,12 @@ prospr-6dpf-1-whole-segmented-RestOfAnimal ../images/prospr-6dpf-1-whole-segment ...@@ -207,9 +207,12 @@ prospr-6dpf-1-whole-segmented-RestOfAnimal ../images/prospr-6dpf-1-whole-segment
prospr-6dpf-1-whole-segmented-Stomodeum ../images/prospr-6dpf-1-whole-segmented-Stomodeum.xml prospr-6dpf-1-whole-segmented-Stomodeum ../images/prospr-6dpf-1-whole-segmented-Stomodeum.xml
prospr-6dpf-1-whole-segmented-VNC ../images/prospr-6dpf-1-whole-segmented-VNC.xml prospr-6dpf-1-whole-segmented-VNC ../images/prospr-6dpf-1-whole-segmented-VNC.xml
prospr-6dpf-1-whole-six12-MED ../images/prospr-6dpf-1-whole-six12-MED.xml prospr-6dpf-1-whole-six12-MED ../images/prospr-6dpf-1-whole-six12-MED.xml
prospr-6dpf-1-whole-ref-SPM ../images/prospr-6dpf-1-whole-ref-SPM.xml
sbem-6dpf-1-whole-segmented-chromatin-labels ../segmentations/sbem-6dpf-1-whole-segmented-chromatin-labels.xml sbem-6dpf-1-whole-segmented-chromatin-labels ../segmentations/sbem-6dpf-1-whole-segmented-chromatin-labels.xml
sbem-6dpf-1-whole-segmented-tissue-labels ../segmentations/sbem-6dpf-1-whole-segmented-tissue-labels.xml sbem-6dpf-1-whole-segmented-tissue-labels ../segmentations/sbem-6dpf-1-whole-segmented-tissue-labels.xml
sbem-6dpf-1-whole-segmented-muscle ../segmentations/sbem-6dpf-1-whole-segmented-muscle.xml sbem-6dpf-1-whole-segmented-muscle ../segmentations/sbem-6dpf-1-whole-segmented-muscle.xml
sbem-6dpf-1-whole-segmented-cells-labels ../segmentations/sbem-6dpf-1-whole-segmented-cells-labels.xml sbem-6dpf-1-whole-segmented-cells-labels ../segmentations/sbem-6dpf-1-whole-segmented-cells-labels.xml
sbem-6dpf-1-whole-segmented-nuclei-labels ../segmentations/sbem-6dpf-1-whole-segmented-nuclei-labels.xml sbem-6dpf-1-whole-segmented-nuclei-labels ../segmentations/sbem-6dpf-1-whole-segmented-nuclei-labels.xml
sbem-6dpf-1-whole-segmented-cilia-labels ../segmentations/sbem-6dpf-1-whole-segmented-cilia-labels.xml sbem-6dpf-1-whole-segmented-cilia-labels ../segmentations/sbem-6dpf-1-whole-segmented-cilia-labels.xml
sbem-6dpf-1-whole-segmented-ariande-neuropil ../segmentations/sbem-6dpf-1-whole-segmented-ariande-neuropil.xml
sbem-6dpf-1-whole-segmented-cats-neuropil ../segmentations/sbem-6dpf-1-whole-segmented-cats-neuropil.xml
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<BasePath type="relative">.</BasePath> <BasePath type="relative">.</BasePath>
<SequenceDescription> <SequenceDescription>
<ImageLoader format="bdv.hdf5"> <ImageLoader format="bdv.hdf5">
<hdf5 type="relative">../rawdata/sbem-6dpf-1-whole-segmented-ariande-neuropil.h5</hdf5> <hdf5 type="relative">../../rawdata/sbem-6dpf-1-whole-segmented-ariande-neuropil.h5</hdf5>
</ImageLoader> </ImageLoader>
<ViewSetups> <ViewSetups>
<ViewSetup> <ViewSetup>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<BasePath type="relative">.</BasePath> <BasePath type="relative">.</BasePath>
<SequenceDescription> <SequenceDescription>
<ImageLoader format="bdv.hdf5"> <ImageLoader format="bdv.hdf5">
<hdf5 type="relative">../rawdata/sbem-6dpf-1-whole-segmented-cats-neuropil.h5</hdf5> <hdf5 type="relative">../../rawdata/sbem-6dpf-1-whole-segmented-cats-neuropil.h5</hdf5>
</ImageLoader> </ImageLoader>
<ViewSetups> <ViewSetups>
<ViewSetup> <ViewSetup>
......
...@@ -9,11 +9,12 @@ def add_to_bdv_config(name, path, bdv_config, relative_paths, ref_dir): ...@@ -9,11 +9,12 @@ def add_to_bdv_config(name, path, bdv_config, relative_paths, ref_dir):
h5path = get_h5_path_from_xml(path, return_absolute_path=True) h5path = get_h5_path_from_xml(path, return_absolute_path=True)
if not os.path.exists(h5path): if not os.path.exists(h5path):
msg = 'Path to h5-file in xml does not exist - %s, %s' % (path, h5path) msg = 'Path to h5-file in xml does not exist - %s, %s' % (path, h5path)
return RuntimeError(msg) raise RuntimeError(msg)
if relative_paths: if relative_paths:
path = os.path.relpath(path, ref_dir) path = os.path.relpath(path, ref_dir)
bdv_config[name] = path bdv_config[name] = path
return bdv_config
def make_bdv_server_file(folder, out_path, relative_paths=True): def make_bdv_server_file(folder, out_path, relative_paths=True):
...@@ -29,13 +30,15 @@ def make_bdv_server_file(folder, out_path, relative_paths=True): ...@@ -29,13 +30,15 @@ def make_bdv_server_file(folder, out_path, relative_paths=True):
if name in privates: if name in privates:
continue continue
path = os.path.join(folder, 'images', '%s.xml' % name) path = os.path.join(folder, 'images', '%s.xml' % name)
add_to_bdv_config(name, path, bdv_config, relative_paths, ref_dir) bdv_config = add_to_bdv_config(name, path, bdv_config,
relative_paths, ref_dir)
for name in seg_names: for name in seg_names:
if name in privates: if name in privates:
continue continue
path = os.path.join(folder, 'segmentations', '%s.xml' % name) path = os.path.join(folder, 'segmentations', '%s.xml' % name)
add_to_bdv_config(name, path, bdv_config, relative_paths, ref_dir) bdv_config = add_to_bdv_config(name, path, bdv_config,
relative_paths, ref_dir)
with open(out_path, 'w') as f: with open(out_path, 'w') as f:
for name, path in bdv_config.items(): for name, path in bdv_config.items():
......
...@@ -4,6 +4,7 @@ from .xml_utils import copy_xml_with_newpath, get_h5_path_from_xml ...@@ -4,6 +4,7 @@ from .xml_utils import copy_xml_with_newpath, get_h5_path_from_xml
from .sources import get_image_names, get_segmentation_names, get_segmentations from .sources import get_image_names, get_segmentation_names, get_segmentations
# TODO double check this
def copy_file(xml_in, xml_out): def copy_file(xml_in, xml_out):
h5path = get_h5_path_from_xml(xml_in, return_absolute_path=True) h5path = get_h5_path_from_xml(xml_in, return_absolute_path=True)
xml_dir = os.path.split(xml_out)[0] xml_dir = os.path.split(xml_out)[0]
......
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