Skip to content

Add a differentiable refine template#106

Merged
jdickerson95 merged 26 commits intojd_movie_refine_templatefrom
jd_differentiable_refine
Jan 29, 2026
Merged

Add a differentiable refine template#106
jdickerson95 merged 26 commits intojd_movie_refine_templatefrom
jd_differentiable_refine

Conversation

@jdickerson95
Copy link
Contributor

Lets us optimize things by using refine template output as the loss.

@jdickerson95
Copy link
Contributor Author

I'm thinking the pydantic_models utils.py is too large and not super descriptive, and might be worth splitting into smaller, more descriptive files.

Comment on lines +392 to +401
device = ref_img_rfft.device
whitening_filter_tensor = wf_config.calculate_whitening_filter(
ref_img_rfft=ref_img_rfft, output_shape=output_shape
)
).to(device)
bandpass_filter_tensor = bf_config.calculate_bandpass_filter(
output_shape=output_shape
)
).to(device)
arbitrary_curve_filter_tensor = ac_config.calculate_arbitrary_curve_filter(
output_shape=output_shape
)
).to(device)
Copy link
Member

Choose a reason for hiding this comment

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

Should update docstring to specify that this method will return a tensor on the same device as the reference image

Copy link
Member

Choose a reason for hiding this comment

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

@jdickerson95 is there anything functionally different in the DifferentiableRefineManager class as compared to RefineTemplateManager? If not, it may make more sense to expose the differentiable refine template backed through another method (e.g. RefineTemplateManager.run_differentiable_refine)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have been considering this as well.
It just needs everything on the GPU instead of any cpu pre-processing.
I think it will work better as a function in the refine manager.

Comment on lines 48 to 51
# Raises
# ------
# ValueError
# If not all the required parameters are passed as additional keyword arguments.
Copy link
Member

Choose a reason for hiding this comment

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

No raise statement in this function, can remove this part of docstring

@jdickerson95
Copy link
Contributor Author

Have made changes in the ctf_aberrations PR #110
That branch is mostly ready, besides some cleaning (and a temporary bodge for issue #102 that will be removed before merging)

@jdickerson95 jdickerson95 merged commit deaa831 into jd_movie_refine_template Jan 29, 2026
4 of 10 checks passed
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