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

tp.batch does not perform batch correctly (all frames output as 0) #756

Open
joaomamede opened this issue Mar 4, 2024 · 3 comments
Open

Comments

@joaomamede
Copy link

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
@b-grimaud
Copy link

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 ?

@joaomamede
Copy link
Author

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.

@joaomamede
Copy link
Author

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).

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

No branches or pull requests

2 participants