-
Notifications
You must be signed in to change notification settings - Fork 67
Add consistent parameter docs to the main functions and napari #542
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
Conversation
|
I'm not sure why the codecov check is failing? |
alessandrofelder
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a big fan of the consistency introduced here - thanks a lot @matham
I have followed the changes and think they make sense. I will run a sanity check on local data overnight, but assuming that passes and you respond to my minor comments/suggestions, this is ready to be merged
PS
I'm not sure why the codecov check is failing?
Maybe because we're adding extra lines through formatting etc (and maybe docstrings too?)... too small a change to warrant deeper investigation, I think, especially since patch coverage is 100%
cellfinder/core/detect/detect.py
Outdated
| Maximum size of a cluster in physical units. | ||
| The expected in-plane (xy) soma diameter (microns). | ||
| max_cluster_size : int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| max_cluster_size : int | |
| max_cluster_size : float |
I think, for consistency with typehint at least (don't think it matters)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the sig to int, because it's int everywhere else and it's number of voxels so should be int.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's number of voxels
So that means the docstring should say number of voxels instead of cubic um right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh it is um so I changed it to float everywhere..
cellfinder/core/detect/detect.py
Outdated
| Size of the sigma for the log filter. | ||
| Gaussian filter width (as a fraction of soma diameter) used during | ||
| 2d in-plane filtering. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 2d in-plane filtering. | |
| 2d in-plane Laplacian of Gaussian filtering. |
Nitpicky, but may help explain the variable name
cellfinder/core/detect/detect.py
Outdated
| for all the filters. Tune to maximize memory usage without running | ||
| out. Check your GPU/CPU memory to verify it's not full. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| for all the filters. Tune to maximize memory usage without running | |
| out. Check your GPU/CPU memory to verify it's not full. | |
| for all the filters. For performance-critical applications, tune to maximize memory usage without running | |
| out. Check your GPU/CPU memory to verify it's not full. |
This suggestion to make clear that tuning is not a requirement.
Also, should this default to 1, as suggested by the old docstring (but not the code 😅 )?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added it everywhere. For GPU it does default to 1 in the code!?
cellfinder/core/detect/detect.py
Outdated
| ------- | ||
| List[Cell] | ||
| List of detected cells. | ||
| List of detected potential cells and artifacts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| List of detected potential cells and artifacts. | |
| List of detected cell candidates. |
I think this is the wording we use in the paper and elsewhere.
cellfinder/core/detect/detect.py
Outdated
| split_ball_xy_size: int | ||
| Similar to `ball_xy_size`, except the value to use for the 3d | ||
| filter during cluster splitting. | ||
| split_ball_z_size: int | ||
| Similar to `ball_z_size`, except the value to use for the 3d filter | ||
| during cluster splitting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| split_ball_xy_size: int | |
| Similar to `ball_xy_size`, except the value to use for the 3d | |
| filter during cluster splitting. | |
| split_ball_z_size: int | |
| Similar to `ball_z_size`, except the value to use for the 3d filter | |
| during cluster splitting. | |
| split_ball_xy_size: float | |
| Similar to `ball_xy_size`, except the value (in microns) to use for the 3d | |
| filter during cluster splitting. | |
| split_ball_z_size: float | |
| Similar to `ball_z_size`, except the value (in microns) to use for the 3d filter | |
| during cluster splitting. |
Should now also be floats, as we use them as micron quantities now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed everywhere.
cellfinder/core/main.py
Outdated
| split_ball_xy_size: int | ||
| Similar to `ball_xy_size`, except the value to use for the 3d | ||
| filter during cluster splitting. | ||
| split_ball_z_size: int | ||
| Similar to `ball_z_size`, except the value to use for the 3d filter | ||
| during cluster splitting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make these have float typehints too?
| ball_xy_size : float | ||
| 3d filter's in-plane (xy) filter ball size (microns). | ||
| ball_z_size : float | ||
| 3d filter's axial (z) filter ball size (microns). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make typehints in function signature match these typehints?
cellfinder/napari/detect/detect.py
Outdated
| The expected in-plane (xy) soma diameter (microns) | ||
| log_sigma_size : float | ||
| Gaussian filter width (as a fraction of soma diameter) used during | ||
| 2d in-plane filtering |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 2d in-plane filtering | |
| 2d in-plane Laplacian of Gaussian filtering |
| batch_size=dict(value=cls.defaults()["batch_size"]), | ||
| classification_batch_size=dict( | ||
| value=cls.defaults()["classification_batch_size"], | ||
| label="Batch size", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| label="Batch size", | |
| label="Batch size (classification)", |
Helpful to be explicit?
cellfinder/core/classify/classify.py
Outdated
| max_workers: int | ||
| The number of sub-processes to use for data loading / processing. | ||
| Defaults to 8. | ||
| pin_memory: bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
presumably this will come in a follow up PR shortly? (it's not currently part of the function signature)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many PRs at once... It leaked over :D
|
I think I addressed all of the comments, including in all the other places they would occur. |
alessandrofelder
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @matham - I got delayed in doing my local tests on separate data (sorry!), just as a sanity check, but I am now happy with the code and will merge when I have done the local tests (assuming they go well, which they should)
|
I moved the split parameters added to the main I'm wondering if we should make all of these |
|
Thanks, @matham All looks good to me now. For our future selves, I did some one-off manual regression testing: I confirm that I have run this code on our internal reference whole-brain dataset I also confirm that I was able to run
I've opened #550 so others can chime in, and we don't continue the discussion on a merged PR. |
Description
What is this PR
Why is this PR needed?
Right now we pass the same parameters from napari and to various functions. But these parameters have inconsistent or no docs.
What does this PR do?
setup_filters.voxel_sizes,n_sds_above_mean_threshin napari) was set as ints, but they should be floats.split_parameters in all themainfunctions, but not in napari.split_parameters were in pixels. I changed it so it's also in microns by multiplying by the default voxel size. But the default values for the parameters are unchanged.n_splitting_iterwith same default to themainfunctions. Previously it was hard coded insetup_filters.split_soma_diameterbecause it was redundant withsoma_spread_factorand not used. AFAICT,soma_diameteris only used during 2d filtering, not during 3d filtering. Splitting only uses 3d filtering. The only place during splittingsplit_soma_diameterwould be used is to calculate the volume of a cell to decide whether we need to split it. But, we already havesoma_spread_factorthat multipliessoma_diameternotsplit_soma_diameter.batch_sizeintodetection_batch_sizeandclassification_batch_size. The former defaults to1in napari andNonein main. Which means1forGPUand4forCPU. The latter default is unchanged. E.g. on my machine with very large planes, a batch of just 1 detection planes can fit in the 10GB GPU, but 128+ classification cubes can fit.References
#532 and #464 (comment).
How has this PR been tested?
Locally and with data.
Is this a breaking change?
Only the
batch_sizeparameter name is renamed. Everything else is effectively the same.Does this PR require an update to the documentation?
No.
Checklist: