Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for slicing and concatenting? #33

Open
dickinson-lab opened this issue Apr 17, 2020 · 5 comments
Open

Support for slicing and concatenting? #33

dickinson-lab opened this issue Apr 17, 2020 · 5 comments

Comments

@dickinson-lab
Copy link

First of all, many thanks for this extremely useful tool - it's been a game-changer for me when working with multi-gigabyte tiff files in MATLAB.

I was wondering if you'd consider adding functions to slice and concatenate images without loading the entire file. As a trivial example, suppose I have a TIFFStack object with size [600, 1200, 500] and I want to pass just half of it to another function. I would be tempted to do something like
smallTIFFStack = bigTIFFStack(:,1:600,:);
but this loads everything into memory, when what I want is a new TIFFStack object that just references the portion of the image I selected.

It also would be nice to be able to concatenate two TIFFStack objects, for cases when my image acquisition software has split a very long timeseries into multiple files:
`>> size(bigTIFFStack1)
ans = 600 1200 4000

size(bigTIFFStack2)
ans = 600 1200 3745
evenBiggerTIFFStack = cat(3, bigTIFFStack1, bigTIFFStack2;
size(evenBiggerTIFFStack)
ans = 600 1200 7745`

If you don't have time to do this, I'd be willing to work on the coding, but I'd need some help figuring out where to start. I am proficient with MATLAB but don't really know anything about how it deals with memory-mapped files.

@DylanMuir
Copy link
Owner

Hi @dannyhmg, thanks for your comments! So for concatenation there is https://github.com/DylanMuir/TensorStack which should work out of the box for what you want. Slicing is much harder, but I had a vague idea that this was already supported somewhere — give me a moment to look.

I haven’t touched this code for quite a while, though. And supporting tensor referencing so it looks like a MATLAB tensor is really complicated!

@DylanMuir
Copy link
Owner

Ah, I was thinking of the de-interleaving in TIFFSTack. So there's no existing functionality to do this. I would suggest making a small wrapper class that does slicing on a tensor, and just passes the indices through. Maybe take a look at https://github.com/DylanMuir/LazyTensorTransform

@dickinson-lab
Copy link
Author

Hi Dylan, thanks very much for taking the time to reply.

I tested TensorStack and it indeed does exactly what I want - thank you!. I noticed that unlike TIFFStack, it doesn't include a license file. May I use a clone of TensorStack as part of an open-source package I am developing (https://github.com/dannyhmg/SiMPull-Analysis-Software), and if so, would you like to add a license?

Slicing is less urgent since I realized that in lieu of slicing a TIFFStack object and passing the result to a function, I can just pass indices along with the whole object along, and then let my function load the part of the image it needs. I might revisit writing a wrapper class later if passing indices becomes problematic.

@DylanMuir
Copy link
Owner

DylanMuir commented Apr 20, 2020 via email

@dickinson-lab
Copy link
Author

Great - thanks again for your help and for sharing your work.

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

No branches or pull requests

2 participants