Open knowblesse opened 7 months ago
Double value in np.arange was not the only problem.
In line 63-64, nframes_all
which I think a variable representing total number of frames, only consider the first two dimension. This works fine with 4D, but when 5D data is provided,
the algorithm must consider number of frames number of planes number of channels
nframes_all = f[key].shape[0] if hdims == 3 else f[key].shape[0] * f[key].shape[1]
I don't know why there is this comment data = (nchan x) (nframes x) nplanes x pixels x pixels
If that comment is right, than...
but the second case of the 4D and the 5D fail because of the line 81
im = f[key][irange, ...]
It would be much safer to check the shape of the data and raise error when the data shape didn't match with ops.npy
.
Same thing applies to line 82-83
I don't understand the logic in line 97 i0 = nchannels * ((j) % nplanes)
as ((j) % nplanes)
is always j
For the 5D, don't we want something like this?
[fr0 ch0 pl0], [fr0 ch0 pl1], [fr0 ch1 pl0],[fr0 ch1 pl1] [fr1 ch0 pl0], ...
In this case, i0 = j
will do the job as it will move one index further for each plane.
Then line 98-99 and line 104-105 should be changed too.
line 87 if type(im[0, 0, 0]) == np.uint16:
would be much direct if im.dtype == np.uint16:
Please correct me if I'm wrong. BTW, it's an awesome package! Thank you for your job!
Thanks @knowblesse for noticing this and trying to fix this issue. We don't use h5 files ourselves, but I think this deinterleaving of irange is necessary for scanbox converted files? I believe these files had data arrays which were/are 3D/4D which needed to be converted to 5D format to put into our binaries (tiffs have this sort of ordering too from Scanimage). But I honestly don't remember who we added this specific 4D/5D fix for.
If possible, ideally the fix would be backwards compatible, e.g. for Fix 1,
nframes_all = np.prod(np.array(f[key].shape[:-2]))
For Fix 2 -- check if the h5 file has the right dimensions -- if so, skip all of the deinterleaving steps and write straight to binary?
I'm not sure if Fix 3 means there is a bug for these sorts of files already anyway?
Hi Dr. Stringer, I'm Ji Hoon, and thank you for your comment! Your feedback is truly an honor! Our lab, led by PI Tristan Geiller at Yale, has recently embarked on building our own data processing pipeline. During this process, we had the pleasure of discovering your remarkable package. After careful consideration, we decided to adopt the H5 format with a 5D array over the TIFF stack option.
I actually fixed the issue, and tested on 3D, 4D (with multiple channels), 4D (with multiple planes), and 5D (both multiple channels and planes). I've submitted a pull request (#1112), and I would greatly appreciate your review.
Thank you!
Describe the issue:
When
suite2p
try to open an h5 file with 5D data structure, it can not iterate through frames with this error.TypeError: Indexing arrays must have integer dtypes
The cause of the error is the fact that arguments ofnp.arange
receivesint / int
whenhdims != 3
.Reproduce the code example:
Error message:
Version information:
0.14.0
Context for the issue:
No response