Skip to content

3881 using sform/qform code 1 for the writers#3882

Merged
wyli merged 9 commits intoProject-MONAI:devfrom
wyli:adds-qform
Oct 31, 2022
Merged

3881 using sform/qform code 1 for the writers#3882
wyli merged 9 commits intoProject-MONAI:devfrom
wyli:adds-qform

Conversation

@wyli
Copy link
Copy Markdown
Contributor

@wyli wyli commented Mar 2, 2022

Fixes #3881
Follow-up of Project-MONAI/tutorials#481

Description

following https://github.com/InsightSoftwareConsortium/ITK/blob/15aa8d58a01a1279e1fafa2214c82edd80b17e92/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx#L2174-L2176

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

wyli added 2 commits March 2, 2022 11:50
Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>
Copy link
Copy Markdown
Contributor

@Nic-Ma Nic-Ma left a comment

Choose a reason for hiding this comment

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

Hi @thewtex @ericspod ,

I am not familiar with the ITK settings, could you please help double confirm it?

Thanks in advance.

@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Mar 7, 2022

/build

Signed-off-by: Wenqi Li <[email protected]>
@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Mar 7, 2022

(also CC'ing @hjmjohnson in case there are more comments)

@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Mar 7, 2022

/build

1 similar comment
@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Mar 7, 2022

/build

@wyli wyli enabled auto-merge (squash) March 7, 2022 13:02
@ericspod
Copy link
Copy Markdown
Member

ericspod commented Mar 7, 2022

I'm not sure hard-coding these values is the right process, either we should be setting them to whatever is appropriate or inheriting whatever the original values were if present in metadata. ITK hard codes it but that's not necessarily the best thing to do, nor is inconsistent values in the header a problem so long as they are set correctly. Setting both these values to 1 selects transform method 3 (https://www.nitrc.org/docman/view.php/26/204/TheNIfTI, pages 12 and 13). If an input nifti uses another method then the header of the output image will be different but both ITK and our code will do this consistent with one another. If we did hard code the values as such we have to fill in the srow_* values correctly as well as qoffset_* and quatern_* values.

@wyli wyli disabled auto-merge March 7, 2022 13:52
@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Mar 7, 2022

@hjmjohnson
Copy link
Copy Markdown
Contributor

I will need some time to make a more detailed review. I have found that all options are a catch-22 with nifti files.

The qform is lossy with respect to the dicom standard, and often results in numerical precision problems when dealing with physical space. The sform has enough precision to be lossless with respect to the dicom standard, but does not necessarily impose that the representation has orthogonal axis.

To further complicate matters, many external tools have developed different protocols and interpretations of when/how to use each of the storage format.

Even ITK's behavior has evolved over time trying to adapt to the environment. The most recent changes opted to try to be less lossy during data conversion so that physical space can be reliably represented with respect to the original dicom data. This change occurred when nifti binary masks were not reported in the same physical space as the dicom originating space. The problem turned out to be small errors in translation to/from qform representations.

@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Apr 4, 2022

/build

1 similar comment
@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Apr 4, 2022

/build

@dzenanz
Copy link
Copy Markdown
Contributor

dzenanz commented Oct 31, 2022

@hjmjohnson did you take a second look here?

@hjmjohnson
Copy link
Copy Markdown
Contributor

@hjmjohnson did you take a second look here?

Yes. I don't think there is a clear solution from ITK's standpoint. ITK defaults to writing the sform content because it most closely matches the internal ITK storage representation, and it provides the least lossy path from DICOM representations of physical2index space mapping.

@dzenanz
Copy link
Copy Markdown
Contributor

dzenanz commented Oct 31, 2022

So, approve PR?

Copy link
Copy Markdown
Contributor

@hjmjohnson hjmjohnson left a comment

Choose a reason for hiding this comment

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

I think setting the sform and qform codes to 1 is the safest way.

@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Oct 31, 2022

/build

@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Oct 31, 2022

/build

@wyli wyli enabled auto-merge (squash) October 31, 2022 20:44
Signed-off-by: Wenqi Li <[email protected]>
@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Oct 31, 2022

/build

@wyli wyli merged commit e766401 into Project-MONAI:dev Oct 31, 2022
KumoLiu pushed a commit that referenced this pull request Nov 2, 2022
Fixes #3881 
Follow-up of Project-MONAI/tutorials#481

### Description
following
https://github.com/InsightSoftwareConsortium/ITK/blob/15aa8d58a01a1279e1fafa2214c82edd80b17e92/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx#L2174-L2176

### Status
**Ready**

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: KumoLiu <[email protected]>
yiheng-wang-nv pushed a commit to yiheng-wang-nv/MONAI that referenced this pull request Nov 2, 2022
Fixes Project-MONAI#3881 
Follow-up of Project-MONAI/tutorials#481

### Description
following
https://github.com/InsightSoftwareConsortium/ITK/blob/15aa8d58a01a1279e1fafa2214c82edd80b17e92/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx#L2174-L2176

### Status
**Ready**

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: Yiheng Wang <[email protected]>
yiheng-wang-nv pushed a commit to yiheng-wang-nv/MONAI that referenced this pull request Nov 2, 2022
Fixes Project-MONAI#3881 
Follow-up of Project-MONAI/tutorials#481

### Description
following
https://github.com/InsightSoftwareConsortium/ITK/blob/15aa8d58a01a1279e1fafa2214c82edd80b17e92/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx#L2174-L2176

### Status
**Ready**

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: Yiheng Wang <[email protected]>
@wyli wyli deleted the adds-qform branch November 3, 2022 09:23
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.

inconsistent output s/qform code for SaveImage

5 participants