Skip to content

Add preprocessing for padding traces - #1706

Merged
samuelgarcia merged 35 commits into
SpikeInterface:mainfrom
h-mayorquin:add_padding_preprocessing
Jun 27, 2023
Merged

samuelgarcia merged 35 commits into
SpikeInterface:mainfrom
h-mayorquin:add_padding_preprocessing

Conversation

@h-mayorquin

@h-mayorquin h-mayorquin commented Jun 7, 2023 •

Copy link
Copy Markdown
Contributor

Adding a preprocessing step that pads traces to the left and to the right.

@h-mayorquin h-mayorquin self-assigned this Jun 7, 2023
@h-mayorquin h-mayorquin added the preprocessing Related to preprocessing module label Jun 7, 2023
@alejoe91 alejoe91 added this to the 0.98.0 milestone Jun 7, 2023
@h-mayorquin
h-mayorquin marked this pull request as ready for review June 7, 2023 14:55

# Extract the traces with partial padding in the left and to the right
number_of_padded_frames_at_start = 2
start_frame = padding_left - number_of_padded_frames_at_start

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if this is negative? (2.g. 0 - 2)?

Suggested change
start_frame = padding_left - number_of_padded_frames_at_start
start_frame = max(padding_left - number_of_padded_frames_at_start, 0)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @alejoe91 . Thanks for checking this, it does not have sense to have number_of_padded_frames_at_start larger than 0 in the case where padding_start is 0 (which was on the parametric test). I changed the test to account for this.

Somehow though, there was a (-1 ) x (-1 ) = 1 situation because the tests passed when I parametrized,

@h-mayorquin

Copy link
Copy Markdown
Contributor Author

I added two more tests:

  1. Retrieve partial padding original traces patial padding at the end.
  2. Retrieve with channels.

Both of them were failing on the previous implementation. The current implementation should be ready.

@h-mayorquin h-mayorquin added the enhancement New feature or request label Jun 9, 2023
@h-mayorquin h-mayorquin changed the title Add preprocessing for padding Add preprocessing for padding traces Jun 9, 2023

if __name__ == "__main__":
test_zero_padding()
test_zero_padding_channel()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the feeling that this tests are really really long for a this small task, no ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are you coming from, @samuelgarcia? It is unusual for people to argue for less testing but the opinion does exist out there.

How are you thinking about this?

I am going to say something obvious but maybe is useful for establishing context and starting the conversation:
I used TTD here and each of those tests uncovered errors on my original implementation that I had to improve to pass. If someone wants to change -for example for optimization process- the function in the future then they will have this safeguard so they can optimize away without being concerned about introducing new bugs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

héhé. I am from France and you know it! :)
Is there ant correlation ? maybe...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to add something here, the torought thesting gave me the confidence for implementing your suggestion here #1706 (comment) without me being concerned that something will broken.

@samuelgarcia

Copy link
Copy Markdown
Member

Hi Ramon. This is cool. I made 2 comments.

@alejoe91

Copy link
Copy Markdown
Member

@h-mayorquin @samuelgarcia this looks good to go for me!

@h-mayorquin

Copy link
Copy Markdown
Contributor Author

It is ready on my side if @samuelgarcia agrees. This will unblock #1602.

@samuelgarcia

Copy link
Copy Markdown
Member

Merci camarades.
SOrry for the delay of merging.

@samuelgarcia
samuelgarcia merged commit 4369b7d into SpikeInterface:main Jun 27, 2023
@h-mayorquin
h-mayorquin deleted the add_padding_preprocessing branch June 27, 2023 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request preprocessing Related to preprocessing module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants