Skip to content

Conversation

@xs254
Copy link

@xs254 xs254 commented Jun 6, 2025

Feature description

This feature enables parallelReadTiff to read slices from a stack with user specified step size by im = parallelReadTiff(filename,[start step end]); in addition to the existing im = parallelReadTiff(filename,[start end]); im = parallelReadTiff(filename);

This feature can be useful for users who want to:

  1. Down-sample big tiff stacks during reading to decrease RAM usage and read time.
  2. Read user specified channel from tiff stacks where adjacent slices are from different channels. Such XYCZ organization of tiff stack is used by ASI's SPIM lightsheet microscope during multichannel stage scanning and may also be encountered elsewhere.

Major commits for the feature:

src/parallelreadtiff.cpp

  • readTiffParallel accepts extra argument sliceStep and loop through dir based on sliceStep.
  • readTiffParallelWrapperHelper accepts zRange of length 3 by interpreting it as [start step end].

mexSrc/parallelreadtiffmex.cpp

  • Now accepts second argument of length 3 by interpreting it as [start step end].
  • Implement out-of-bound check similar to the case of [start end].

mexSrc/tests.m

  • Add a small tutorial to illustrate the usage of parallelReadTiff in three different modes.

Minor commits for practical reason:

CMakeLists.txt

  • include_directories(${CMAKE_BINARY_DIR}/dependencies/zlib-1.2.8) is added to solve the compilation error during cmake with MINGW64 on windows:

expected '=', ',', ';', 'asm' or 'attribute' before 'Z_ARG' 1349 | ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));

mexSrc/compile_parallelReadTiff.m

  • Change paths to relative path for better portability.

Limitation:

  • Read with step is not implemented for ImageJ images.
  • Only tested on Windows. Not on Mac and Linux.

Xingbo Shang and others added 4 commits June 5, 2025 19:59
Correct confusing naming of variable and title in the tutorial
@xs254 xs254 marked this pull request as ready for review June 6, 2025 18:23
@MattHazard MattHazard self-assigned this Jun 7, 2025
@MattHazard
Copy link
Collaborator

Hello,

Thank you for the pull request. I appreciate the extensive write-up of your changes. Overall, this new feature looks great, but I will make some adjustments for improved compatibility with the current version of cpp-tiff.

I will change the input parameter to be [start end step] so it does not affect current function calls. I will also move the sliceStep arg to the end of the function call with a default value of 1 for the same reason. Also, readTiffParallelBak is necessary as some tiff files (very rarely) will fail with the strip reading method, so I would also have to implement this there. I'm fine with there not being support for ImageJ images for now as I can add that later if someone requests it.

I am very busy with other projects at the moment, but I will integrate these changes when I have more time.

Thanks,

Matthew Mueller

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants