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

Improve performance of create_all_cell_csv #220

Merged
merged 12 commits into from
Jan 30, 2023
Merged

Improve performance of create_all_cell_csv #220

merged 12 commits into from
Jan 30, 2023

Conversation

stegiopast
Copy link

@stegiopast stegiopast commented Jan 27, 2023

Before submitting a pull request (PR), please read the contributing guide.

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?
In the function create_all_cell_csv() of cellfinder/analyse/analyse.py a df.append() call is used in a for loop, which slows down the runtime of the program to a significant extend.
(from hours to seconds)

What does this PR do?
Within the for loop over the points list a temporary matrix is constructed line by line by appending the following values separately (raw_coordinate[0],raw_coordinate[1],raw_coordinate[2],atlas_coordinate[0],atlas_coordinate[1],atlas_coordinate[2],structure,hemisphere). After the loop termination a dataframe is constructed via pd.DataFrame(temp_matrix, columns = list_of_colnames, index = None).

References

Please reference any existing issues/PRs that relate to this PR.

How has this PR been tested?

The code has been tested manually and during several cell detection runs.
So far i did not actively assure that any information is missing. I would be happy if you could assure that.

Is this a breaking change?

Strong improvement in run time

Does this PR require an update to the documentation?

No additional change in the handling of the tool.

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality (unit & integration)
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

analyse.py.zip

@adamltyson adamltyson changed the title Dev Improve performance of create_all_cell_csv Jan 30, 2023
@adamltyson
Copy link
Member

Hey @stegiopast thanks for this. Just FYI I added your changes (from the zip file) to this branch. This looks to speed up this step in cellfinder by about 2x.

This also may address #356

@codecov
Copy link

codecov bot commented Jan 30, 2023

Codecov Report

Base: 19.04% // Head: 18.92% // Decreases project coverage by -0.12% ⚠️

Coverage data is based on head (dbdba65) compared to base (e3b48c0).
Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     brainglobe/cellfinder#220      +/-   ##
==========================================
- Coverage   19.04%   18.92%   -0.12%     
==========================================
  Files          25       25              
  Lines        1486     1495       +9     
==========================================
  Hits          283      283              
- Misses       1203     1212       +9     
Impacted Files Coverage Δ
cellfinder/analyse/analyse.py 0.00% <0.00%> (ø)
cellfinder/extract/extract_cubes.py 0.00% <0.00%> (ø)
setup.py 0.00% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@adamltyson adamltyson merged commit 2dfecda into master Jan 30, 2023
@adamltyson adamltyson deleted the dev branch January 30, 2023 13:22
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

Successfully merging this pull request may close these issues.

2 participants