Skip to content
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

Update to 1.0 #56

Merged
merged 94 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 96 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
dd30f13
start revising log/error API
jcupitt Dec 16, 2022
e6f2185
Merge branch 'update-to-v0.2'
jcupitt Apr 20, 2023
ab7fe00
allow for optional FileMetaInformationVersion
jcupitt Apr 24, 2023
a7cfd9c
almost done
jcupitt May 1, 2023
3ad2590
almost done
jcupitt May 3, 2023
4332e45
almost there
jcupitt May 4, 2023
0006001
tests pass again
jcupitt May 4, 2023
bbcb8b3
file_meta reads correctly
jcupitt May 5, 2023
97bc075
parses leica dicoms correctly
jcupitt May 13, 2023
72a5f21
fix some small issues
jcupitt May 15, 2023
2d241c5
fix the parser
jcupitt May 22, 2023
36ed5c2
fix the segv on the test suite
jcupitt May 24, 2023
188d9e1
strip out old parser
jcupitt May 24, 2023
4d9fe01
improve file_meta parsing
jcupitt May 25, 2023
8037b23
read the frame index table
jcupitt May 26, 2023
e184ac4
start revising BOT handler
jcupitt May 26, 2023
f75daf8
make capacity checks a non-fatal warning
jcupitt May 26, 2023
96e50f1
Merge remote-tracking branch 'upstream/main'
jcupitt May 27, 2023
99f9393
Merge branch 'main' into add-parser
jcupitt May 27, 2023
49ee15f
Merge remote-tracking branch 'upstream/main'
jcupitt May 27, 2023
51ebb99
Merge branch 'main' into add-parser
jcupitt May 27, 2023
40a6923
note dcm-dump fix
jcupitt May 29, 2023
ae6f847
delay func seq read to BOT load
jcupitt May 29, 2023
6c7ee7e
revise bot handling
jcupitt Jun 1, 2023
5db2be4
test, docs, bump version
jcupitt Jun 1, 2023
99f28c5
remove error return from DcmIO close
jcupitt Jun 2, 2023
17561be
remove stray size_t
jcupitt Jun 2, 2023
012debf
fix clang build
jcupitt Jun 2, 2023
68464f8
remove another size_t
jcupitt Jun 2, 2023
c275ed5
also stop on REFERENCED_IMAGE_NAVIGATION_SEQUENCE
jcupitt Jun 2, 2023
aee0708
add dcm_filehandle_read_frame_position
jcupitt Jun 4, 2023
343eecc
make TotalPixelMatrixColumns optional
jcupitt Jun 4, 2023
9dfbacf
fix sanity check in BOT read
jcupitt Jun 4, 2023
d2cc5e7
improve handling of localizer in 3dhistech
jcupitt Jun 5, 2023
4828495
only look up tiles in 3d and sparse mode
jcupitt Jun 6, 2023
a8062a4
add dcm_sequence_steal()
jcupitt Jun 6, 2023
07a866b
make DOT test stricter
jcupitt Jun 7, 2023
7559ae4
remove redef of DcmIOMethods
jcupitt Jun 7, 2023
fd77725
revise TODO
jcupitt Jun 8, 2023
e47bcd4
fix foreach dataset and sequence iterators
jcupitt Jun 9, 2023
dfd7254
expose vr class in the public API
jcupitt Jun 9, 2023
9c39605
split NUMERIC class, add element->str
jcupitt Jun 10, 2023
96caf7f
add index to sequence_foreach
jcupitt Jun 10, 2023
3eb3b0f
rename floatingpoint as decimal
jcupitt Jun 11, 2023
cf38a30
fix build with clang
jcupitt Jun 11, 2023
a6c42cb
rename NUMERIC_FLOATINGPOINT as NUMERIC_INTEGER
jcupitt Jun 11, 2023
9541fb6
skip unnecessary read of File Preamble
bgilbert Jun 13, 2023
6dfb2b8
add dcm_filehandle_get_transfer_syntax_uid()
jcupitt Jun 18, 2023
a9b8936
Merge pull request #1 from bgilbert/preamble
jcupitt Jun 19, 2023
644fca4
Merge branch 'main' into add-set-log-level
jcupitt Jun 20, 2023
7aafa70
a set of cleanups
jcupitt Jun 20, 2023
1cc7c00
better CLI option parsing
jcupitt Jun 20, 2023
ec552e8
start a new print system
jcupitt Jun 21, 2023
e7bd087
add filehandle print
jcupitt Jun 22, 2023
c7a455f
stack of index counters
jcupitt Jun 23, 2023
3003042
add stop_tags to metadata read
jcupitt Jun 23, 2023
4970018
revise base offset for native frames
jcupitt Jun 23, 2023
fbba306
revisw byteswapping code
jcupitt Jun 24, 2023
b90805a
start reworking the API to hold more state
jcupitt Jun 25, 2023
5328799
fix clang build
jcupitt Jun 25, 2023
85db2f6
Merge branch 'main' into revise-api
jcupitt Jun 25, 2023
71218da
API revision done
jcupitt Jun 25, 2023
a6c5b3e
polish docs, bump API to 1.0
jcupitt Jun 25, 2023
47d8cd9
TODO all done
jcupitt Jun 25, 2023
e8ace31
revise read_frame
jcupitt Jun 25, 2023
f100c8f
missing file_meta destroy
jcupitt Jun 25, 2023
df5fee4
bump ABI version to 1.x
jcupitt Jun 25, 2023
e0e130f
small doc fixes
jcupitt Jun 26, 2023
5a506b0
fix sphinx build
jcupitt Jun 26, 2023
057c4ec
add dcm_calloc / dcm_free to public API
jcupitt Jun 26, 2023
035ce75
implement dcm_free()
jcupitt Jun 26, 2023
2cead33
better printing of binary values
jcupitt Jun 26, 2023
45a6c0e
print vm as well as length
jcupitt Jun 28, 2023
ac968b8
add link to py binding
jcupitt Jun 28, 2023
b12d43c
update pywsidicom link
jcupitt Jun 28, 2023
f4355f4
make binary values void*
jcupitt Jul 8, 2023
25da0e3
fix UC parsing
jcupitt Jul 9, 2023
0279653
rename klass as vr_class
jcupitt Jul 9, 2023
3a06178
make element_check_integer also check numeric
jcupitt Jul 9, 2023
28fea98
Merge branch 'enh-codespell' of https://github.com/yarikoptic/libdico…
jcupitt Jul 11, 2023
dfd6b07
fix byteswapping
jcupitt Jul 15, 2023
2632133
grammar fix
jcupitt Jul 15, 2023
f51a0c8
revise codespell workflow
jcupitt Jul 16, 2023
8fefded
meson: apply `bin` tag to tools
bgilbert Jul 23, 2023
679ab2a
Fix typos
bgilbert Jul 23, 2023
b0a83a8
Merge pull request #2 from bgilbert/tags
jcupitt Jul 23, 2023
cb97fa9
Update doc/source/usage.rst
jcupitt Jul 28, 2023
414dec5
rename DCM_CLASS_ as DCM_VR_CLASS_
jcupitt Jul 28, 2023
3d44c8a
Merge branch 'main' of github.com:jcupitt/libdicom
jcupitt Jul 28, 2023
38fce1e
renames following review
jcupitt Aug 1, 2023
0b6836a
fix handling of AT
jcupitt Sep 8, 2023
c9d122e
Merge branch 'main' into main
jcupitt Sep 23, 2023
ec925f3
bump min meson version
jcupitt Sep 23, 2023
34d8e96
install ninja for win build
jcupitt Sep 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# http://editorconfig.org

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{cpp,c,h}]
indent_style = space
indent_size = 4

[*.py]
indent_style = space
indent_size = 4
10 changes: 2 additions & 8 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
---
name: Codespell

on:
push:
branches: [main]
pull_request:
branches: [main]
on: [push, pull_request]

permissions:
contents: read
permissions: {}

jobs:
codespell:
Expand Down
35 changes: 30 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Build Status](https://github.com/ImagingDataCommons/libdicom/actions/workflows/run_unit_tests.yml/badge.svg)](https://github.com/ImagingDataCommons/libdicom/actions)
[![Build
Status](https://github.com/ImagingDataCommons/libdicom/actions/workflows/run_unit_tests.yml/badge.svg)](https://github.com/ImagingDataCommons/libdicom/actions)

# libdicom

Expand All @@ -8,19 +9,43 @@ C library and executable tools for reading DICOM files.

### Building from source

```none
```shell
meson setup --buildtype release builddir
meson compile -C builddir
meson install -C builddir
```
See [the installation documentation](https://libdicom.readthedocs.io/en/latest/installation.html) for build dependencies and installation options.
See [the installation
documentation](https://libdicom.readthedocs.io/en/latest/installation.html)
for build dependencies and installation options.

### Printing the metadata of a DICOM file

```none
```shell
dcm-dump data/test_files/sm_image.dcm
```

### Fetching a frame from a file

```shell
dcm-getframe -o tile.raw data/test_files/sm_image.dcm 12
```

### From Python

There's a sample Python binding here:

https://github.com/ImagingDataCommons/pylibdicom

## Documentation

User and developer guides as well as API documentation can be found at [libdicom.readthedocs.io](https://libdicom.readthedocs.io/en/latest/).
User and developer guides as well as API documentation can be found at
[libdicom.readthedocs.io](https://libdicom.readthedocs.io/en/latest/).

# Thanks

Development of this library was supported by [NCI Imaging Data
Commons](https://imaging.datacommons.cancer.gov/), and has been funded in
whole or in part with Federal funds from the National Cancer Institute,
National Institutes of Health, under Task Order No. HHSN26110071 under
Contract No. HHSN261201500003l.

65 changes: 0 additions & 65 deletions TODO

This file was deleted.

2 changes: 1 addition & 1 deletion doc/source/api.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
API documentation
-----------------

.. c:autodoc:: dicom.h
.. c:autodoc:: dicom/dicom.h
7 changes: 5 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import os
import sys
from hawkmoth.util import readthedocs
from hawkmoth.util import compiler
from clang.cindex import Config as clang_config

# -- Project information -----------------------------------------------------
Expand All @@ -22,7 +23,6 @@
copyright = '2021, Markus D. Herrmann'
author = 'Markus D. Herrmann'


# -- General configuration ---------------------------------------------------

primary_domain = 'c'
Expand Down Expand Up @@ -57,8 +57,11 @@

# -- Hawkmoth extension ------------------------------------------------------

cautodoc_root = os.path.abspath('../../include')
hawkmoth_root = os.path.abspath('../../include')
readthedocs.clang_setup()
hawkmoth_clang = compiler.get_include_args()
# we need build to get version.h
hawkmoth_clang.append(f"-I{os.path.abspath('../../build')}")
if sys.platform == 'darwin':
lib_search_dirs = [
'/usr/lib',
Expand Down
81 changes: 61 additions & 20 deletions doc/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Contributing
Coding style
++++++++++++

Source code should be written following the `K&R (Kernighan & Ritchie) style <https://en.wikipedia.org/wiki/Indentation_style#K&R_style>`_ with a few modifications.
Source code should be written following the `K&R (Kernighan & Ritchie)
style <https://en.wikipedia.org/wiki/Indentation_style#K&R_style>`_ with
a few modifications.

* Line length: max 80 characters

Expand All @@ -13,68 +15,107 @@ Source code should be written following the `K&R (Kernighan & Ritchie) style <ht
* Braces:

- Functions: opening brace at next line

- Control statements (mandatory): opening brace at same line

* Spacing:

- 2 lines between function definitions
- 1 line between logical blocks within functions (and between variable declarations and definitions)

- 1 line between logical blocks within functions (and between variable
declarations and definitions)

* Comments:

- Documentation of functions and other symbols: balanced, multi-line ``/** ... */`` comments in `reStructuredText <https://docutils.sourceforge.io/rst.html>`_ format using `field lists <https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#field-lists>`_ ``:param:`` and ``:return:`` to document function parameters and return values, respectively, and ``:c:member:``, ``:c:func:``, ``:c:macro:``, ``:c:struct:``, ``:c:union:``, ``:c:enum:``, ``:c:enumerator:``, ``:c:type:``, ``:c:expr:``, ``:c:var:`` from the `Sphinx C domain <https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#the-c-domain>`_ directive to `cross-reference other C language constructs <https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#cross-referencing-c-constructs>`_ or to insert a C expression as inline code.
- Documentation of functions and other symbols: balanced,
multi-line ``/** ... */`` comments in `reStructuredText
<https://docutils.sourceforge.io/rst.html>`_ format using `field lists
<https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#field-lists>`_
``:param:`` and ``:return:`` to document function parameters and return
values, respectively, and ``:c:member:``, ``:c:func:``, ``:c:macro:``,
``:c:struct:``, ``:c:union:``, ``:c:enum:``, ``:c:enumerator:``,
``:c:type:``, ``:c:expr:``, ``:c:var:`` from the `Sphinx C domain
<https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#the-c-domain>`_
directive to `cross-reference other C language constructs
<https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#cross-referencing-c-constructs>`_
or to insert a C expression as inline code.

- Inline comments in function body: single-line ``//`` C++ style comments

* Naming conventions:

- Data structures (``struct`` or ``enum``) and types are named using upper camel case (e.g., ``DcmDataSet``), while functions are named using all lower case with underscores (e.g., ``dcm_dataset_create()``).
- Data structures (``struct`` or ``enum``) and types are named using
upper camel case (e.g., ``DcmDataSet``), while functions are named using
all lower case with underscores (e.g., ``dcm_dataset_create()``).

- Names of ``external`` functions, data structures, and types that are declared in the ``dicom.h`` header file are prefixed with ``dcm_`` or ``Dcm``. Names of ``static`` functions, types, or data structures declared in ``*.c`` files are never prefixed.
- Names of ``external`` functions, data structures, and types that are
declared in the ``dicom.h`` header file are prefixed with ``dcm_`` or
``Dcm``. Names of ``static`` functions, types, or data structures declared
in ``*.c`` files are never prefixed.


Interface
+++++++++

The library exposes an "object-oriented" application programming interface (API), which provides data structures and functions to store, access, and manipulate the data.
The library exposes an "object-oriented" application programming interface
(API), which provides data structures and functions to store, access,
and manipulate the data.

To facilitate portability, the ``dicom.h`` header file is restricted to

* C99 version of the standard (C89 + Boolean type from ``stdbool.h`` + fixed-width integer types from ``stdint.h``/``inttypes.h``)
* C99 version of the standard (C89 + Boolean type from ``stdbool.h`` +
fixed-width integer types from ``stdint.h``/``inttypes.h``)

* Opaque data types
* Clear, exact-width integer types (``int16_t``, ``int32_t``, ``int64_t``, ``uint16_t``, ``uint32_t``, and ``uint64_t``)

* Clear, exact-width integer types (``int16_t``, ``int32_t``, ``int64_t``,
``uint16_t``, ``uint32_t``, and ``uint64_t``)

* Minimal use of enums


Implementation
++++++++++++++

The ``dicom-data.c`` (Part 5), ``dicom-dict.c`` (Part 6), and ``dicom-file.c`` (Part 10) are implemented based on the C11 version of the standard.
The ``dicom-data.c`` (Part 5), ``dicom-dict.c`` (Part 6), and ``dicom-file.c``
and ``dicom-parse.c`` (Part 10) are implemented based on the C11 version
of the standard.

The Data Set and Sequence data structures are implemented using the battletested `uthash <https://troydhanson.github.io/uthash>`_ headers.
The Data Set and Sequence data structures are implemented using the
battletested `uthash <https://troydhanson.github.io/uthash>`_ headers.


Documentation
+++++++++++++

Documentation is written in `reStructuredText <https://docutils.sourceforge.io/rst.html>`_ format and HTML documents are autogenerated using `Sphinx <https://www.sphinx-doc.org/en/master/>`_.
API documentation is automatically extracted from the comments in the source code in the ``dicom.h`` header file via the `Hawkmoth Sphinx C Autodoc <https://hawkmoth.readthedocs.io/en/latest/index.html>`_ extension, which relies on `Clang <https://libclang.readthedocs.io/en/latest/index.html>`_ to parse C code.
Documentation is written in `reStructuredText
<https://docutils.sourceforge.io/rst.html>`_ format and HTML documents
are autogenerated using `Sphinx <https://www.sphinx-doc.org/en/master/>`_.
API documentation is automatically extracted from the comments in the source
code in the ``dicom.h`` header file via the `Hawkmoth Sphinx C Autodoc
<https://hawkmoth.readthedocs.io/en/latest/index.html>`_ extension, which
relies on `Clang <https://libclang.readthedocs.io/en/latest/index.html>`_
to parse C code.

Documentation files are located under the ``doc/source`` directory of the repository.
To build the documentation, install ``libclang`` development headers and the Python ``venv`` module, then build with ``meson``:
Documentation files are located under the ``doc/source`` directory of the
repository. To build the documentation, install ``libclang`` development
headers and the Python ``venv`` module, then build with ``meson``:

meson compile -C builddir html

The generated documentation files will then be located under the ``builddir/html`` directory.
The ``builddir/html/index.html`` HTML document can be rendered in the web browser.
The generated documentation files will then be located under the
``builddir/html`` directory. The ``builddir/html/index.html`` HTML document
can be rendered in the web browser.


Testing
+++++++

Unit test cases are defined and run using `check <https://github.com/libcheck/check>`_.
Unit test cases are defined and run using `check
<https://github.com/libcheck/check>`_.

Test files are located under ``/tests`` and can be built and run using ``meson``::
Test files are located under ``/tests`` and can be built and run using
``meson``::

meson test -C builddir

Expand All @@ -87,8 +128,8 @@ For example::

valgrind --leak-check=full dcm-dump data/test_files/sm_image.dcm


Unit testing and dynamic analysis can also be performed using the provided `Dockerfile` (located in the root of the repository)::
Unit testing and dynamic analysis can also be performed using the provided
`Dockerfile` (located in the root of the repository)::

docker build -t dcm-testing .
docker run dcm-testing
12 changes: 8 additions & 4 deletions doc/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Installation
Building
++++++++

The library and executables can be built using `Meson <https://mesonbuild.com/>`_:
The library and executables can be built using `Meson
<https://mesonbuild.com/>`_:

.. code:: bash

Expand Down Expand Up @@ -45,15 +46,18 @@ Build for development and debugging:

.. code:: bash

CFLAGS="-DDEBUG" meson setup builddir
meson setup builddir --buildtype debug
meson compile -C builddir


Optional dependencies
+++++++++++++++++++++

This package uses `check <https://libcheck.github.io/check/>`_ for unit testing and `uthash <https://troydhanson.github.io/uthash/>`_ for data structures.
It will automatically download and build both libraries, or can use system copies.
This package uses `check <https://libcheck.github.io/check/>`_ for unit
testing and `uthash <https://troydhanson.github.io/uthash/>`_ for data
structures. It will automatically download and build both libraries,
or can use system copies.

To install system copies:

On Debian-based Linux distributions:
Expand Down
Loading