# ImageRegistrationMethodv4 questions

**URL:** https://discourse.itk.org/t/imageregistrationmethodv4-questions/4117
**Category:** Algorithms
**Created:** [May 11, 2021, 4:46pm UTC](https://discourse.itk.org/t/imageregistrationmethodv4-questions/4117 "2021-05-11T16:46:45Z")
**Posts on this page:** 8
**Page:** 2

<div class="post-metadata">

### Author: ![gcsharp](https://discourse.itk.org/letter_avatar_proxy/v4/letter/g/7bcc69/32.png) [@gcsharp](https://discourse.itk.org/u/gcsharp)
#### Post date: [June 2, 2021, 7:11pm UTC](https://discourse.itk.org/t/imageregistrationmethodv4-questions/4117/21 "2021-06-02T19:11:55Z")

</div>

Thanks!

---

<div class="post-metadata">

### Author: ![gcsharp](https://discourse.itk.org/letter_avatar_proxy/v4/letter/g/7bcc69/32.png) [@gcsharp](https://discourse.itk.org/u/gcsharp)
#### Post date: [June 2, 2021, 7:45pm UTC](https://discourse.itk.org/t/imageregistrationmethodv4-questions/4117/22 "2021-06-02T19:45:36Z")

</div>

Does anyone know what is the desired semantics of calling StartOptimization with doOnlyInitialization = true? Would it be allowed to invoke the initial cost function evaluation in that case?

Edit: Never mind, I figured it out.

---

<div class="post-metadata">

### Author: ![gcsharp](https://discourse.itk.org/letter_avatar_proxy/v4/letter/g/7bcc69/32.png) [@gcsharp](https://discourse.itk.org/u/gcsharp)
#### Post date: [June 3, 2021, 2:58pm UTC](https://discourse.itk.org/t/imageregistrationmethodv4-questions/4117/23 "2021-06-03T14:58:15Z")

</div>

I’m trying to follow the guidelines for creating a PR according to [CONTRIBUTING.md](https://github.com/InsightSoftwareConsortium/ITK/blob/master/CONTRIBUTING.md)

When I try to commit, it is not successful because I get some sort of error due to mergetool.

```
$ git commit -am "WIP: Modify itkGradientDescentOptimizerv4 so AdvanceOneStep() is called prior to GetValueAndDerivative() rather than after; Update tests in ITKOptimizersv4TestDriver to match the algorithmic change"

This message is displayed because 'merge.tool' is not configured.
See 'git mergetool --tool-help' or 'git help config' for more details.
'git mergetool' will now attempt to use one of the following tools:
opendiff kdiff3 tkdiff xxdiff meld tortoisemerge gvimdiff diffuse diffmerge ecmerge p4merge araxis bc codecompare emerge vimdiff
[attr]our-c-style whitespace=tab-in-indent,no-lf-at-eof hooks.style=KWStyle,clangformat
 not allowed: ./.gitattributes:31
[attr]our-c-style whitespace=tab-in-indent,no-lf-at-eof hooks.style=KWStyle,clangformat
 not allowed: ./.gitattributes:31
Utilities/KWStyle/ITKOverwrite.txt
[attr]our-c-style whitespace=tab-in-indent,no-lf-at-eof hooks.style=KWStyle,clangformat
 not allowed: ./.gitattributes:31
[attr]our-c-style whitespace=tab-in-indent,no-lf-at-eof hooks.style=KWStyle,clangformat
 not allowed: ./.gitattributes:31
The 
merge tool bc is not available as 'bcompare'
gcs6@icecream:/home/gcs6/build/src/ITK/Modules/Numerics/Optimizersv4/test$ git status
On branch issue-2570
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified: ../include/itkGradientDescentOptimizerv4.h
	deleted: ../include/itkGradientDescentOptimizerv4.hxx
	modified: ../include/itkQuasiNewtonOptimizerv4.hxx
	modified: ../include/itkRegularStepGradientDescentOptimizerv4.hxx
	modified: itkGradientDescentOptimizerv4Test.cxx
	modified: itkGradientDescentOptimizerv4Test2.cxx
	modified: itkRegularStepGradientDescentOptimizerv4Test.cxx

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	../include/itkGradientDescentOptimizerv4.hxx.20986.hxx.log
	../include/itkGradientDescentOptimizerv4.hxx.BACKUP.20986.hxx
	../include/itkGradientDescentOptimizerv4.hxx.CLANGFORMAT.20986.hxx
	../include/itkGradientDescentOptimizerv4.hxx.NEW.20986.hxx
	../include/itkGradientDescentOptimizerv4.hxx.STAGED.20986.hxx

no changes added to commit (use "git add" and/or "git commit -a")

```

So I clean up the junk and I try to set a mergetool, but still have problems.

```
$ git config --global merge.tool meld
$ git commit -am "WIP: Modify itkGradientDescentOptimizerv4 so AdvanceOneStep() is called prior to GetValueAndDerivative() rather than after; Update tests in ITKOptimizersv4TestDriver to match the algorithmic change"
[attr]our-c-style whitespace=tab-in-indent,no-lf-at-eof hooks.style=KWStyle,clangformat
 not allowed: ./.gitattributes:31
[attr]our-c-style whitespace=tab-in-indent,no-lf-at-eof hooks.style=KWStyle,clangformat
 not allowed: ./.gitattributes:31
Utilities/KWStyle/ITKOverwrite.txt
[attr]our-c-style whitespace=tab-in-indent,no-lf-at-eof hooks.style=KWStyle,clangformat
 not allowed: ./.gitattributes:31
[attr]our-c-style whitespace=tab-in-indent,no-lf-at-eof hooks.style=KWStyle,clangformat
 not allowed: ./.gitattributes:31
Usage: 
  meld Start with an empty window
  meld <file|folder> Start a version control comparison
  meld <file> <file> [<file>] Start a 2- or 3-way file comparison
  meld <folder> <folder> [<folder>] Start a 2- or 3-way folder comparison

Error: Cannot compare a mixture of files and directories

[snip]

```

What am I doing wrong?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [June 3, 2021, 3:15pm UTC](https://discourse.itk.org/t/imageregistrationmethodv4-questions/4117/24 "2021-06-03T15:15:21Z")

</div>

Maybe automatic application of clang-format causes some merge conflicts thus derailing the commit? First apply clang format before committing. If that does not help, try `commit -n -am "..."` to skip commit checks.

---

<div class="post-metadata">

### Author: ![gcsharp](https://discourse.itk.org/letter_avatar_proxy/v4/letter/g/7bcc69/32.png) [@gcsharp](https://discourse.itk.org/u/gcsharp)
#### Post date: [June 3, 2021, 4:08pm UTC](https://discourse.itk.org/t/imageregistrationmethodv4-questions/4117/25 "2021-06-03T16:08:50Z")

</div>

Thanks Dzenan. I did not know that it is necessary to install clang-format. Now it works as expected.

---

<div class="post-metadata">

### Author: ![gcsharp](https://discourse.itk.org/letter_avatar_proxy/v4/letter/g/7bcc69/32.png) [@gcsharp](https://discourse.itk.org/u/gcsharp)
#### Post date: [June 3, 2021, 4:18pm UTC](https://discourse.itk.org/t/imageregistrationmethodv4-questions/4117/26 "2021-06-03T16:18:07Z")

</div>

It looks like the instructions may be missing some steps. There is no mention of forking the repository. But that is what is needed?

```
$ git review-push --force
Pushing to origin
Username for 'https://github.com': gregsharp
Password for 'https://gregsharp@github.com': 
remote: Permission to InsightSoftwareConsortium/ITK.git denied to gregsharp.
fatal: unable to access 'https://github.com/InsightSoftwareConsortium/ITK/': The requested URL returned error: 403
```

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [June 3, 2021, 4:54pm UTC](https://discourse.itk.org/t/imageregistrationmethodv4-questions/4117/27 "2021-06-03T16:54:06Z")

</div>

I guess that [instructions](https://github.com/InsightSoftwareConsortium/ITK/blob/master/CONTRIBUTING.md#setup) imply (but do not explicitly state) that you have forked it on GitHub.

---

<div class="post-metadata">

### Author: ![gcsharp](https://discourse.itk.org/letter_avatar_proxy/v4/letter/g/7bcc69/32.png) [@gcsharp](https://discourse.itk.org/u/gcsharp)
#### Post date: [June 3, 2021, 6:19pm UTC](https://discourse.itk.org/t/imageregistrationmethodv4-questions/4117/28 "2021-06-03T18:19:25Z")

</div>

Pull request uploaded. It is WIP because there are 12 failing tests. Those should wait until after review of the main concept.

> <https://github.com/InsightSoftwareConsortium/ITK/pull/2572>
>
> Issue 2570.
> AdvanceOneStep() is now called prior to GetValueAndDerivative() rat…her than afterward.
> Tests in ITKOptimizersv4TestDriver have been updated to match the algorithmic change.
> 
> \<!-- The text within this markup is a comment, and is intended to provide
> guidelines to open a Pull Request for the ITK repository. This text will not
> be part of the Pull Request. --\>
> 
> 
> \<!-- See the CONTRIBUTING (CONTRIBUTING.md) guide. Specifically:
> 
> Start ITK commit messages with a standard prefix (and a space):
> 
> \* BUG: fix for runtime crash or incorrect result
> \* COMP: compiler error or warning fix
> \* DOC: documentation change
> \* ENH: new functionality
> \* PERF: performance improvement
> \* STYLE: no logic impact (indentation, comments)
> \* WIP: Work In Progress not ready for merge
> 
> Provide a short, meaningful message that describes the change you made.
> 
> When the PR is based on a single commit, the commit message is usually left as
> the PR message.
> 
> A reference to a related issue or pull request (https://help.github.com/articles/basic-writing-and-formatting-syntax/#referencing-issues-and-pull-requests)
> in your repository. You can automatically
> close a related issues using keywords (https://help.github.com/articles/closing-issues-using-keywords/)
> 
> @mentions (https://help.github.com/articles/basic-writing-and-formatting-syntax/#mentioning-people-and-teams)
> of the person or team responsible for reviewing proposed changes. --\>
> 
> \## PR Checklist
> \- \[\] No \[API changes\](https://github.com/InsightSoftwareConsortium/ITK/blob/master/CONTRIBUTING.md#breaking-changes) were made (or the changes have been approved)
> \- \[\] No \[major design changes\](https://github.com/InsightSoftwareConsortium/ITK/blob/master/CONTRIBUTING.md#design-changes) were made (or the changes have been approved)
> \- \[\] Added test (or behavior not changed)
> \- \[\] Updated API documentation (or API not changed)
> \- \[\] Added \[license\](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Utilities/KWStyle/ITKHeader.h) to new files (if any)
> \- \[\] Added Python wrapping to new files (if any) as described in \[ITK Software Guide\](https://itk.org/ItkSoftwareGuide.pdf) Section 9.5
> \- \[\] Added \[ITK examples\](https://github.com/InsightSoftwareConsortium/ITKSphinxExamples) for all new major features (if any)
> 
> Refer to the \[ITK Software Guide\](https://itk.org/ItkSoftwareGuide.pdf) for
> further development details if necessary.

[Previous page](https://discourse.itk.org/t/imageregistrationmethodv4-questions/4117.md?page=1)
