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

Patch2Self error #827

Open
araikes opened this issue Oct 14, 2024 · 4 comments
Open

Patch2Self error #827

araikes opened this issue Oct 14, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@araikes
Copy link
Contributor

araikes commented Oct 14, 2024

Using v 0.22.1, I went to use patch2self as the denoising method (which I've done for every QSIPrep version since 0.11) and got this:

Traceback (most recent call last):
  File "/opt/conda/envs/qsiprep/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/opt/conda/envs/qsiprep/lib/python3.10/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/conda/envs/qsiprep/lib/python3.10/site-packages/qsiprep/cli/workflow.py", line 160, in build_workflow
    retval["workflow"] = workflow_builder()
  File "/opt/conda/envs/qsiprep/lib/python3.10/site-packages/qsiprep/workflows/base.py", line 82, in init_qsiprep_wf
    single_subject_wf = init_single_subject_wf(subject_id)
  File "/opt/conda/envs/qsiprep/lib/python3.10/site-packages/qsiprep/workflows/base.py", line 352, in init_single_subject_wf
    dwi_preproc_wf = init_dwi_preproc_wf(
  File "/opt/conda/envs/qsiprep/lib/python3.10/site-packages/qsiprep/workflows/dwi/base.py", line 246, in init_dwi_preproc_wf
    pre_hmc_wf = init_dwi_pre_hmc_wf(
  File "/opt/conda/envs/qsiprep/lib/python3.10/site-packages/qsiprep/workflows/dwi/pre_hmc.py", line 238, in init_dwi_pre_hmc_wf
    merge_dwis = init_merge_and_denoise_wf(
  File "/opt/conda/envs/qsiprep/lib/python3.10/site-packages/qsiprep/workflows/dwi/merge.py", line 191, in init_merge_and_denoise_wf
    init_dwi_denoising_wf(
  File "/opt/conda/envs/qsiprep/lib/python3.10/site-packages/qsiprep/workflows/dwi/merge.py", line 498, in init_dwi_denoising_wf
    Patch2Self(patch_radius=dwi_denoise_window),
UnboundLocalError: local variable 'dwi_denoise_window' referenced before assignment

Looks like the issue is here, where dwi_denoise_window gets defined when config.workflow.dwi_denoise_window == "auto") for dwidenoisebut not forpatch2self`. Based on :

if (
config.workflow.denoise_method == "dwidenoise"
) and config.workflow.dwi_denoise_window == "auto":
dwi_denoise_window = 5
config.loggers.workflow.info("Automatically using 5, 5, 5 window for dwidenoise")

May need to either define dwi_denoise_window for the patch2self or pass config.workflow.dwi_denoise_window to the `Patch2Self`` node on L499

@araikes araikes added the bug Something isn't working label Oct 14, 2024
@araikes
Copy link
Contributor Author

araikes commented Oct 24, 2024

@mattcieslak,

I can probably get this fixed if you let me know what the preferred approach for setting the window to go patch2self is.

@mattcieslak
Copy link
Collaborator

@ShreyasFadnavis Do you have an algorithm for picking a window size for patch2self?

@ShreyasFadnavis
Copy link
Contributor

Hi @mattcieslak - yes! I do have it in my new paper: https://openaccess.thecvf.com/content/CVPR2024/papers/Fadnavis_Patch2Self2_Self-supervised_Denoising_on_Coresets_via_Matrix_Sketching_CVPR_2024_paper.pdf

The new version of P2S will be available in DIPY soon, but till then a patch size of 0 should be good for all human brain data. If it's non-human brain data, going to a patch of [1, 1, 1] or higher is recommended. I'd just default to 0 in general.

@araikes
Copy link
Contributor Author

araikes commented Oct 24, 2024

May be worth it then to just hard-code that for now and restrict the dwi_denoise_window parameter for use only with dwidenoise (to avoid people incidentally setting the window to 5 and getting rather poor patch2self results).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants