Commit 0c5fb7a9 authored by Pierre Paleo's avatar Pierre Paleo
Browse files

resources.DatasetAnalyzer: add exclude_projections mechanism

parent 83c59844
......@@ -8,7 +8,7 @@ from tomoscan.esrf.hdf5scan import HDF5TomoScan
from ..thirdparty.tomwer_load_flats_darks import get_flats_frm_process_file, get_darks_frm_process_file
from .nxflatfield import NXFlatField
from ..utils import is_writeable
from .utils import is_hdf5_extension
from .utils import is_hdf5_extension, get_values_from_file
from .logger import LoggerOrPrint
......@@ -52,6 +52,7 @@ class DatasetAnalyzer(object):
self.location = location
self.processes_file = processes_file
self._set_extra_options(extra_options)
self._get_excluded_projections()
def _set_extra_options(self, extra_options):
......@@ -60,10 +61,19 @@ class DatasetAnalyzer(object):
advanced_options = {
"force_flatfield": False,
"output_dir": None,
"exclude_projections": None,
}
advanced_options.update(extra_options)
self.extra_options = advanced_options
def _get_excluded_projections(self):
excluded_projs = self.extra_options["exclude_projections"]
if excluded_projs is None:
return
projs_idx = get_values_from_file(excluded_projs, any_size=True).astype(np.int32).tolist()
self.logger.info("Ignoring projections: %s" % (str(projs_idx)))
self.extra_options["exclude_projections"] = projs_idx
def _init_dataset_scan(self, filetype, **kwargs):
scanners = {
......@@ -73,7 +83,11 @@ class DatasetAnalyzer(object):
if filetype not in scanners.keys():
raise ValueError("No scanner for file type: %s" % filetype)
scanner = scanners[filetype]
self.dataset_scanner = scanner(self.location, **kwargs)
self.dataset_scanner = scanner(
self.location,
ignore_projections=self.extra_options["exclude_projections"],
**kwargs
)
self.projections = self.dataset_scanner.projections
self.flats = self.dataset_scanner.flats
self.darks = self.dataset_scanner.darks
......
Supports Markdown
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