csa-header 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. csa_header-1.0.0/.gitignore +156 -0
  2. csa_header-1.0.0/CHANGELOG.md +164 -0
  3. csa_header-1.0.0/CODE_OF_CONDUCT.md +36 -0
  4. csa_header-1.0.0/CONTRIBUTING.md +384 -0
  5. csa_header-1.0.0/LICENSE.txt +9 -0
  6. csa_header-1.0.0/PKG-INFO +312 -0
  7. csa_header-1.0.0/README.md +283 -0
  8. csa_header-1.0.0/SECURITY.md +87 -0
  9. csa_header-1.0.0/csa_header/__about__.py +4 -0
  10. csa_header-1.0.0/csa_header/__init__.py +12 -0
  11. csa_header-1.0.0/csa_header/ascii/__init__.py +3 -0
  12. csa_header-1.0.0/csa_header/ascii/ascconv.py +285 -0
  13. csa_header-1.0.0/csa_header/ascii/header.py +82 -0
  14. csa_header-1.0.0/csa_header/ascii/messages.py +9 -0
  15. csa_header-1.0.0/csa_header/exceptions.py +6 -0
  16. csa_header-1.0.0/csa_header/header.py +331 -0
  17. csa_header-1.0.0/csa_header/messages.py +20 -0
  18. csa_header-1.0.0/csa_header/unpacker.py +125 -0
  19. csa_header-1.0.0/csa_header/utils.py +56 -0
  20. csa_header-1.0.0/examples/README.md +213 -0
  21. csa_header-1.0.0/examples/nibabel_integration.py +356 -0
  22. csa_header-1.0.0/pyproject.toml +202 -0
  23. csa_header-1.0.0/tests/__init__.py +3 -0
  24. csa_header-1.0.0/tests/ascii/__init__.py +0 -0
  25. csa_header-1.0.0/tests/ascii/fixtures.py +18 -0
  26. csa_header-1.0.0/tests/ascii/test_ascconv_parsing.py +30 -0
  27. csa_header-1.0.0/tests/ascii/test_ascconv_sample.py +190 -0
  28. csa_header-1.0.0/tests/ascii/test_header.py +51 -0
  29. csa_header-1.0.0/tests/benchmarks/__init__.py +1 -0
  30. csa_header-1.0.0/tests/benchmarks/bench_parsing.py +99 -0
  31. csa_header-1.0.0/tests/files/__init__.py +1 -0
  32. csa_header-1.0.0/tests/files/ascconv_sample.txt +919 -0
  33. csa_header-1.0.0/tests/files/dwi_image_header_info +0 -0
  34. csa_header-1.0.0/tests/files/e11_series_header_info +0 -0
  35. csa_header-1.0.0/tests/files/rsfmri_series_header_info +0 -0
  36. csa_header-1.0.0/tests/fixtures.py +8 -0
  37. csa_header-1.0.0/tests/test_header.py +898 -0
  38. csa_header-1.0.0/tests/test_unpacker.py +634 -0
@@ -0,0 +1,156 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # VSCode settings
156
+ .vscode/
@@ -0,0 +1,164 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Changed
11
+ - **CODE_OF_CONDUCT.md**: Replaced Contributor Covenant v2.1 with a community-focused code of conduct inspired by the NIPY community standards. The new version uses friendlier, less legalistic language while maintaining clear guidelines for respectful collaboration.
12
+
13
+ ## [1.0.0] - 2025-10-28
14
+
15
+ ### 🎉 First Stable Release
16
+
17
+ This is the first production-ready release of `csa_header`. The package has undergone a comprehensive modernization and now provides a robust, well-tested foundation for parsing Siemens CSA headers in medical imaging workflows.
18
+
19
+ ### Added
20
+
21
+ #### Testing
22
+ - **Comprehensive test suite**: 161 tests covering all core functionality
23
+ - **96% test coverage**: All critical parsing code at 100% coverage
24
+ - `header.py`: 25% → 100% (75 new tests)
25
+ - `unpacker.py`: 23% → 100% (63 new tests)
26
+ - `utils.py`: 40% → 100%
27
+ - **Real DICOM data tests**: Integration tests with actual CSA headers
28
+ - **All VR types tested**: IS, DS, FL, FD, SS, US, SL, UL, UN, string types
29
+ - **Error handling tests**: Comprehensive edge case and malformed data testing
30
+
31
+ #### Documentation
32
+ - **CONTRIBUTING.md**: Complete contributor guide with development setup, code style, testing requirements, and PR process
33
+ - **CODE_OF_CONDUCT.md**: Contributor Covenant v2.1 for community standards
34
+ - **GitHub issue templates**: Bug report, feature request, and question templates
35
+ - **Pull request template**: Comprehensive PR checklist for quality assurance
36
+ - **Enhanced README**: Advanced usage examples, NiBabel integration guide, feature highlights
37
+ - **Examples directory**: Complete NiBabel integration examples with runnable scripts
38
+
39
+ #### Community Infrastructure
40
+ - GitHub Actions CI/CD with Python 3.9-3.13 testing
41
+ - Pre-commit hooks with automatic code formatting and linting
42
+ - Codecov integration for coverage tracking
43
+ - Issue and PR templates for structured contributions
44
+
45
+ #### Type Safety
46
+ - **Complete type hints**: All public APIs now have comprehensive type annotations
47
+ - **Modern type syntax**: Uses Python 3.10+ union syntax (`X | Y`)
48
+ - **Zero mypy errors**: Full type checking compliance
49
+
50
+ #### Python Support
51
+ - **Python 3.12 support**: Added to test matrix
52
+ - **Python 3.13 support**: Added to test matrix
53
+ - **Dropped Python 3.7-3.8**: Minimum version is now Python 3.9
54
+
55
+ ### Changed
56
+
57
+ #### Code Quality
58
+ - **Modernized type annotations**: Replaced `Union[X, Y]` with `X | Y`, `Optional[X]` with `X | None`
59
+ - **Improved code organization**: Better separation of concerns in test suite
60
+ - **Enhanced error messages**: More descriptive error reporting
61
+
62
+ #### Tooling
63
+ - **Updated pre-commit hooks**:
64
+ - pre-commit-hooks: v4.4.0 → v6.0.0
65
+ - black: 23.3.0 → 25.9.0 (moved to mirror repo)
66
+ - ruff: v0.0.272 → v0.14.2 (moved to astral-sh org)
67
+ - **Modernized ruff configuration**: Migrated to new `[tool.ruff.lint]` structure
68
+ - **Fixed ruff command syntax**: Updated to `ruff check` from deprecated `ruff`
69
+ - **GitHub Actions updates**: checkout@v4, setup-python@v5, codecov@v4
70
+
71
+ #### Testing Infrastructure
72
+ - **Test organization**: Better structured test classes with clear naming
73
+ - **Fixture improvements**: More efficient test data loading
74
+ - **Coverage reporting**: Enhanced coverage reports with branch coverage
75
+
76
+ ### Removed
77
+ - **Python 3.8 compatibility code**: Removed dead code branches for ast.Constant handling
78
+ - **Python 3.7-3.8 support**: No longer tested or officially supported
79
+ - **Deprecated imports**: Cleaned up unused `Union` and `Optional` imports
80
+
81
+ ### Fixed
82
+ - **Type errors**: Resolved all 7 mypy errors in codebase
83
+ - **AST parsing**: Fixed subscript handling for Python 3.9+
84
+ - **Ruff deprecation warnings**: Updated configuration to eliminate warnings
85
+
86
+ ### Security
87
+ - No known security issues
88
+ - All dependencies up to date
89
+ - Pre-commit hooks include security checks (detect-private-key)
90
+
91
+ ## [0.0.1] - 2023-06-XX
92
+
93
+ ### Initial Beta Release
94
+ - Basic CSA header parsing functionality
95
+ - Support for CSA Type 1 and Type 2 headers
96
+ - ASCCONV protocol parsing
97
+ - Integration with pydicom
98
+ - Initial test coverage (~59%)
99
+
100
+ ---
101
+
102
+ ## Release Notes
103
+
104
+ ### 1.0.0 Migration Guide
105
+
106
+ #### No Breaking Changes
107
+ Version 1.0.0 maintains full backward compatibility with 0.0.1. All existing code will continue to work without modifications.
108
+
109
+ #### Recommended Updates
110
+
111
+ 1. **Update Python version**: Minimum is now Python 3.9
112
+ ```bash
113
+ # Verify your Python version
114
+ python --version # Should be 3.9+
115
+ ```
116
+
117
+ 2. **Update type hints** (if you're using them):
118
+ ```python
119
+ # Old style
120
+ from typing import Union, Optional
121
+ def func(x: Optional[int]) -> Union[str, int]:
122
+ pass
123
+
124
+ # New style (Python 3.10+)
125
+ def func(x: int | None) -> str | int:
126
+ pass
127
+ ```
128
+
129
+ 3. **Leverage new examples**:
130
+ ```bash
131
+ # Check out the NiBabel integration example
132
+ python examples/nibabel_integration.py your_dicom.dcm
133
+ ```
134
+
135
+ ### For Contributors
136
+
137
+ If you're contributing to the project, note the new requirements:
138
+ - **Test coverage**: Maintain 90%+ coverage for new code
139
+ - **Type hints**: All public APIs must have complete type annotations
140
+ - **Commit messages**: Follow Conventional Commits specification
141
+ - **Pre-commit hooks**: Must pass all checks before committing
142
+
143
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for complete guidelines.
144
+
145
+ ### Acknowledgments
146
+
147
+ This release represents a complete modernization of the package. Special thanks to:
148
+ - The NiBabel team for their excellent CSA header documentation
149
+ - The PyDICOM community for DICOM parsing infrastructure
150
+ - All contributors who filed issues and provided feedback
151
+
152
+ ### What's Next (Future Releases)
153
+
154
+ Potential features for future releases:
155
+ - CSA header writing support (currently read-only)
156
+ - Support for additional Siemens private tags
157
+ - Performance optimizations for large batch processing
158
+ - Extended ASCCONV parameter documentation
159
+ - Additional integration examples (MONAI, SimpleITK, dcmstack)
160
+
161
+ ---
162
+
163
+ [1.0.0]: https://github.com/open-dicom/csa_header/compare/v0.0.1...v1.0.0
164
+ [0.0.1]: https://github.com/open-dicom/csa_header/releases/tag/v0.0.1
@@ -0,0 +1,36 @@
1
+ # Code of Conduct
2
+
3
+ ## Community Guidelines
4
+
5
+ This project adheres to community standards inspired by the NIPY code of conduct, which itself draws from the Python community, Apache Foundation, Debian, and Burning Man principles.
6
+
7
+ ## Core Values
8
+
9
+ Community members should embody these qualities:
10
+
11
+ **Open**: Accept all who wish to participate; foster collaboration on data reuse, methods, and best practices.
12
+
13
+ **Collaborative**: Explain work to others, provide constructive criticism, and accept feedback graciously.
14
+
15
+ **Inquisitive**: Encourage questions; those asked should respond helpfully toward shared goals.
16
+
17
+ **Considerate**: Be thoughtful about others' efforts; communicate tactfully in person and online.
18
+
19
+ **Careful in words**: Avoid personal insults, violent threats, discriminatory language, sexual/violent material, private content sharing, excessive profanity, harassment, and advocacy of these behaviors.
20
+
21
+ **Concise**: Write briefly and empathetically; add unique contributions; stay on-topic.
22
+
23
+ **Respectful**: Honor others' positions, skills, commitments, and volunteer efforts; disagree courteously.
24
+
25
+ ## Incident Reporting
26
+
27
+ If communications lack respect or friendliness:
28
+
29
+ 1. Address it directly with the person if comfortable
30
+ 2. Contact the project maintainer for unresolved issues
31
+
32
+ All complaints will be reviewed and handled with discretion and respect for all parties involved.
33
+
34
+ ## Attribution
35
+
36
+ Adapted from the [NIPY Code of Conduct](https://nipy.org/conduct.html), inspired by community standards from the Python Software Foundation, Apache Foundation, Debian, and Burning Man.