Skip to content

Commit

Permalink
Merge pull request #75 from BioimageAnalysisCoreWEHI/iterate_roi_fix
Browse files Browse the repository at this point in the history
fix for roi indexing
  • Loading branch information
multimeric authored Aug 29, 2024
2 parents bcf3b81 + 584b2cd commit f57b489
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions core/lls_core/cmds/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

from lls_core.models.output import SaveFileType
from pydantic.v1 import ValidationError
from toolz.dicttoolz import merge_with

if TYPE_CHECKING:
from lls_core.models.utils import FieldAccessModel
Expand Down Expand Up @@ -79,7 +80,10 @@ def field_from_model(model: Type[FieldAccessModel], field_name: str, extra_descr

def handle_merge(values: list):
if len(values) > 1:
raise ValueError(f"A parameter has been passed multiple times! Got: {', '.join(values)}")
if all(isinstance(param, dict) for param in values):
return merge_with(handle_merge, values)
else:
raise ValueError(f"A parameter has been passed multiple times! Got: {', '.join(values)}")
return values[0]

def rich_validation(e: ValidationError) -> Table:
Expand Down Expand Up @@ -224,7 +228,7 @@ def process(
except ValidationError as e:
console.print(rich_validation(e))
raise Exit(code=1)

lattice.save()
console.print(f"Processing successful. Results can be found in {lattice.save_dir.resolve()}")

Expand Down
4 changes: 2 additions & 2 deletions core/lls_core/models/lattice_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def _process_crop(self) -> Iterable[ImageSlice]:
# We have an extra level of iteration for the crop path: iterating over each ROI
for roi_index, roi in enumerate(tqdm(self.crop.selected_rois, desc="ROI", position=0)):
# pass arguments for save tiff, callable and function arguments
logger.info(f"Processing ROI {roi_index}")
logger.info(f"Processing ROI {self.crop.roi_subset[roi_index]}")

for slice in self.iter_slices():
deconv_args: dict[Any, Any] = {}
Expand Down Expand Up @@ -367,7 +367,7 @@ def _process_crop(self) -> Iterable[ImageSlice]:
z_end=self.crop.z_range[1],
**deconv_args
),
"roi_index": roi_index
"roi_index": self.crop.roi_subset[roi_index]
})

def _process_non_crop(self) -> Iterable[ImageSlice]:
Expand Down

0 comments on commit f57b489

Please sign in to comment.