GitLab will be upgraded on June 23rd evening. During the upgrade the service will be unavailable, sorry for the inconvenience.

Commit 1fe384e4 authored by payno's avatar payno

[TomoScanBase] add properties `sequence_name`, `sample_name` and `group_size`

parent 0559c556
......@@ -28,3 +28,6 @@ __license__ = "MIT"
__date__ = "09/08/2018"
TYPES = ["EDF", "HDF5"]
from .hdf5scan import HDF5TomoScan
from .edfscan import EDFTomoScan
......@@ -89,6 +89,14 @@ class HDF5TomoScan(TomoScanBase):
_ROTATION_ANGLE_PATH = "sample/rotation_angle"
_SAMPLE_PATH = "sample"
_NAME_PATH = "sample/name"
_GRP_SIZE_ATTR = "group_size"
_SAMPLE_NAME_PATH = "sample/sample_name"
_X_TRANS_PATH = "sample/x_translation"
_Y_TRANS_PATH = "sample/y_translation"
......@@ -160,7 +168,9 @@ class HDF5TomoScan(TomoScanBase):
"unable to find a valid entry for %s" % self.master_file
)
# for now the default entry is 1_tomo but should change with time
self._name = None
self._sample_name = None
self._grp_size = None
# data caches
self._projections_compacted = None
self._flats = None
......@@ -355,6 +365,44 @@ class HDF5TomoScan(TomoScanBase):
def entry(self) -> str:
return self._entry
@property
def sequence_name(self):
"""Return the sequence name"""
if self._name is None and self.master_file and os.path.exists:
self._check_hdf5scan_validity()
with HDF5File(self.master_file, "r") as h5_file:
if self._NAME_PATH in h5_file[self._entry]:
self._name = h5py_read_dataset(
h5_file[self._entry][self._NAME_PATH]
)
return self._name
@property
@docstring(TomoScanBase.projections)
def sample_name(self):
if self._sample_name is None and self.master_file and os.path.exists:
self._check_hdf5scan_validity()
with HDF5File(self.master_file, "r") as h5_file:
if self._SAMPLE_NAME_PATH in h5_file[self._entry]:
self._sample_name = h5py_read_dataset(
h5_file[self._entry][self._SAMPLE_NAME_PATH]
)
return self._sample_name
@property
@docstring(TomoScanBase.projections)
def group_size(self):
if self._grp_size is None and self.master_file and os.path.exists:
self._check_hdf5scan_validity()
with HDF5File(self.master_file, "r") as h5_file:
if self._SAMPLE_PATH in h5_file[self._entry]:
grp = h5_file[self._entry][self._SAMPLE_PATH]
if self._GRP_SIZE_ATTR in grp.attrs:
self._grp_size = h5py_read_dataset(
grp.attrs[self._GRP_SIZE_ATTR]
)
return self._grp_size
@property
@docstring(TomoScanBase.projections)
def projections(self) -> typing.Union[dict, None]:
......
......@@ -299,6 +299,22 @@ class TomoScanBase:
"""Parse the root folder and files to update informations"""
raise NotImplementedError("Base class")
@property
def sequence_name(self):
"""Return the sequence name"""
raise NotImplementedError("Base class")
@property
def sample_name(self):
"""Return the sample name"""
raise NotImplementedError("Base class")
@property
def group_size(self):
"""Used in the case of zseries for example. Return the number of
sequence expected on the acquisition"""
raise NotImplementedError("Base class")
def to_dict(self) -> dict:
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment