Skip to content

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

@joaomamede

Description

@joaomamede

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions