log.warning("Virtual stack is only thoroughly tested for reconstructed volumes in TXM format and is thus not guaranteed to load TXRM and XRM files correctly")
log.warning(
"Virtual stack is only thoroughly tested for reconstructed volumes in TXM format and is thus not guaranteed to load TXRM and XRM files correctly"
)
# Get metadata
# Get metadata
ole=olefile.OleFileIO(path)
ole=olefile.OleFileIO(path)
...
@@ -268,23 +273,29 @@ class DataLoader:
...
@@ -268,23 +273,29 @@ class DataLoader:
# Compute data offsets in bytes for each slice
# Compute data offsets in bytes for each slice
offsets=_get_ole_offsets(ole)
offsets=_get_ole_offsets(ole)
iflen(offsets)!=metadata['number_of_images']:
iflen(offsets)!=metadata["number_of_images"]:
raiseValueError(f'Metadata is erroneous: number of images {metadata["number_of_images"]} is different from number of data offsets {len(offsets)}')
raiseValueError(
f'Metadata is erroneous: number of images {metadata["number_of_images"]} is different from number of data offsets {len(offsets)}'
log.warning('Virtual stack volume will be returned as a dask array. To load certain slices into memory, use normal indexing followed by the compute() method, e.g. vol[:,0,:].compute()')
log.warning(
"Virtual stack volume will be returned as a dask array. To load certain slices into memory, use normal indexing followed by the compute() method, e.g. vol[:,0,:].compute()"
)
else:
else:
vol,metadata=dxchange.read_txrm(path)
vol,metadata=dxchange.read_txrm(path)
...
@@ -352,11 +363,11 @@ class DataLoader:
...
@@ -352,11 +363,11 @@ class DataLoader:
should_indent=True
should_indent=True
withopen(path,'r')asf:
withopen(path,"r")asf:
forlineinf:
forlineinf:
line=line.strip()
line=line.strip()
# {NAME} is start of a new object, so should indent
# {NAME} is start of a new object, so should indent
ifline.startswith('{')andline.endswith('}'):
ifline.startswith("{")andline.endswith("}"):
section_name=line[1:-1]
section_name=line[1:-1]
current_section[section_name]={}
current_section[section_name]={}
section_stack.append(current_section)
section_stack.append(current_section)
...
@@ -364,7 +375,7 @@ class DataLoader:
...
@@ -364,7 +375,7 @@ class DataLoader:
should_indent=True
should_indent=True
# [NAME] is start of a section, so should not indent
# [NAME] is start of a section, so should not indent
elifline.startswith('[')andline.endswith(']'):
elifline.startswith("[")andline.endswith("]"):
section_name=line[1:-1]
section_name=line[1:-1]
ifnotshould_indent:
ifnotshould_indent:
...
@@ -377,10 +388,10 @@ class DataLoader:
...
@@ -377,10 +388,10 @@ class DataLoader:
should_indent=False
should_indent=False
# = is a key value pair
# = is a key value pair
elif'='inline:
elif"="inline:
key,value=line.split('=',1)
key,value=line.split("=",1)
current_section[key.strip()]=value.strip()
current_section[key.strip()]=value.strip()
elifline=='':
elifline=="":
iflen(section_stack)>1:
iflen(section_stack)>1:
current_section=section_stack.pop()
current_section=section_stack.pop()
...
@@ -404,35 +415,45 @@ class DataLoader:
...
@@ -404,35 +415,45 @@ class DataLoader:
path=path.replace(".vol",".vgi")
path=path.replace(".vol",".vgi")
log.warning("Corrected path to .vgi metadata file from .vol file")
log.warning("Corrected path to .vgi metadata file from .vol file")