tp.batch does not perform batch correctly (all frames output as 0)
joaomamede opened this issue · 3 comments
python 3.11
trackpy 0.6.2 (I tried now with 0.6.1, problem is still there)
all anaconda packages (conda-forge)
I have a plugin for napari that pulls data from a layer and then tp.batches with all the settings from the GUI:
print("Detected a Time lapse TYX or TZYX image")
img = self.viewer.layers[index_layer].data[self.min_timer.value():self.max_timer.value()]
print(''Image from napari:',img.shape)
#Depending on the version of trackpy if somehow does the batch, but assigns all frame values to 0.
#this is to avoid this problem but it doesn't solve it
if len(img.shape) == 3:
img = np.expand_dims(img, axis=1)
print('Before batch:',img.shape)
self.f = tp.batch(img,self.diameter_input.value(),minmass=self.mass_slider.value(),
engine="numba",
processes=1,
)
If I have a TZYX image, all is good it works as intended.
If I have a TYZ image tp.batch detects all frames as 0 and outputs the Dataframe as such
(I added that np.expand_dims trying to fix it but it did not work.
Detected a Time lapse TYX or TZYX image
Image from napari: (111,1020,1020)
Before batch: (111, 1, 1020, 1020)
trackpy.feature.batch: Frame 0: 26 features
22:50:08 INFO Frame 0: 26 features
trackpy.feature.batch: Frame 0: 15 features
22:50:08 INFO Frame 0: 15 features
trackpy.feature.batch: Frame 0: 14 features
22:50:08 INFO Frame 0: 14 features
trackpy.feature.batch: Frame 0: 11 features
22:50:08 INFO Frame 0: 11 features
trackpy.feature.batch: Frame 0: 13 features
22:50:08 INFO Frame 0: 13 features
trackpy.feature.batch: Frame 0: 13 features
22:50:08 INFO Frame 0: 13 features
trackpy.feature.batch: Frame 0: 13 features
22:50:08 INFO Frame 0: 13 features
trackpy.feature.batch: Frame 0: 11 features
Image from napari: (111,1020,1020)
Before batch: (111, 1, 1020, 1020)
Is the added dimension expected ?
Do you know if the order of your dimensions matches the one expected by trackpy ?
From closer inspection of the code I believe it is using the pims flag .frameno and assigning everything to 0. I will test with different napari plugins. I believe that using napari-bioformats is leading to this.
Is the added dimension expected ? Do you know if the order of your dimensions matches the one expected by trackpy ?
Yes and Yes.
It always assumes frame 0. possibly because of the way batch works trying to get the "frame" number from pims (it only goes from 0 to n if the variable is not there in the class).