Read other file types for frames #116
-
HI, congrats on the 0.10 version! I have a question about using an extra piece of code to directly read Nikon nd2 files as input for frames. Right now I have to convert all acquisitions to tif files and it is adding a significant overhead both in terms of time, hard drive space and transfer of data between computers. There are nd2 reader in python, like nd2 reader (https://rbnvrw.github.io/nd2reader/) and pims-nd2 (https://github.com/soft-matter/pims_nd2). My question is, how difficult would it be to interface these with DECODE so that it can load frames from nd2 without the tif intermediate? I'm not suggesting to have the function built-in in DECODE (that would be nice though :) but general guidance on if/how this could be done so that I can start clumsily hacking my way through it. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
That should be fairly easy. The only thing decode expects is a torch Tensor of size N x H x W. If you want a memory map, it could be a bit more advanced (i.e. if the whole framestack does not fit into RAM at once). E.g. this is the relevant line for the tiff file: DECODE/decode/utils/frames_io.py Lines 44 to 45 in e93f1ea Without trying a drafty implementation could be from pims import ND2_Reader
def load_nd2(file):
frames = ND2_Reader(file)
return torch.from_numpy(frames[:]) # maybe some datatype conversion necessary |
Beta Was this translation helpful? Give feedback.
-
Hi @Haydnspass, I published the batch fitting notebook able to process nd2 files and an example nd2 sequence (256x256 pixels, 100 frames) here: https://github.com/cleterrier/DECODE_NC |
Beta Was this translation helpful? Give feedback.
-
Hi @cleterrier,
|
Beta Was this translation helpful? Give feedback.
That should be fairly easy. The only thing decode expects is a torch Tensor of size N x H x W. If you want a memory map, it could be a bit more advanced (i.e. if the whole framestack does not fit into RAM at once).
E.g. this is the relevant line for the tiff file:
DECODE/decode/utils/frames_io.py
Lines 44 to 45 in e93f1ea
Without trying a drafty implementation could be