-
Notifications
You must be signed in to change notification settings - Fork 135
Add support for a custom seqinfo to extract from DICOMs any additional metadata desired for a heuristic #581
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
44124bd
ENH: custom_seqinfo - provide a way for heuristics to extract/add arb…
yarikoptic a699e4d
TMP: just a demonstration on how custom_seqinfo could/should be used
yarikoptic 48f14bf
fixup typing in dicoms.py
yarikoptic 4afc7df
add custom_info to group_dicoms_into_seqinfos call in parser
bpinsard 115b227
fix test, custom_seqinfo has to be hashable
bpinsard a37e276
test data include messed-up dicoms with no affine
bpinsard 803bbaf
add a check for hashable custom_info, link to new doc section
bpinsard 678f816
Typo fix
yarikoptic 0f5846a
Log exception (as error) if we fail to obtain affine in convertall
yarikoptic c640ffe
fix the order of args in the custom_seqinfo doc
yarikoptic 517ffdc
ENH: custom_seqinfo - provide a way for heuristics to extract/add arb…
yarikoptic 2afe136
change tostr -> tobytes for deprecation, add basic test
bpinsard b3193f6
linting/typing
bpinsard 419ed48
fix py3.11 typing import
bpinsard cfdd3d7
run pre-commit magic!
bpinsard 4688912
Create convertall_custom.py as a demonstration for a derived heuristi…
yarikoptic ca48c66
Fix import in the test due to move + use str() since now tostring is …
yarikoptic 41b22d7
Provide types for custom_seqinfo but disable type checking in the tes…
yarikoptic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| """A demo convertall heuristic with custom_seqinfo extracting affine and sample DICOM path | ||
|
|
||
| This heuristic also demonstrates on how to create a "derived" heuristic which would augment | ||
| behavior of an already existing heuristic without complete rewrite. Such approach could be | ||
| useful for heuristic like reproin to overload mapping etc. | ||
| """ | ||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| import nibabel.nicom.dicomwrappers as dw | ||
|
|
||
| from .convertall import * # noqa: F403 | ||
|
|
||
|
|
||
| def custom_seqinfo( | ||
| series_files: list[str], wrapper: dw.Wrapper, **kw: Any # noqa: U100 | ||
| ) -> tuple[str | None, str]: | ||
| """Demo for extracting custom header fields into custom_seqinfo field | ||
|
|
||
| Operates on already loaded DICOM data. | ||
| Origin: https://github.com/nipy/heudiconv/pull/333 | ||
| """ | ||
|
|
||
| from nibabel.nicom.dicomwrappers import WrapperError | ||
|
|
||
| try: | ||
| affine = str(wrapper.affine) | ||
| except WrapperError: | ||
| lgr.exception("Errored out while obtaining/converting affine") # noqa: F405 | ||
| affine = None | ||
| return affine, series_files[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.