Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions httomo/darks_flats.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class DarksFlatsFileConfig(NamedTuple):
"""

file: Path
data_path: str
data_path: Optional[str]
image_key_path: Optional[str]
ignore: bool = False

Expand Down Expand Up @@ -145,8 +145,12 @@ def get_separate(config: DarksFlatsFileConfig):
]

if darks_config.file != flats_config.file:
darks = get_separate(darks_config)
flats = get_separate(flats_config)
darks = None
flats = None
if not darks_config.ignore:
darks = get_separate(darks_config)
if not flats_config.ignore:
flats = get_separate(flats_config)
return darks, flats # type: ignore

return get_together_or_dummy()
2 changes: 1 addition & 1 deletion httomo/runner/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def slicing_dim(self) -> Literal[0, 1, 2]:

def _empty_aux_array(self):
empty_shape = list(self._data.shape)
empty_shape[self.slicing_dim] = 0
empty_shape[self.slicing_dim] = 1
return np.empty_like(self._data, shape=empty_shape)

@property
Expand Down
43 changes: 23 additions & 20 deletions httomo/transform_loader_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ class DarksFlatsParam(TypedDict):
Darks/flats configuration dict.
"""

file: str
data_path: str
file: Path
data_path: Optional[str]
image_key_path: Optional[str]
ignore: bool

Expand Down Expand Up @@ -426,25 +426,28 @@ def parse_config(
data_config = DataConfig(in_file=input_file, data_path=str(data_path))

darks_value = config.get("darks", None)
ignore_darks = False
if darks_value == "ignore":
ignore_darks = True # ignore darks in the data
darks_value = None
if darks_value is not None and "image_key_path" not in darks_value:
darks_value["image_key_path"] = None
darks_config = parse_darks_flats(
data_config, image_key_path, darks_value, ignore=ignore_darks
)
if darks_value == "ignore" or darks_value is None:
darks_config = DarksFlatsFileConfig(
file=input_file, data_path=None, image_key_path=None, ignore=True
)
else:
if "image_key_path" not in darks_value:
darks_value["image_key_path"] = None
darks_config = parse_darks_flats(
data_config, image_key_path, darks_value, ignore=False
)

flats_value = config.get("flats", None)
ignore_flats = False
if flats_value == "ignore":
ignore_flats = True # ignore flats in the data
flats_value = None
if flats_value is not None and "image_key_path" not in flats_value:
flats_value["image_key_path"] = None
flats_config = parse_darks_flats(
data_config, image_key_path, flats_value, ignore=ignore_flats
)
if flats_value == "ignore" or flats_value is None:
flats_config = DarksFlatsFileConfig(
file=input_file, data_path=None, image_key_path=None, ignore=True
)
else:
if "image_key_path" not in flats_value:
flats_value["image_key_path"] = None
flats_config = parse_darks_flats(
data_config, image_key_path, flats_value, ignore=False
)

return (
data_config,
Expand Down
8 changes: 4 additions & 4 deletions tests/runner/test_dataset_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def test_full_block_for_global_data():
np.testing.assert_array_equal(data, block.data)
np.testing.assert_array_equal(angles, block.angles)
np.testing.assert_array_equal(angles, block.angles_radians)
assert block.darks.shape == (0, 10, 10)
assert block.dark.shape == (0, 10, 10)
assert block.flats.shape == (0, 10, 10)
assert block.flat.shape == (0, 10, 10)
assert block.darks.shape == (1, 10, 10)
assert block.dark.shape == (1, 10, 10)
assert block.flats.shape == (1, 10, 10)
assert block.flat.shape == (1, 10, 10)
assert block.darks.dtype == data.dtype
assert block.flats.dtype == data.dtype
assert block.dark.dtype == data.dtype
Expand Down
Loading