Skip to content

Commit 5ef0f9d

Browse files
Refactor BIDS batch conversion to BIDS batch processing
- Renamed `bids_batch_convert` to `bids_batch_process` to better reflect its functionality. - Updated documentation to describe the new processing capabilities, including flexible discovery and custom processing callables. - Added comprehensive tests for the new `bids_batch_process` function, covering various scenarios such as subject ID discovery, folder stack handling, error reporting, and custom processing functions. - Implemented helper functions for testing batch image loading, processing, and saving. - Enhanced error handling and reporting mechanisms within the batch processing workflow.
1 parent 1721597 commit 5ef0f9d

10 files changed

Lines changed: 2439 additions & 134 deletions

File tree

CHANGELOG.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,41 @@ Each release is also archived on Zenodo for long-term preservation and citation
99

1010
---
1111

12-
### 🔜 OMIO v0.2.10 - UNRELEASED
12+
### 🔜 OMIO v0.3.0 - UNRELEASED
1313

14-
This is a major refactor of OMIO's internal structure: OMIO is now fully organized into focused internal modules for core helpers, cache handling, readers, writers, viewer integration, conversion, templates, and batch processing. The public API remains unchanged and backward-compatible. However, future extensions and new readers will be easier to implement and maintain thanks to the new modular structure.
14+
This is a major refactor of OMIO's internal structure and batch-processing API. OMIO is now fully organized into focused internal modules for core helpers, cache handling, readers, writers, viewer integration, conversion, templates, and batch processing. This enables more maintainable code, better test coverage, and a more flexible public API for, e.g., adding new readers or custom batch-processing workflows.
15+
16+
This release also adds the new flexible BIDS-like batch processor under the public `bids_batch_process()` name, while the pre-v0.3.0 converter remains available as `bids_batch_convert()` for backward compatibility.
17+
18+
**We recommend that users relying on OMIO's batch workflows upgrade to v0.3.0 and switch to the new `bids_batch_process()` API, which provides more robust discovery, filtering, error handling, and reporting features.**
1519

1620
#### 📃 Changes
21+
##### ✨ Added
22+
* Added a new public `bids_batch_process()` implementation with explicit subject selection, subject-prefix discovery, arbitrary folder-token levels, image-pattern filtering, name-based exclusion, skip-if-already-converted logic, robust per-file error handling, persistent run reports, and structured root/local error reports.
23+
* Added `discover_bids_like_batch_images` for reusable discovery of image files in flexible BIDS-like folder trees.
24+
* Added `batch_create_thorlabs_raw_yaml_templates`, which reads OMIO or ZenReg-style batch error reports and creates Thorlabs RAW YAML sidecars from editable `template_metadata` blocks.
25+
1726
##### 🧩 Changed
1827
* Modularized OMIO's implementation into focused internal modules for core helpers, cache handling, readers, writers, viewer integration, conversion, templates, and batch processing while keeping `omio.omio` as a compatibility facade for existing imports.
28+
* Kept the pre-v0.3.0 BIDS-like converter available as `bids_batch_convert()` for backward compatibility, but marked it as deprecated in favor of `bids_batch_process()`.
29+
* Batch run reports now automatically label successful custom `process_func` runs with the callable name and compact `processing_options` when no explicit `method_name` is provided.
30+
* `bids_batch_process(output_folder_name=...)` now explicitly supports both relative output folders below each discovered image folder and absolute output folders.
31+
* `bids_batch_process()` and `discover_bids_like_batch_images()` now collapse OME multi-file TIFF series during discovery by default, matching OMIO's existing `imread`/`imconvert` behavior. Users can opt out with `collapse_ome_multifile_series=False`.
32+
* `bids_batch_process()` and `discover_bids_like_batch_images()` now support optional `folder_stacks` tags for discovering tagged stack folders below the final folder-token level and loading them through OMIO's existing folder-stack merge path.
1933

2034
##### 📚 Documentation
2135
* Clarified OMIO's scope relative to Bio-Formats, explaining why Bio-Formats is not a default dependency and how OMIO can still be extended through dedicated pure-Python readers.
36+
* Documented the new `bids_batch_process()` workflow, report files, skip semantics, file-pattern filtering, nested tag-folder discovery, and RAW YAML template workflow in the RTD batch conversion guide, README, and interactive tutorial script.
37+
* Reintroduced a clearly marked legacy `bids_batch_convert()` tutorial cell in the interactive usage script for users maintaining older workflows.
38+
* Added a custom `process_func` batch example showing Z-projection with OMIO's canonical `TZCYX` axis convention while keeping default OMIO loading and saving.
39+
* Documented OME multi-file TIFF batch handling and tagged folder-stack batch processing in the RTD batch-processing guide and interactive tutorial script.
2240

2341
##### 🧪 Testing and robustness
2442
* Updated internal monkeypatch targets in the test suite to match the new module boundaries and kept the full regression suite passing after the refactor.
43+
* Added regression coverage for flexible `bids_batch_process()` discovery, skip-if-already-converted handling, load/process/save failures, persistent run-report updates, error-report creation, and batch RAW YAML sidecar generation.
44+
* Added regression coverage for automatic custom `process_func` naming and option reporting in batch run reports.
45+
* Added regression coverage for OME multi-file TIFF series collapsing in flexible batch discovery.
46+
* Added regression coverage for tagged folder-stack discovery and automatic forwarding of OMIO folder-stack merge options in `bids_batch_process()`.
2547

2648
---
2749

README.md

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ OMIO's core functions are:
188188
* `imread()`: read images from files or folders,
189189
* `imwrite()`: write images to OME-TIFF,
190190
* `imconvert()`: convert images to OME-TIFF,
191-
* `bids_batch_convert()`: batch-convert BIDS-like projects,
191+
* `bids_batch_process()`: batch-process BIDS-like projects,
192192
* `open_in_napari()`: visualize images in napari,
193193
* `create_empty_metadata()`: create empty metadata templates,
194194
* `create_empty_image()`: create empty image arrays, and
@@ -221,17 +221,41 @@ merged_img, merged_md = omio.imread(
221221
omio.imconvert("experiment_folder")
222222
```
223223

224-
### Batch conversion over a BIDS-like project
224+
### Batch processing over a BIDS-like project
225+
226+
`bids_batch_process()` supports
227+
explicit subject IDs or subject-prefix discovery, arbitrary folder-token levels,
228+
file-pattern filtering, name-based exclusion, skip-if-already-converted behavior, and
229+
persistent run/error reports in the project root.
230+
Use `output_folder_name` for relative or absolute output locations; `save_options`
231+
is reserved for writer settings such as `overwrite` or `compression_level`.
232+
OME-TIFF multi-file series are collapsed during discovery by default, and optional
233+
`folder_stacks` tags can be used to merge tagged stack folders before processing.
225234

226235
```python
227-
omio.bids_batch_convert(
228-
fname="project_root",
229-
sub="sub-",
230-
exp="TP",
231-
tagfolder="TAG_",
232-
merge_tagfolders=True)
236+
result = omio.bids_batch_process(
237+
project_root="project_root",
238+
subject_ids=None,
239+
subject_prefix="ID",
240+
tag_folder_levels=[
241+
("DC000_FOV", "DA000_FOV"),
242+
("TL_000",)],
243+
image_patterns=None,
244+
exclude_name_contains=("Preview",),
245+
folder_stacks=None,
246+
output_folder_name="omio_converted",
247+
skip_processed=True,
248+
load_options={"zarr_store": "disk", "reuse_disk_cache": True},
249+
save_options={"overwrite": False})
250+
251+
print(len(result.processed), len(result.skipped), len(result.failed))
252+
print(result.report_path)
233253
```
234254

255+
If Thorlabs RAW files fail because XML metadata are missing or unusable, OMIO can use
256+
the generated batch error report to create editable YAML sidecars via
257+
`batch_create_thorlabs_raw_yaml_templates()`.
258+
235259

236260
## Scope and non-goals
237261
OMIO intentionally does **not**:

0 commit comments

Comments
 (0)