From 39b71cc38b82e9a7db43856b0b8fcfc9ad976f1c Mon Sep 17 00:00:00 2001 From: Juergen Bohl Date: Wed, 17 Sep 2025 17:36:13 +0200 Subject: [PATCH 01/36] Switch submodule libs/libCZIrw to https://github.com/ptahmose/libczi-zeiss.git (branch jbl/mask-support) --- .gitmodules | 3 ++- libs/libCZIrw | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 2869a11..d077d22 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,7 @@ [submodule "libs/libCZIrw"] path = libs/libCZIrw - url = https://github.com/ZEISS/libczi + url = https://github.com/ptahmose/libczi-zeiss.git + branch = jbl/mask-support [submodule "libs/pybind11"] path = libs/pybind11 url = https://github.com/pybind/pybind11 diff --git a/libs/libCZIrw b/libs/libCZIrw index 87c06cb..bc4300d 160000 --- a/libs/libCZIrw +++ b/libs/libCZIrw @@ -1 +1 @@ -Subproject commit 87c06cbf5eee5b91ca2d3560ad0a247d6ed9c810 +Subproject commit bc4300dd35f64bf802bc84722ea6d8ae8a15e455 From 6ef2fb12bddc24da5457411e2f673462fe297078 Mon Sep 17 00:00:00 2001 From: Juergen Bohl Date: Wed, 17 Sep 2025 17:44:36 +0200 Subject: [PATCH 02/36] Add atomic lock management to CMemBitmapWrapper --- _pylibCZIrw/src/bindings/PbHelper.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/_pylibCZIrw/src/bindings/PbHelper.h b/_pylibCZIrw/src/bindings/PbHelper.h index 6089f8b..27d6d6f 100644 --- a/_pylibCZIrw/src/bindings/PbHelper.h +++ b/_pylibCZIrw/src/bindings/PbHelper.h @@ -5,6 +5,7 @@ #include #include #include +#include namespace py = pybind11; @@ -19,7 +20,7 @@ class CMemBitmapWrapper : public libCZI::IBitmapData { std::uint32_t width; std::uint32_t height; std::uint32_t stride; - + std::atomic lockCnt = ATOMIC_VAR_INIT(0); public: CMemBitmapWrapper(libCZI::PixelType pixeltype, std::uint32_t width, std::uint32_t height, std::uint32_t stride) @@ -42,10 +43,17 @@ class CMemBitmapWrapper : public libCZI::IBitmapData { bitmapLockInfo.ptrDataRoi = this->ptrData; bitmapLockInfo.stride = this->stride; bitmapLockInfo.size = this->stride * static_cast(this->height); + std::atomic_fetch_add(&this->lockCnt, 1); return bitmapLockInfo; } - virtual void Unlock() {} + virtual void Unlock() { + std::atomic_fetch_sub(&this->lockCnt, 1); + } + + virtual int GetLockCount() const { + return std::atomic_load(&this->lockCnt); + } }; /// Returns format descriptor corresponding to each libCZI::PixelType. From 8ea26bda9467f28c2ba977db1f9c142a6d93d943 Mon Sep 17 00:00:00 2001 From: Juergen Bohl Date: Thu, 18 Sep 2025 08:02:19 +0200 Subject: [PATCH 03/36] Add ReaderOptions to CZI reader initialization Introduces a new ReaderOptions dataclass for configuring CZI reader behavior, including mask awareness and visibility check optimization. Updates CziReader and open_czi to accept and document the new reader_options parameter. --- pylibCZIrw/czi.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pylibCZIrw/czi.py b/pylibCZIrw/czi.py index 761936c..8de28a2 100644 --- a/pylibCZIrw/czi.py +++ b/pylibCZIrw/czi.py @@ -69,6 +69,16 @@ class CacheOptions: max_sub_block_count: Optional[int] = None +@dataclass +class ReaderOptions: + """Reader options data structure. + + Configuration options for CZI reader. + """ + enable_mask_awareness: bool = False # whether the accessor will use the valid-pixel-mask for the tile-composition + enable_visibility_check_optimization = False # whether the accessor will use the visibility-check-optimization for the tile-composition + + @dataclass class Rgb8Color: """Rgb8Color class. @@ -151,6 +161,7 @@ def __init__( filepath: str, file_input_type: ReaderFileInputTypes = ReaderFileInputTypes.Standard, cache_options: Optional[CacheOptions] = None, + reader_options: Optional[ReaderOptions] = None, ) -> None: """Creates a czi reader object, should only be called through the open_czi() function. @@ -1270,6 +1281,8 @@ def open_czi( filepath: str, file_input_type: ReaderFileInputTypes = ReaderFileInputTypes.Standard, cache_options: Optional[CacheOptions] = None, + *, + reader_options: Optional[ReaderOptions] = None, ) -> Generator: """Initialize a czi reader object and returns it. Opens the filepath and hands it over to the low-level function. @@ -1282,6 +1295,9 @@ def open_czi( The type of file input, default is local file. cache_options : CacheOptions, optional The configuration of a subblock cache to be used. Per default no cache is used. + reader_options: ReaderOptions, optional + Additional configuration options for the reader. Note that there is a keyword-only argument + boundary before the reader_options argument. Returns ---------- From d79f6c46c6c24d466114da9c8876e79ff5656c9c Mon Sep 17 00:00:00 2001 From: Juergen Bohl Date: Thu, 18 Sep 2025 22:42:28 +0200 Subject: [PATCH 04/36] Switch submodule libs/libCZIrw to https://github.com/ptahmose/libczi-zeiss.git (branch jbl/mask-support) --- .gitmodules | 4 ++-- libs/libCZIrw | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index d077d22..8640183 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,7 @@ [submodule "libs/libCZIrw"] path = libs/libCZIrw - url = https://github.com/ptahmose/libczi-zeiss.git - branch = jbl/mask-support + url = https://github.com/ZEISS/libczi.git + branch = main [submodule "libs/pybind11"] path = libs/pybind11 url = https://github.com/pybind/pybind11 diff --git a/libs/libCZIrw b/libs/libCZIrw index bc4300d..a996184 160000 --- a/libs/libCZIrw +++ b/libs/libCZIrw @@ -1 +1 @@ -Subproject commit bc4300dd35f64bf802bc84722ea6d8ae8a15e455 +Subproject commit a9961845f465412abf1e468851afc5e8c764202b From 5105b728cd5dd4af6afbda952ec4782d6322553d Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 11:36:46 +0200 Subject: [PATCH 05/36] add support for "reader-options" --- _pylibCZIrw/src/api/CMakeLists.txt | 3 ++- _pylibCZIrw/src/api/CZIreadAPI.cpp | 18 +++++++++++++++-- _pylibCZIrw/src/api/CZIreadAPI.h | 26 ++++++++++++++++--------- _pylibCZIrw/src/api/ReaderOptions.h | 18 +++++++++++++++++ _pylibCZIrw/src/bindings/CZIrw.cpp | 16 +++++++++++++++ _pylibCZIrw/src/pylibCZIrw_Config.h | 4 ++++ pylibCZIrw/czi.py | 30 ++++++++++++++++++++++++++--- 7 files changed, 100 insertions(+), 15 deletions(-) create mode 100644 _pylibCZIrw/src/api/ReaderOptions.h create mode 100644 _pylibCZIrw/src/pylibCZIrw_Config.h diff --git a/_pylibCZIrw/src/api/CMakeLists.txt b/_pylibCZIrw/src/api/CMakeLists.txt index 9934d82..bdcccb0 100644 --- a/_pylibCZIrw/src/api/CMakeLists.txt +++ b/_pylibCZIrw/src/api/CMakeLists.txt @@ -13,7 +13,8 @@ add_library( site.cpp StaticContext.cpp StaticContext.h - SubBlockCache.h) + SubBlockCache.h + ReaderOptions.h) target_include_directories(_pylibCZIrw_API PRIVATE ${libCZI_SOURCE_DIR}) target_link_libraries(_pylibCZIrw_API INTERFACE libCZIStatic JxrDecodeStatic) diff --git a/_pylibCZIrw/src/api/CZIreadAPI.cpp b/_pylibCZIrw/src/api/CZIreadAPI.cpp index 572c717..8a8de20 100644 --- a/_pylibCZIrw/src/api/CZIreadAPI.cpp +++ b/_pylibCZIrw/src/api/CZIreadAPI.cpp @@ -21,7 +21,16 @@ CZIreadAPI::CZIreadAPI(const std::string &stream_class_name, CZIreadAPI::CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, - const SubBlockCacheOptions &subBlockCacheOptions) { + const SubBlockCacheOptions &subBlockCacheOptions) + : CZIreadAPI(stream_class_name, fileName, subBlockCacheOptions, + ReaderOptions()) {} + + + +CZIreadAPI::CZIreadAPI(const std::string &stream_class_name, + const std::wstring &fileName, + const SubBlockCacheOptions &subBlockCacheOptions, + const ReaderOptions &readerOptions) { shared_ptr stream; if (stream_class_name.empty() || stream_class_name == "standard") { stream = StreamsFactory::CreateDefaultStreamForFile(fileName.c_str()); @@ -49,6 +58,7 @@ CZIreadAPI::CZIreadAPI(const std::string &stream_class_name, this->spAccessor = reader->CreateSingleChannelScalingTileAccessor(); this->spReader = reader; this->subBlockCacheOptions = subBlockCacheOptions; + this->readerOptions = readerOptions; if (subBlockCacheOptions.cacheType == CacheType::Standard) { this->spSubBlockCache = libCZI::CreateSubBlockCache(); } else if (subBlockCacheOptions.cacheType != CacheType::None) { @@ -118,7 +128,11 @@ std::unique_ptr CZIreadAPI::GetSingleChannelScalingTileAccessorData( libCZI::ISingleChannelScalingTileAccessor::Options scstaOptions; scstaOptions.Clear(); scstaOptions.useVisibilityCheckOptimization = - true; // enable the "visibility check optimization" + this->readerOptions.enableVisibilityCheckOptimization; // set the flag "visibility check optimization" + // as configured by the user + scstaOptions.maskAware = + this->readerOptions.enableMaskAwareness; // set the flag "mask awareness" as + // configured by the user scstaOptions.backGroundColor = bgColor; if (this->spSubBlockCache) { scstaOptions.subBlockCache = this->spSubBlockCache; diff --git a/_pylibCZIrw/src/api/CZIreadAPI.h b/_pylibCZIrw/src/api/CZIreadAPI.h index 80dec66..9b56bb8 100644 --- a/_pylibCZIrw/src/api/CZIreadAPI.h +++ b/_pylibCZIrw/src/api/CZIreadAPI.h @@ -2,6 +2,7 @@ #include "PImage.h" #include "SubBlockCache.h" +#include "ReaderOptions.h" #include "inc_libCzi.h" #include #include @@ -22,6 +23,9 @@ class CZIreadAPI { SubBlockCacheOptions subBlockCacheOptions; ///< Options for using the subblock cache + ReaderOptions readerOptions; ///< Options for the reader, such as enabling mask + ///< awareness and visibility check optimizations + public: /// Constructor which constructs a CZIrwAPI object from the given wstring. /// Creates a spReader and spAccessor (SingleChannelTilingScalingAccessor) for @@ -47,9 +51,10 @@ class CZIreadAPI { /// Creates a spReader and spAccessor (SingleChannelTilingScalingAccessor) for /// the czi document pointed by the given filepath. /// This constructor allows defining a subblock cache to be used for - /// performance optimization. \param fileName Filename of the - /// file. \param subBlockCacheOptions Options for initializing the - /// subblock cache. + /// performance optimization. + /// \param fileName Filename of the file. + /// \param subBlockCacheOptions Options for initializing the + /// subblock cache. CZIreadAPI(const std::wstring &fileName, const SubBlockCacheOptions &subBlockCacheOptions); @@ -61,16 +66,19 @@ class CZIreadAPI { /// optimization. /// /// \param stream_class_name A string identifying the stream class to - /// be used (note that this string is *not* the same string the libCZI-streams - /// factory uses. There is a mapping between - /// the two strings done in the CZIrwAPI - /// constructor. + /// be used (note that this string is *not* the same + /// string the libCZI-streams factory uses. There is a mapping between + /// the two strings done in the CZIrwAPI constructor. /// \param fileName Filename (or URI) of the file (the - /// interpretation of the string is stream class specific). \param - /// subBlockCacheOptions Options for initializing the subblock cache. + /// interpretation of the string is stream class specific). + /// \param subBlockCacheOptions Options for initializing the subblock cache. CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, const SubBlockCacheOptions &subBlockCacheOptions); + CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, + const SubBlockCacheOptions &subBlockCacheOptions, + const ReaderOptions &readerOptions); + /// Close the Opened czi document void close() { this->spReader->Close(); } diff --git a/_pylibCZIrw/src/api/ReaderOptions.h b/_pylibCZIrw/src/api/ReaderOptions.h new file mode 100644 index 0000000..79a2755 --- /dev/null +++ b/_pylibCZIrw/src/api/ReaderOptions.h @@ -0,0 +1,18 @@ +#pragma once +#include "inc_libCzi.h" + +/// This POD ("plain-old-data") structure gathers open-time options for the +/// CZI reader. It is used to configure the reader's behavior, such as enabling +/// mask awareness and visibility check optimizations. +struct ReaderOptions { + /// whether to enable mask awareness + bool enableMaskAwareness = false; + + /// whether to enable visibility check optimization + bool enableVisibilityCheckOptimization = true; + + void Clear() { + this->enableMaskAwareness = false; + this->enableVisibilityCheckOptimization = true; + } +}; diff --git a/_pylibCZIrw/src/bindings/CZIrw.cpp b/_pylibCZIrw/src/bindings/CZIrw.cpp index fd4dc2d..bfb4c63 100644 --- a/_pylibCZIrw/src/bindings/CZIrw.cpp +++ b/_pylibCZIrw/src/bindings/CZIrw.cpp @@ -2,6 +2,7 @@ #include "../api/CZIwriteAPI.h" #include "../api/PImage.h" #include "../api/SubBlockCache.h" +#include "../api/ReaderOptions.h" #include "../api/site.h" #include "PbHelper.h" @@ -33,6 +34,13 @@ PYBIND11_MODULE(_pylibCZIrw, m) { return new CZIreadAPI(stream_class_name, fileName, subBlockCacheOptions); })) + .def(py::init([](const std::string &stream_class_name, + const std::wstring &fileName, + const SubBlockCacheOptions &subBlockCacheOptions, + const ReaderOptions &readerOptions) { + return new CZIreadAPI(stream_class_name, fileName, + subBlockCacheOptions, readerOptions); + })) .def("close", &CZIreadAPI::close) .def("GetXmlMetadata", &CZIreadAPI::GetXmlMetadata) .def("GetSubBlockStats", &CZIreadAPI::GetSubBlockStats) @@ -219,6 +227,14 @@ PYBIND11_MODULE(_pylibCZIrw, m) { .def_readwrite("elements_count", &SubBlockCacheInfo::elementsCount) .def_readwrite("memory_usage", &SubBlockCacheInfo::memoryUsage); + py::class_(m, "ReaderOptions", py::module_local()) + .def(py::init<>()) + .def_readwrite("enableMaskAwareness", + &ReaderOptions::enableMaskAwareness) + .def_readwrite("enableVisibilityCheckOptimization", + &ReaderOptions::enableVisibilityCheckOptimization) + .def("Clear", &ReaderOptions::Clear); + // perform one-time-initialization of libCZI OneTimeSiteInitialization(); } diff --git a/_pylibCZIrw/src/pylibCZIrw_Config.h b/_pylibCZIrw/src/pylibCZIrw_Config.h new file mode 100644 index 0000000..a07ecd6 --- /dev/null +++ b/_pylibCZIrw/src/pylibCZIrw_Config.h @@ -0,0 +1,4 @@ +#pragma once + +// Make the project version available on the C++ side +#define PROJECT_VERSION "" diff --git a/pylibCZIrw/czi.py b/pylibCZIrw/czi.py index 8de28a2..6949bb2 100644 --- a/pylibCZIrw/czi.py +++ b/pylibCZIrw/czi.py @@ -1,7 +1,7 @@ """Module implementing the czi interface The open method will create a czi document. -This czi document can be use to read and write czi. +This czi document can be used to read and write czi. """ import contextlib @@ -76,7 +76,7 @@ class ReaderOptions: Configuration options for CZI reader. """ enable_mask_awareness: bool = False # whether the accessor will use the valid-pixel-mask for the tile-composition - enable_visibility_check_optimization = False # whether the accessor will use the visibility-check-optimization for the tile-composition + enable_visibility_check_optimization = True # whether the accessor will use the visibility-check-optimization for the tile-composition @dataclass @@ -175,6 +175,8 @@ def __init__( The configuration of a subblock cache to be used. """ libczi_cache_options = self._create_default_cache_options(cache_options=cache_options) + libczi_reader_options = self._create_reader_options(reader_options=reader_options) + if file_input_type is ReaderFileInputTypes.Curl: if validators.url(filepath): # When reading from CURL stream we assume that the connection is slow @@ -207,6 +209,28 @@ def close(self) -> None: """Close the document and finalize the reading""" self._czi_reader.close() + @staticmethod + def _create_reader_options(reader_options: Optional[ReaderOptions]) -> _pylibCZIrw.ReaderOptions: + """Creates a ReaderOptions object from the ReaderOptions dataclass. + + Parameters + ---------- + reader_options : ReaderOptions + Reader options dataclass + + Returns + ------- + : _pylibCZIrw.ReaderOptions + Reader options object. + """ + libczi_reader_options = _pylibCZIrw.ReaderOptions() + libczi_reader_options.Clear() + if reader_options: + libczi_reader_options.enableMaskAwareness = reader_options.enable_mask_awareness + libczi_reader_options.enableVisibilityCheckOptimization = reader_options.enable_visibility_check_optimization + return libczi_reader_options + + @staticmethod def _compute_index_ranges( rectangle: _pylibCZIrw.IntRect, @@ -1304,7 +1328,7 @@ def open_czi( : czi CziReader document as a czi object """ - reader = CziReader(filepath, file_input_type, cache_options=cache_options) + reader = CziReader(filepath, file_input_type, cache_options=cache_options, reader_options=reader_options) try: yield reader finally: From a1fd846b5c098c99c3bb680606e07010c7303588 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 12:21:37 +0200 Subject: [PATCH 06/36] add to "API.md" --- API.md | 22 ++++++++++++++++++++++ pylibCZIrw/czi.py | 1 - 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/API.md b/API.md index fa0d6ab..1ecbbc7 100644 --- a/API.md +++ b/API.md @@ -62,6 +62,28 @@ with czi.open_czi(file_path, cache_options=cache_options) as czi: ... ``` +### Specifying additional reader-options +The `open_czi` method accepts a `ReaderOptions` structure where additional configurations +can be given controlling the operations. There are two options currently available: +- `enable_mask_awareness` - whether the tile-composition uses mask-information. This is by default `false`. +- `enable_visibility_check_optimization` - in the tile-composition, do a visibility-check before reading sub-blocks, potentially reducing the amount of data that must be loaded. This is by default `true`. + +The `ReaderOptions` can be passed to `open_czi` like in this example: + +```python +cache_options = CacheOptions( + type = CacheType.Standard, + max_memory_usge = 500 * 1024**2 # 500 Megabytes + max_sub_block_count = 100, +) +reader_options = ReaderOptions( + enable_mask_awareness = True +) +with czi.open_czi(file_path, cache_options=cache_options, reader_options=reader_options) as czi: + ... +``` + + ## Reading a CZI The following calls all relate to reading information from the CZI. And, whenever they're called, the file's last write date will be evaluated and cached. **If the file was changed while opened, all file caches will be invalidated.** diff --git a/pylibCZIrw/czi.py b/pylibCZIrw/czi.py index 6949bb2..c0e500d 100644 --- a/pylibCZIrw/czi.py +++ b/pylibCZIrw/czi.py @@ -230,7 +230,6 @@ def _create_reader_options(reader_options: Optional[ReaderOptions]) -> _pylibCZI libczi_reader_options.enableVisibilityCheckOptimization = reader_options.enable_visibility_check_optimization return libczi_reader_options - @staticmethod def _compute_index_ranges( rectangle: _pylibCZIrw.IntRect, From a2ebd51cf779fa4be44693a814aeff89cb96a600 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 12:34:24 +0200 Subject: [PATCH 07/36] linter --- pylibCZIrw/czi.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pylibCZIrw/czi.py b/pylibCZIrw/czi.py index c0e500d..06a776c 100644 --- a/pylibCZIrw/czi.py +++ b/pylibCZIrw/czi.py @@ -75,8 +75,10 @@ class ReaderOptions: Configuration options for CZI reader. """ - enable_mask_awareness: bool = False # whether the accessor will use the valid-pixel-mask for the tile-composition - enable_visibility_check_optimization = True # whether the accessor will use the visibility-check-optimization for the tile-composition + enable_mask_awareness: bool = False # whether the accessor will use the valid-pixel-mask for the + # tile-composition + enable_visibility_check_optimization = True # whether the accessor will use the visibility-check-optimization + # for the tile-composition @dataclass @@ -183,14 +185,14 @@ def __init__( # And therefore also cache uncompressed subblocks. libczi_cache_options.cacheOnlyCompressed = False self._czi_reader = _pylibCZIrw.czi_reader( - ReaderFileInputTypes.Curl.value, filepath, libczi_cache_options + ReaderFileInputTypes.Curl.value, filepath, libczi_cache_options, libczi_reader_options ) else: raise FileNotFoundError(f"{filepath} is not a valid URL.") else: # When reading from disk we only cache compressed subblocks. libczi_cache_options.cacheOnlyCompressed = True - self._czi_reader = _pylibCZIrw.czi_reader(filepath, libczi_cache_options) + self._czi_reader = _pylibCZIrw.czi_reader(filepath, libczi_cache_options, libczi_reader_options) self._stats = self._czi_reader.GetSubBlockStats() @classmethod @@ -227,7 +229,8 @@ def _create_reader_options(reader_options: Optional[ReaderOptions]) -> _pylibCZI libczi_reader_options.Clear() if reader_options: libczi_reader_options.enableMaskAwareness = reader_options.enable_mask_awareness - libczi_reader_options.enableVisibilityCheckOptimization = reader_options.enable_visibility_check_optimization + libczi_reader_options.enableVisibilityCheckOptimization = + reader_options.enable_visibility_check_optimization return libczi_reader_options @staticmethod From 09c757c71cd38f14a4550db2801cb3b8e451128b Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 12:44:41 +0200 Subject: [PATCH 08/36] fix syntax error --- pylibCZIrw/czi.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pylibCZIrw/czi.py b/pylibCZIrw/czi.py index 06a776c..6ebc74c 100644 --- a/pylibCZIrw/czi.py +++ b/pylibCZIrw/czi.py @@ -229,8 +229,9 @@ def _create_reader_options(reader_options: Optional[ReaderOptions]) -> _pylibCZI libczi_reader_options.Clear() if reader_options: libczi_reader_options.enableMaskAwareness = reader_options.enable_mask_awareness - libczi_reader_options.enableVisibilityCheckOptimization = + libczi_reader_options.enableVisibilityCheckOptimization = ( reader_options.enable_visibility_check_optimization + ) return libczi_reader_options @staticmethod From a0dd70436a6001fb1f5993b9e55b3a6989329aaa Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 13:00:25 +0200 Subject: [PATCH 09/36] linter --- pylibCZIrw/czi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylibCZIrw/czi.py b/pylibCZIrw/czi.py index 6ebc74c..450dce7 100644 --- a/pylibCZIrw/czi.py +++ b/pylibCZIrw/czi.py @@ -76,9 +76,9 @@ class ReaderOptions: Configuration options for CZI reader. """ enable_mask_awareness: bool = False # whether the accessor will use the valid-pixel-mask for the - # tile-composition + # tile-composition enable_visibility_check_optimization = True # whether the accessor will use the visibility-check-optimization - # for the tile-composition + # for the tile-composition @dataclass From 18b0d4c0c6c0efc7fcba125320b9f58f83fb3c98 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 13:04:45 +0200 Subject: [PATCH 10/36] linter --- _pylibCZIrw/src/api/CZIreadAPI.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/_pylibCZIrw/src/api/CZIreadAPI.h b/_pylibCZIrw/src/api/CZIreadAPI.h index 9b56bb8..0d9b353 100644 --- a/_pylibCZIrw/src/api/CZIreadAPI.h +++ b/_pylibCZIrw/src/api/CZIreadAPI.h @@ -23,8 +23,9 @@ class CZIreadAPI { SubBlockCacheOptions subBlockCacheOptions; ///< Options for using the subblock cache - ReaderOptions readerOptions; ///< Options for the reader, such as enabling mask - ///< awareness and visibility check optimizations + ReaderOptions + readerOptions; ///< Options for the reader, such as enabling mask + ///< awareness and visibility check optimizations public: /// Constructor which constructs a CZIrwAPI object from the given wstring. @@ -75,6 +76,22 @@ class CZIreadAPI { CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, const SubBlockCacheOptions &subBlockCacheOptions); + /// Constructor which constructs a CZIrwAPI object, allowing to specify a + /// stream class name. Possible stream class names are: "standard" for reading + /// files in the file system, and "curl" for reading files from a web server. + /// "curl" is mapped to the libCZI-streams class "curl_http_inputstream". This + /// constructor allows defining a subblock cache to be used for performance + /// optimization. In addition, is allows to specify reader options. + /// + /// \param stream_class_name A string identifying the stream class to + /// be used (note that this string is *not* the same + /// string the libCZI-streams factory uses. There is a mapping between + /// the two strings done in the CZIrwAPI constructor. + /// \param fileName Filename (or URI) of the file (the + /// interpretation of the string is stream class specific). + /// \param subBlockCacheOptions Options for initializing the subblock cache. + /// \param readerOptions Options controlling the reader operation, such as enabling + /// mask awareness tile-composition. CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, const SubBlockCacheOptions &subBlockCacheOptions, const ReaderOptions &readerOptions); From 32692e75a4340d7edda8e42e7546fd00c4a256bc Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 13:13:19 +0200 Subject: [PATCH 11/36] linter --- pylibCZIrw/czi.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pylibCZIrw/czi.py b/pylibCZIrw/czi.py index 450dce7..a8e05de 100644 --- a/pylibCZIrw/czi.py +++ b/pylibCZIrw/czi.py @@ -75,10 +75,10 @@ class ReaderOptions: Configuration options for CZI reader. """ - enable_mask_awareness: bool = False # whether the accessor will use the valid-pixel-mask for the + enable_mask_awareness: bool = False # whether the accessor will use the valid-pixel-mask for the # tile-composition - enable_visibility_check_optimization = True # whether the accessor will use the visibility-check-optimization - # for the tile-composition + enable_visibility_check_optimization: bool = True # whether the accessor will use the + # visibility-check-optimization for the tile-composition @dataclass From f879748cf306facb467cd7756ad5f9d28e9aedd9 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 13:20:46 +0200 Subject: [PATCH 12/36] linter --- pylibCZIrw/czi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylibCZIrw/czi.py b/pylibCZIrw/czi.py index a8e05de..7a65424 100644 --- a/pylibCZIrw/czi.py +++ b/pylibCZIrw/czi.py @@ -77,7 +77,7 @@ class ReaderOptions: """ enable_mask_awareness: bool = False # whether the accessor will use the valid-pixel-mask for the # tile-composition - enable_visibility_check_optimization: bool = True # whether the accessor will use the + enable_visibility_check_optimization: bool = True # whether the accessor will use the # visibility-check-optimization for the tile-composition From 5af71fe41aaef794fe07699100ac3bcce2c71b3e Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 13:34:28 +0200 Subject: [PATCH 13/36] linter --- _pylibCZIrw/src/bindings/PbHelper.h | 1 + pylibCZIrw/czi.py | 1 + 2 files changed, 2 insertions(+) diff --git a/_pylibCZIrw/src/bindings/PbHelper.h b/_pylibCZIrw/src/bindings/PbHelper.h index 27d6d6f..a07a0bc 100644 --- a/_pylibCZIrw/src/bindings/PbHelper.h +++ b/_pylibCZIrw/src/bindings/PbHelper.h @@ -21,6 +21,7 @@ class CMemBitmapWrapper : public libCZI::IBitmapData { std::uint32_t height; std::uint32_t stride; std::atomic lockCnt = ATOMIC_VAR_INIT(0); + public: CMemBitmapWrapper(libCZI::PixelType pixeltype, std::uint32_t width, std::uint32_t height, std::uint32_t stride) diff --git a/pylibCZIrw/czi.py b/pylibCZIrw/czi.py index 7a65424..3a5ae2c 100644 --- a/pylibCZIrw/czi.py +++ b/pylibCZIrw/czi.py @@ -75,6 +75,7 @@ class ReaderOptions: Configuration options for CZI reader. """ + enable_mask_awareness: bool = False # whether the accessor will use the valid-pixel-mask for the # tile-composition enable_visibility_check_optimization: bool = True # whether the accessor will use the From 65c8cdae856a3adc4cdb3a638760cc31a61a54b5 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 13:38:07 +0200 Subject: [PATCH 14/36] linter --- pylibCZIrw/czi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylibCZIrw/czi.py b/pylibCZIrw/czi.py index 3a5ae2c..67cdf91 100644 --- a/pylibCZIrw/czi.py +++ b/pylibCZIrw/czi.py @@ -75,7 +75,7 @@ class ReaderOptions: Configuration options for CZI reader. """ - + enable_mask_awareness: bool = False # whether the accessor will use the valid-pixel-mask for the # tile-composition enable_visibility_check_optimization: bool = True # whether the accessor will use the From e8a7e3e14e92ff31a4c422fd77d4c5d836d3e105 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 14:05:25 +0200 Subject: [PATCH 15/36] lint --- _pylibCZIrw/src/api/CZIreadAPI.cpp | 2 +- _pylibCZIrw/src/api/CZIreadAPI.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/_pylibCZIrw/src/api/CZIreadAPI.cpp b/_pylibCZIrw/src/api/CZIreadAPI.cpp index 8a8de20..7decc6e 100644 --- a/_pylibCZIrw/src/api/CZIreadAPI.cpp +++ b/_pylibCZIrw/src/api/CZIreadAPI.cpp @@ -23,7 +23,7 @@ CZIreadAPI::CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, const SubBlockCacheOptions &subBlockCacheOptions) : CZIreadAPI(stream_class_name, fileName, subBlockCacheOptions, - ReaderOptions()) {} + ReaderOptions()) {} diff --git a/_pylibCZIrw/src/api/CZIreadAPI.h b/_pylibCZIrw/src/api/CZIreadAPI.h index 0d9b353..513b10f 100644 --- a/_pylibCZIrw/src/api/CZIreadAPI.h +++ b/_pylibCZIrw/src/api/CZIreadAPI.h @@ -22,11 +22,10 @@ class CZIreadAPI { ///< null (in which case no caching is done) SubBlockCacheOptions subBlockCacheOptions; ///< Options for using the subblock cache - ReaderOptions readerOptions; ///< Options for the reader, such as enabling mask ///< awareness and visibility check optimizations - + public: /// Constructor which constructs a CZIrwAPI object from the given wstring. /// Creates a spReader and spAccessor (SingleChannelTilingScalingAccessor) for From fef6e44e7b1eda3f7f85f8a59f206bcf7c4518a1 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 14:05:38 +0200 Subject: [PATCH 16/36] linter --- .vscode/settings.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..9e284b8 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "files.associations": { + "xlocbuf": "cpp", + "stdexcept": "cpp", + "atomic": "cpp" + }, + "github.copilot.advanced": { + + } +} \ No newline at end of file From df8f7b175e1e5f3dbafa3c0eca7830fa54d66d3e Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 14:46:43 +0200 Subject: [PATCH 17/36] linter --- _pylibCZIrw/src/api/CZIreadAPI.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/_pylibCZIrw/src/api/CZIreadAPI.cpp b/_pylibCZIrw/src/api/CZIreadAPI.cpp index 7decc6e..f65805e 100644 --- a/_pylibCZIrw/src/api/CZIreadAPI.cpp +++ b/_pylibCZIrw/src/api/CZIreadAPI.cpp @@ -22,10 +22,7 @@ CZIreadAPI::CZIreadAPI(const std::string &stream_class_name, CZIreadAPI::CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, const SubBlockCacheOptions &subBlockCacheOptions) - : CZIreadAPI(stream_class_name, fileName, subBlockCacheOptions, - ReaderOptions()) {} - - + : CZIreadAPI(stream_class_name, fileName, subBlockCacheOptions, ReaderOptions()) {} CZIreadAPI::CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, @@ -127,12 +124,11 @@ std::unique_ptr CZIreadAPI::GetSingleChannelScalingTileAccessorData( libCZI::ISingleChannelScalingTileAccessor::Options scstaOptions; scstaOptions.Clear(); + // set the flag "visibility check optimization" as configured by the user scstaOptions.useVisibilityCheckOptimization = - this->readerOptions.enableVisibilityCheckOptimization; // set the flag "visibility check optimization" - // as configured by the user - scstaOptions.maskAware = - this->readerOptions.enableMaskAwareness; // set the flag "mask awareness" as - // configured by the user + this->readerOptions.enableVisibilityCheckOptimization; + // set the flag "mask awareness" as configured by the user + scstaOptions.maskAware = this->readerOptions.enableMaskAwareness; scstaOptions.backGroundColor = bgColor; if (this->spSubBlockCache) { scstaOptions.subBlockCache = this->spSubBlockCache; From fc0641d8a9a5cbd9b9abdab51fd6f561d7148479 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 14:48:00 +0200 Subject: [PATCH 18/36] remove settings.json --- .vscode/settings.json | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 9e284b8..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "files.associations": { - "xlocbuf": "cpp", - "stdexcept": "cpp", - "atomic": "cpp" - }, - "github.copilot.advanced": { - - } -} \ No newline at end of file From cc6a3fedbd351dc6dc5b3c57c685d4dfe4ed8f55 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 14:55:28 +0200 Subject: [PATCH 19/36] linter --- _pylibCZIrw/src/api/CZIreadAPI.cpp | 2 +- _pylibCZIrw/src/api/CZIreadAPI.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/_pylibCZIrw/src/api/CZIreadAPI.cpp b/_pylibCZIrw/src/api/CZIreadAPI.cpp index f65805e..ba81e25 100644 --- a/_pylibCZIrw/src/api/CZIreadAPI.cpp +++ b/_pylibCZIrw/src/api/CZIreadAPI.cpp @@ -21,7 +21,7 @@ CZIreadAPI::CZIreadAPI(const std::string &stream_class_name, CZIreadAPI::CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, - const SubBlockCacheOptions &subBlockCacheOptions) + const SubBlockCacheOptions &subBlockCacheOptions) : CZIreadAPI(stream_class_name, fileName, subBlockCacheOptions, ReaderOptions()) {} CZIreadAPI::CZIreadAPI(const std::string &stream_class_name, diff --git a/_pylibCZIrw/src/api/CZIreadAPI.h b/_pylibCZIrw/src/api/CZIreadAPI.h index 513b10f..47a22ee 100644 --- a/_pylibCZIrw/src/api/CZIreadAPI.h +++ b/_pylibCZIrw/src/api/CZIreadAPI.h @@ -24,8 +24,8 @@ class CZIreadAPI { subBlockCacheOptions; ///< Options for using the subblock cache ReaderOptions readerOptions; ///< Options for the reader, such as enabling mask - ///< awareness and visibility check optimizations - + ///< awareness and visibility check optimizations + public: /// Constructor which constructs a CZIrwAPI object from the given wstring. /// Creates a spReader and spAccessor (SingleChannelTilingScalingAccessor) for @@ -88,12 +88,12 @@ class CZIreadAPI { /// the two strings done in the CZIrwAPI constructor. /// \param fileName Filename (or URI) of the file (the /// interpretation of the string is stream class specific). - /// \param subBlockCacheOptions Options for initializing the subblock cache. + /// \param subBlockCacheOptions Options for initializing the subblock cache. /// \param readerOptions Options controlling the reader operation, such as enabling /// mask awareness tile-composition. CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, const SubBlockCacheOptions &subBlockCacheOptions, - const ReaderOptions &readerOptions); + const ReaderOptions &readerOptions); /// Close the Opened czi document void close() { this->spReader->Close(); } From 5f7de916917668ba1d7ce05321da5e96d19aa34f Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 15:02:37 +0200 Subject: [PATCH 20/36] linter --- _pylibCZIrw/src/bindings/PbHelper.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/_pylibCZIrw/src/bindings/PbHelper.h b/_pylibCZIrw/src/bindings/PbHelper.h index a07a0bc..d6dcd18 100644 --- a/_pylibCZIrw/src/bindings/PbHelper.h +++ b/_pylibCZIrw/src/bindings/PbHelper.h @@ -20,7 +20,7 @@ class CMemBitmapWrapper : public libCZI::IBitmapData { std::uint32_t width; std::uint32_t height; std::uint32_t stride; - std::atomic lockCnt = ATOMIC_VAR_INIT(0); + std::atomic lock_count = ATOMIC_VAR_INIT(0); public: CMemBitmapWrapper(libCZI::PixelType pixeltype, std::uint32_t width, @@ -44,16 +44,16 @@ class CMemBitmapWrapper : public libCZI::IBitmapData { bitmapLockInfo.ptrDataRoi = this->ptrData; bitmapLockInfo.stride = this->stride; bitmapLockInfo.size = this->stride * static_cast(this->height); - std::atomic_fetch_add(&this->lockCnt, 1); + std::atomic_fetch_add(&this->lock_count, 1); return bitmapLockInfo; } virtual void Unlock() { - std::atomic_fetch_sub(&this->lockCnt, 1); + std::atomic_fetch_sub(&this->lock_count, 1); } virtual int GetLockCount() const { - return std::atomic_load(&this->lockCnt); + return std::atomic_load(&this->lock_count); } }; From 0c103fc79c3a26c4f633be96ef6fb32d351e37e2 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 15:06:36 +0200 Subject: [PATCH 21/36] linter --- _pylibCZIrw/src/api/CZIreadAPI.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/_pylibCZIrw/src/api/CZIreadAPI.h b/_pylibCZIrw/src/api/CZIreadAPI.h index 47a22ee..bed6e41 100644 --- a/_pylibCZIrw/src/api/CZIreadAPI.h +++ b/_pylibCZIrw/src/api/CZIreadAPI.h @@ -66,11 +66,11 @@ class CZIreadAPI { /// optimization. /// /// \param stream_class_name A string identifying the stream class to - /// be used (note that this string is *not* the same - /// string the libCZI-streams factory uses. There is a mapping between - /// the two strings done in the CZIrwAPI constructor. + /// be used (note that this string is *not* the same + /// string the libCZI-streams factory uses. There is a mapping between + /// the two strings done in the CZIrwAPI constructor. /// \param fileName Filename (or URI) of the file (the - /// interpretation of the string is stream class specific). + /// interpretation of the string is stream class specific). /// \param subBlockCacheOptions Options for initializing the subblock cache. CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, const SubBlockCacheOptions &subBlockCacheOptions); @@ -83,14 +83,14 @@ class CZIreadAPI { /// optimization. In addition, is allows to specify reader options. /// /// \param stream_class_name A string identifying the stream class to - /// be used (note that this string is *not* the same - /// string the libCZI-streams factory uses. There is a mapping between - /// the two strings done in the CZIrwAPI constructor. + /// be used (note that this string is *not* the same + /// string the libCZI-streams factory uses. There is a mapping between + /// the two strings done in the CZIrwAPI constructor. /// \param fileName Filename (or URI) of the file (the - /// interpretation of the string is stream class specific). + /// interpretation of the string is stream class specific). /// \param subBlockCacheOptions Options for initializing the subblock cache. /// \param readerOptions Options controlling the reader operation, such as enabling - /// mask awareness tile-composition. + /// mask awareness tile-composition. CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, const SubBlockCacheOptions &subBlockCacheOptions, const ReaderOptions &readerOptions); From 09604cacb2dc1977622b6af202661f664f7405df Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 15:14:36 +0200 Subject: [PATCH 22/36] linter --- _pylibCZIrw/src/api/CZIreadAPI.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/_pylibCZIrw/src/api/CZIreadAPI.h b/_pylibCZIrw/src/api/CZIreadAPI.h index bed6e41..133b54d 100644 --- a/_pylibCZIrw/src/api/CZIreadAPI.h +++ b/_pylibCZIrw/src/api/CZIreadAPI.h @@ -66,12 +66,16 @@ class CZIreadAPI { /// optimization. /// /// \param stream_class_name A string identifying the stream class to - /// be used (note that this string is *not* the same - /// string the libCZI-streams factory uses. There is a mapping between - /// the two strings done in the CZIrwAPI constructor. + /// be used (note that this string is *not* + /// the same string the libCZI-streams + /// factory uses. There is a mapping between + /// the two strings done in the CZIrwAPI + /// constructor. /// \param fileName Filename (or URI) of the file (the - /// interpretation of the string is stream class specific). - /// \param subBlockCacheOptions Options for initializing the subblock cache. + /// interpretation of the string is stream + /// class specific). + /// \param subBlockCacheOptions Options for initializing the subblock + /// cache. CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, const SubBlockCacheOptions &subBlockCacheOptions); From c70950dcded0b71bd44e568732ec104ad6d7a433 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 15:15:44 +0200 Subject: [PATCH 23/36] linter --- _pylibCZIrw/src/api/CZIreadAPI.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_pylibCZIrw/src/api/CZIreadAPI.cpp b/_pylibCZIrw/src/api/CZIreadAPI.cpp index ba81e25..9e8d684 100644 --- a/_pylibCZIrw/src/api/CZIreadAPI.cpp +++ b/_pylibCZIrw/src/api/CZIreadAPI.cpp @@ -22,7 +22,8 @@ CZIreadAPI::CZIreadAPI(const std::string &stream_class_name, CZIreadAPI::CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, const SubBlockCacheOptions &subBlockCacheOptions) - : CZIreadAPI(stream_class_name, fileName, subBlockCacheOptions, ReaderOptions()) {} + : CZIreadAPI(stream_class_name, fileName, subBlockCacheOptions, + ReaderOptions()) {} CZIreadAPI::CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, From 073071ddce83ee87a178ea6faea0196df4604e09 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 15:22:01 +0200 Subject: [PATCH 24/36] linter --- _pylibCZIrw/src/api/CZIreadAPI.h | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/_pylibCZIrw/src/api/CZIreadAPI.h b/_pylibCZIrw/src/api/CZIreadAPI.h index 133b54d..490ec8e 100644 --- a/_pylibCZIrw/src/api/CZIreadAPI.h +++ b/_pylibCZIrw/src/api/CZIreadAPI.h @@ -66,13 +66,13 @@ class CZIreadAPI { /// optimization. /// /// \param stream_class_name A string identifying the stream class to - /// be used (note that this string is *not* - /// the same string the libCZI-streams + /// be used (note that this string is *not* + /// the same string the libCZI-streams /// factory uses. There is a mapping between /// the two strings done in the CZIrwAPI /// constructor. /// \param fileName Filename (or URI) of the file (the - /// interpretation of the string is stream + /// interpretation of the string is stream /// class specific). /// \param subBlockCacheOptions Options for initializing the subblock /// cache. @@ -87,15 +87,21 @@ class CZIreadAPI { /// optimization. In addition, is allows to specify reader options. /// /// \param stream_class_name A string identifying the stream class to - /// be used (note that this string is *not* the same - /// string the libCZI-streams factory uses. There is a mapping between - /// the two strings done in the CZIrwAPI constructor. + /// be used (note that this string is *not* + /// the same string the libCZI-streams + /// factory uses. There is a mapping between + /// the two strings done in the CZIrwAPI + /// constructor. /// \param fileName Filename (or URI) of the file (the - /// interpretation of the string is stream class specific). - /// \param subBlockCacheOptions Options for initializing the subblock cache. - /// \param readerOptions Options controlling the reader operation, such as enabling - /// mask awareness tile-composition. - CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, + /// interpretation of the string is stream + /// class specific). + /// \param subBlockCacheOptions Options for initializing the + /// subblock cache. + /// \param readerOptions Options controlling the reader + /// operation, such as enabling mask + /// aware tile-composition. + CZIreadAPI(const std::string &stream_class_name, + const std::wstring &fileName, const SubBlockCacheOptions &subBlockCacheOptions, const ReaderOptions &readerOptions); From 916153eee8ff9bf6137464e7d04c8a17d3b0830c Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 15:28:42 +0200 Subject: [PATCH 25/36] Improve comments in CZIreadAPI.h for clarity Updated descriptions for subBlockCacheOptions and readerOptions to enhance readability and provide more complete information. --- _pylibCZIrw/src/api/CZIreadAPI.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_pylibCZIrw/src/api/CZIreadAPI.h b/_pylibCZIrw/src/api/CZIreadAPI.h index 490ec8e..980d6f1 100644 --- a/_pylibCZIrw/src/api/CZIreadAPI.h +++ b/_pylibCZIrw/src/api/CZIreadAPI.h @@ -96,10 +96,10 @@ class CZIreadAPI { /// interpretation of the string is stream /// class specific). /// \param subBlockCacheOptions Options for initializing the - /// subblock cache. + /// subblock cache. /// \param readerOptions Options controlling the reader - /// operation, such as enabling mask - /// aware tile-composition. + /// operation, such as enabling mask + /// aware tile-composition. CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, const SubBlockCacheOptions &subBlockCacheOptions, From f5585b79c3b551a727c5b1ccc8124b67ffd916a3 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 15:51:18 +0200 Subject: [PATCH 26/36] linter --- _pylibCZIrw/src/api/CZIreadAPI.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/_pylibCZIrw/src/api/CZIreadAPI.h b/_pylibCZIrw/src/api/CZIreadAPI.h index 980d6f1..c82a4ba 100644 --- a/_pylibCZIrw/src/api/CZIreadAPI.h +++ b/_pylibCZIrw/src/api/CZIreadAPI.h @@ -1,14 +1,15 @@ #pragma once #include "PImage.h" -#include "SubBlockCache.h" #include "ReaderOptions.h" +#include "SubBlockCache.h" #include "inc_libCzi.h" #include #include /// Class used to represent a CZI reader object in pylibCZIrw. -/// It gathers the libCZI features needed for reading in the pylibCZIrw project. +/// It gathers the libCZI features needed for reading in the pylibCZIrw +/// project. /// CZIrwAPI will be exposed to python via pybind11 as a czi class. class CZIreadAPI { @@ -76,7 +77,8 @@ class CZIreadAPI { /// class specific). /// \param subBlockCacheOptions Options for initializing the subblock /// cache. - CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, + CZIreadAPI(const std::string &stream_class_name, + const std::wstring &fileName, const SubBlockCacheOptions &subBlockCacheOptions); /// Constructor which constructs a CZIrwAPI object, allowing to specify a From 467c24bb72a1686833e6a48708089d792b18c401 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 15:52:30 +0200 Subject: [PATCH 27/36] linter --- _pylibCZIrw/src/bindings/CZIrw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_pylibCZIrw/src/bindings/CZIrw.cpp b/_pylibCZIrw/src/bindings/CZIrw.cpp index bfb4c63..f1c7c13 100644 --- a/_pylibCZIrw/src/bindings/CZIrw.cpp +++ b/_pylibCZIrw/src/bindings/CZIrw.cpp @@ -2,8 +2,8 @@ #include "../api/CZIwriteAPI.h" #include "../api/PImage.h" #include "../api/SubBlockCache.h" -#include "../api/ReaderOptions.h" #include "../api/site.h" +#include "../api/ReaderOptions.h" #include "PbHelper.h" #include From 11ccaa728b4a52c52aebcc5048167f812ddd98f4 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 15:58:08 +0200 Subject: [PATCH 28/36] linter --- _pylibCZIrw/src/api/CZIreadAPI.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/_pylibCZIrw/src/api/CZIreadAPI.h b/_pylibCZIrw/src/api/CZIreadAPI.h index c82a4ba..b5345b8 100644 --- a/_pylibCZIrw/src/api/CZIreadAPI.h +++ b/_pylibCZIrw/src/api/CZIreadAPI.h @@ -77,8 +77,7 @@ class CZIreadAPI { /// class specific). /// \param subBlockCacheOptions Options for initializing the subblock /// cache. - CZIreadAPI(const std::string &stream_class_name, - const std::wstring &fileName, + CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, const SubBlockCacheOptions &subBlockCacheOptions); /// Constructor which constructs a CZIrwAPI object, allowing to specify a @@ -102,8 +101,7 @@ class CZIreadAPI { /// \param readerOptions Options controlling the reader /// operation, such as enabling mask /// aware tile-composition. - CZIreadAPI(const std::string &stream_class_name, - const std::wstring &fileName, + CZIreadAPI(const std::string &stream_class_name, const std::wstring &fileName, const SubBlockCacheOptions &subBlockCacheOptions, const ReaderOptions &readerOptions); From d9bc647e7f1901121a7c25718fb5f284c47449cd Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 16:00:36 +0200 Subject: [PATCH 29/36] linter --- _pylibCZIrw/src/bindings/CZIrw.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/_pylibCZIrw/src/bindings/CZIrw.cpp b/_pylibCZIrw/src/bindings/CZIrw.cpp index f1c7c13..437bb45 100644 --- a/_pylibCZIrw/src/bindings/CZIrw.cpp +++ b/_pylibCZIrw/src/bindings/CZIrw.cpp @@ -1,9 +1,9 @@ #include "../api/CZIreadAPI.h" #include "../api/CZIwriteAPI.h" #include "../api/PImage.h" +#include "../api/ReaderOptions.h" #include "../api/SubBlockCache.h" #include "../api/site.h" -#include "../api/ReaderOptions.h" #include "PbHelper.h" #include @@ -38,8 +38,8 @@ PYBIND11_MODULE(_pylibCZIrw, m) { const std::wstring &fileName, const SubBlockCacheOptions &subBlockCacheOptions, const ReaderOptions &readerOptions) { - return new CZIreadAPI(stream_class_name, fileName, - subBlockCacheOptions, readerOptions); + return new CZIreadAPI(stream_class_name, fileName, subBlockCacheOptions, + readerOptions); })) .def("close", &CZIreadAPI::close) .def("GetXmlMetadata", &CZIreadAPI::GetXmlMetadata) @@ -229,8 +229,7 @@ PYBIND11_MODULE(_pylibCZIrw, m) { py::class_(m, "ReaderOptions", py::module_local()) .def(py::init<>()) - .def_readwrite("enableMaskAwareness", - &ReaderOptions::enableMaskAwareness) + .def_readwrite("enableMaskAwareness", &ReaderOptions::enableMaskAwareness) .def_readwrite("enableVisibilityCheckOptimization", &ReaderOptions::enableVisibilityCheckOptimization) .def("Clear", &ReaderOptions::Clear); From dc3f6a84b4f0c2b101ea5f516c0ecef8a4b3e228 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 16:05:40 +0200 Subject: [PATCH 30/36] linter --- _pylibCZIrw/src/bindings/PbHelper.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/_pylibCZIrw/src/bindings/PbHelper.h b/_pylibCZIrw/src/bindings/PbHelper.h index d6dcd18..d5498f1 100644 --- a/_pylibCZIrw/src/bindings/PbHelper.h +++ b/_pylibCZIrw/src/bindings/PbHelper.h @@ -1,11 +1,11 @@ #include "../api/CZIreadAPI.h" #include "include_python.h" +#include #include #include #include #include #include -#include namespace py = pybind11; @@ -48,9 +48,7 @@ class CMemBitmapWrapper : public libCZI::IBitmapData { return bitmapLockInfo; } - virtual void Unlock() { - std::atomic_fetch_sub(&this->lock_count, 1); - } + virtual void Unlock() { std::atomic_fetch_sub(&this->lock_count, 1); } virtual int GetLockCount() const { return std::atomic_load(&this->lock_count); From f16919b05769f7f5836466ef1cfebd3aacf68801 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 16:35:30 +0200 Subject: [PATCH 31/36] fix --- pylibCZIrw/czi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylibCZIrw/czi.py b/pylibCZIrw/czi.py index 67cdf91..1afd82b 100644 --- a/pylibCZIrw/czi.py +++ b/pylibCZIrw/czi.py @@ -193,7 +193,7 @@ def __init__( else: # When reading from disk we only cache compressed subblocks. libczi_cache_options.cacheOnlyCompressed = True - self._czi_reader = _pylibCZIrw.czi_reader(filepath, libczi_cache_options, libczi_reader_options) + self._czi_reader = _pylibCZIrw.czi_reader("", filepath, libczi_cache_options, libczi_reader_options) self._stats = self._czi_reader.GetSubBlockStats() @classmethod From aabd658715a4e508203fa1f7f0dc5a2d473e282d Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 16:43:28 +0200 Subject: [PATCH 32/36] review --- pylibCZIrw/czi.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pylibCZIrw/czi.py b/pylibCZIrw/czi.py index 1afd82b..1df7a19 100644 --- a/pylibCZIrw/czi.py +++ b/pylibCZIrw/czi.py @@ -193,7 +193,10 @@ def __init__( else: # When reading from disk we only cache compressed subblocks. libczi_cache_options.cacheOnlyCompressed = True - self._czi_reader = _pylibCZIrw.czi_reader("", filepath, libczi_cache_options, libczi_reader_options) + # use the "standard reader class name" for local files + self._czi_reader = _pylibCZIrw.czi_reader( + ReaderFileInputTypes.Standard.value, filepath, libczi_cache_options, libczi_reader_options + ) self._stats = self._czi_reader.GetSubBlockStats() @classmethod From 3c2af79dc54a9b5fd3709dac53fd698178f68534 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 19 Sep 2025 16:44:31 +0200 Subject: [PATCH 33/36] review --- API.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/API.md b/API.md index 1ecbbc7..ed8b457 100644 --- a/API.md +++ b/API.md @@ -55,7 +55,7 @@ A `CacheOptions` object allows defining a cache type and upper limits for memory ```python cache_options = CacheOptions( type = CacheType.Standard, - max_memory_usge = 500 * 1024**2 # 500 Megabytes + max_memory_usage = 500 * 1024**2 # 500 Megabytes max_sub_block_count = 100, ) with czi.open_czi(file_path, cache_options=cache_options) as czi: @@ -73,7 +73,7 @@ The `ReaderOptions` can be passed to `open_czi` like in this example: ```python cache_options = CacheOptions( type = CacheType.Standard, - max_memory_usge = 500 * 1024**2 # 500 Megabytes + max_memory_usage = 500 * 1024**2 # 500 Megabytes max_sub_block_count = 100, ) reader_options = ReaderOptions( From 401bde9a0e31b3de0248427bd161aa779062db64 Mon Sep 17 00:00:00 2001 From: Juergen Bohl Date: Fri, 19 Sep 2025 23:08:49 +0200 Subject: [PATCH 34/36] refactor: improve docstrings for ReaderOptions and open_czi function --- pylibCZIrw/czi.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pylibCZIrw/czi.py b/pylibCZIrw/czi.py index 1df7a19..741414f 100644 --- a/pylibCZIrw/czi.py +++ b/pylibCZIrw/czi.py @@ -76,10 +76,11 @@ class ReaderOptions: Configuration options for CZI reader. """ - enable_mask_awareness: bool = False # whether the accessor will use the valid-pixel-mask for the - # tile-composition - enable_visibility_check_optimization: bool = True # whether the accessor will use the - # visibility-check-optimization for the tile-composition + enable_mask_awareness: bool = False + """Whether the accessor will use the valid-pixel-mask for the tile-composition.""" + + enable_visibility_check_optimization: bool = True + """Whether the accessor will use the visibility-check-optimization for the tile-composition.""" @dataclass @@ -1329,6 +1330,12 @@ def open_czi( reader_options: ReaderOptions, optional Additional configuration options for the reader. Note that there is a keyword-only argument boundary before the reader_options argument. + Note: This parameter uses a keyword-only argument separator (*) to prevent + accidental positional argument passing. This design choice ensures that + reader_options must be explicitly named when called, improving code clarity + and preventing errors when the function signature evolves. It also maintains + backward compatibility if new optional parameters are added between + cache_options and reader_options in the future. Returns ---------- From e066478753584310d4fbac5299ff761b75baf6aa Mon Sep 17 00:00:00 2001 From: Juergen Bohl Date: Fri, 19 Sep 2025 23:19:27 +0200 Subject: [PATCH 35/36] fix: remove unnecessary whitespace in ReaderOptions class --- pylibCZIrw/czi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylibCZIrw/czi.py b/pylibCZIrw/czi.py index 741414f..9e784f6 100644 --- a/pylibCZIrw/czi.py +++ b/pylibCZIrw/czi.py @@ -78,7 +78,7 @@ class ReaderOptions: enable_mask_awareness: bool = False """Whether the accessor will use the valid-pixel-mask for the tile-composition.""" - + enable_visibility_check_optimization: bool = True """Whether the accessor will use the visibility-check-optimization for the tile-composition.""" From 461126d0728b2d16e90f60ba73e9ec8213e662a9 Mon Sep 17 00:00:00 2001 From: Juergen Bohl Date: Fri, 19 Sep 2025 23:42:05 +0200 Subject: [PATCH 36/36] fix: correct formatting in open_czi function docstring --- pylibCZIrw/czi.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pylibCZIrw/czi.py b/pylibCZIrw/czi.py index 9e784f6..ee821d5 100644 --- a/pylibCZIrw/czi.py +++ b/pylibCZIrw/czi.py @@ -1330,11 +1330,11 @@ def open_czi( reader_options: ReaderOptions, optional Additional configuration options for the reader. Note that there is a keyword-only argument boundary before the reader_options argument. - Note: This parameter uses a keyword-only argument separator (*) to prevent - accidental positional argument passing. This design choice ensures that - reader_options must be explicitly named when called, improving code clarity - and preventing errors when the function signature evolves. It also maintains - backward compatibility if new optional parameters are added between + Note: This parameter uses a keyword-only argument separator (*) to prevent + accidental positional argument passing. This design choice ensures that + reader_options must be explicitly named when called, improving code clarity + and preventing errors when the function signature evolves. It also maintains + backward compatibility if new optional parameters are added between cache_options and reader_options in the future. Returns