ENH: Print a warning for each unused parameter of the ParameterMap#1431
Conversation
|
Nice!
From: Niels Dekker ***@***.***>
Sent: Friday, April 17, 2026 2:31 PM
To: SuperElastix/elastix ***@***.***>
Cc: Stefan Klein ***@***.***>; Mention ***@***.***>
Subject: [SuperElastix/elastix] ENH: Print a warning for each unused parameter of the ParameterMap (PR #1431)
Waarschuwing: Deze e-mail is afkomstig van buiten de organisatie. Klik niet op links en open geen bijlagen, tenzij u de afzender herkent en weet dat de inhoud veilig is.
Caution: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
Checks that all parameters in the ParameterMap are accessed.
…________________________________
Example output:
WARNING: 5 unused parameter(s) found!
Unused parameter: AutomaticScalesEstimation
Unused parameter: AutomaticTransformInitialization
Unused parameter: AutomaticTransformInitializationMethod
Unused parameter: Blablabla
Unused parameter: ErodeMask
@mstaring<https://github.com/mstaring> @stefanklein<https://github.com/stefanklein> This should ease finding mistakes in parameter maps that are edited by the user.
________________________________
You can view, comment on, or merge this pull request online at:
#1431<https://github.com/SuperElastix/elastix/pull/1431?email_source=notifications&email_token=AAF2LNIT23FZYS225ARZONT4WIPZ3A5CNFSNUABEM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF4ZTKNBVGIZTQNZZGOTHEZLBONXW5J3NMVXHI2LPN2SWK5TFNZ2K24DSL5XXAZLOL5RWY2LDNM>
Commit Summary
* c8512ea<c8512ea?email_source=notifications&email_token=AAF2LNIVLP6UYKXEGTIY7VD4WIPZ3A5CNFSNUABEM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF4ZTKNBVGIZTQNZZGOTHEZLBONXW5J3NMVXHI2LPN2SWK5TFNZ2K64DSL5RW63LNNF2F6Y3MNFRWW> ENH: Print a warning for each unused parameter of the ParameterMap
File Changes
(2 files<https://github.com/SuperElastix/elastix/pull/1431/files?email_source=notifications&email_token=AAF2LNJJ6LDDI5MXI6TOBJD4WIPZ3A5CNFSNUABEM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF4ZTKNBVGIZTQNZZGOTHEZLBONXW5J3NMVXHI2LPN2SWK5TFNZ2K44DSL5TGS3DFONPWG3DJMNVQ>)
* M Core/Configuration/elxConfiguration.cxx<https://github.com/SuperElastix/elastix/pull/1431/files?email_source=notifications&email_token=AAF2LNMCPUEHIFQZACER3HL4WIPZ3A5CNFSNUABEM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF4ZTKNBVGIZTQNZZGOTHEZLBONXW5J3NMVXHI2LPN2SWK5TFNZ2K24DSL5TGS3DFL5RWY2LDNM#diff-8c717fcae83f91a8ccfdf7d9dba3cfb96947c8bc667c0c238222ac3b25576481> (69)
* M Core/Configuration/elxConfiguration.h<https://github.com/SuperElastix/elastix/pull/1431/files?email_source=notifications&email_token=AAF2LNMCPUEHIFQZACER3HL4WIPZ3A5CNFSNUABEM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF4ZTKNBVGIZTQNZZGOTHEZLBONXW5J3NMVXHI2LPN2SWK5TFNZ2K24DSL5TGS3DFL5RWY2LDNM#diff-6660886c32421fd84fee03003eb51cdd2592b8932b9f44b9b9ba9078ec04971e> (20)
Patch Links:
* #1431.patch<https://github.com/SuperElastix/elastix/pull/1431.patch?email_source=notifications&email_token=AAF2LNOM6RST4MO6PNAWEWD4WIPZ3A5CNFSNUABEM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF4ZTKNBVGIZTQNZZGOTHEZLBONXW5J3NMVXHI2LPN2SWK5TFNZ2K44DSL5YGC5DDNBPWG3DJMNVQ>
* #1431.diff<https://github.com/SuperElastix/elastix/pull/1431.diff?email_source=notifications&email_token=AAF2LNJ75NHXYSIII5TIYCT4WIPZ3A5CNFSNUABEM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF4ZTKNBVGIZTQNZZGOTHEZLBONXW5J3NMVXHI2LPN2SWK5TFNZ2K24DSL5SGSZTGL5RWY2LDNM>
-
Reply to this email directly, view it on GitHub<#1431?email_source=notifications&email_token=AAF2LNJ7JCCKGG4RP267DKL4WIPZ3A5CNFSNUABEM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF4ZTKNBVGIZTQNZZGOTHEZLBONXW5J3NMVXHI2LPN2SWK5TFNZ2KYZTPN52GK4S7MNWGSY3L>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAF2LNN7574FWR3TMHHGSK34WIPZ3AVCNFSM6AAAAACX45TKQWVHI2DSMVQWIX3LMV43ASLTON2WKOZUGI4DENRQGUZDKNQ>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
| for (const auto & pair : m_ParameterMapInterface->GetParameterMap()) | ||
| { | ||
| if (pair.first == parameterName) | ||
| { | ||
| // Conceptually, m_ParameterAccessFlags[i] is mutable. | ||
| m_ParameterAccessFlags[i] = true; | ||
| return; | ||
| } | ||
| ++i; | ||
| } |
There was a problem hiding this comment.
Technically, this is O(n), rather than O(1), but I don't think it's worth optimizing the performance of AccessParameter(parameterName). It should not be called inside a performance critical loop anyway.
| const itk::ParameterMapInterface::Pointer m_ParameterMapInterface{ itk::ParameterMapInterface::New() }; | ||
|
|
||
| // Tells for each parameter whether it is accessed. | ||
| std::unique_ptr<std::atomic_bool[]> m_ParameterAccessFlags; |
There was a problem hiding this comment.
Using std::atomic_bool instead of ordinary bool, because I guess these flags might be set concurrently by multiple threads.
There was a problem hiding this comment.
Honestly I wonder if ParameterMap access really ever takes place concurrently (by multiple threads simultaneously). Otherwise the use of atomic_bool may be a bit overdone 🤷
There was a problem hiding this comment.
Update: Replaced atomic_bool with plain bool, as I think that's good enough.
c8512ea to
0df6c6c
Compare
Checks that all parameters in the ParameterMap are accessed.
0df6c6c to
906c90c
Compare
|
For the record, this proposal was discussed in the most recent internal bi-weekly elastix and ITKElastix Zoom meetings. |
Included elastix pull requests: SuperElastix/elastix#1444 "Improve performance of Advanced, ParzenWindowHistogram, ParzenWindowMutualInformation ImageToImageMetric" SuperElastix/elastix#1440 "PERF: Use ImageBufferRange in AfterThreadedComputePDFs" SuperElastix/elastix#1431 "ENH: Print a warning for each unused parameter of the ParameterMap" All included new commits: SuperElastix/elastix@5.3.1...77c726a
Included elastix pull requests: SuperElastix/elastix#1444 "Improve performance of Advanced, ParzenWindowHistogram, ParzenWindowMutualInformation ImageToImageMetric" SuperElastix/elastix#1440 "PERF: Use ImageBufferRange in AfterThreadedComputePDFs" SuperElastix/elastix#1431 "ENH: Print a warning for each unused parameter of the ParameterMap" All included new commits: SuperElastix/elastix@5.3.1...77c726a
Checks that all parameters in the ParameterMap are accessed.
Example output:
@mstaring @stefanklein This should ease finding mistakes in parameter maps that are edited by the user.