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

EventDownsampling polarity is set to 1 always #298

Closed
agirbau opened this issue Jan 21, 2025 · 2 comments
Closed

EventDownsampling polarity is set to 1 always #298

agirbau opened this issue Jan 21, 2025 · 2 comments

Comments

@agirbau
Copy link
Contributor

agirbau commented Jan 21, 2025

Hello, thank you for the great work!

I was testing the EventDownsampling module, and it seems it's returning always the same polarity.

To reproduce:

import tonic

nmnist = tonic.datasets.NMNIST("./data", train=False)
events, label = nmnist[0]

transform = tonic.transforms.Compose(
    [
        tonic.transforms.EventDownsampling(sensor_size=nmnist.sensor_size,
                                           target_size=(12, 12),
                                           dt=0.01,
                                           downsampling_method="differentiator",
                                           noise_threshold=0,
                                           differentiator_time_bins=2)
    ]
)

aa = transform(events)
print(events['p'].min())

0
print(aa['p'].min())

1
@agirbau
Copy link
Contributor Author

agirbau commented Jan 22, 2025

I think the problem comes in this bugfix:

bba009c#diff-cb9bbb0e9210b9747c8af2608a06b558a6a35d01dad19e767a2985e6ecf44117R50

- event_hist_pos = (np.maximum(event_histogram, 0)).clip(max=1)
- event_hist_neg = (-np.minimum(event_histogram, 0)).clip(max=1)
+ event_hist_pos = (np.maximum(event_histogram >= noise_threshold, 0)).clip(max=1)
+ event_hist_neg = (-np.minimum(-event_histogram >= noise_threshold, 0)).clip(max=1)

Where by comparing the event histogram to the noise thresh converts it to a boolean, and min(True, 0) is 0, so no negative events.

I'll start a PR to further discuss this.

@agirbau
Copy link
Contributor Author

agirbau commented Jan 22, 2025

Opened a PR #299 as a quick hotfix, but requires further discussion on events sharing spatial and temporal slots.

@agirbau agirbau closed this as completed Jan 22, 2025
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

1 participant