Skip to content

Commit f6d7a00

Browse files
authored
Merge pull request rordenlab#941 from rordenlab/development
Stable Release v1.0.20250505
2 parents 98ecd0b + 3e05ac0 commit f6d7a00

38 files changed

+3346
-323
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# GitHub syntax highlighting
2+
pixi.lock linguist-language=YAML linguist-generated=true

.github/workflows/codespell.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ jobs:
1414

1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v3
17+
uses: actions/checkout@v4
1818
- name: Codespell
19-
uses: codespell-project/actions-codespell@v1
19+
uses: codespell-project/actions-codespell@v2

.github/workflows/release.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,37 @@
11
name: Release
2-
on: {push: {tags: ['v*.*.*']}}
2+
on: {push: {branches: [development], tags: [v*.*.*]}}
33
jobs:
4+
wheels:
5+
runs-on: ${{ matrix.os }}
6+
strategy:
7+
matrix:
8+
# macos-13 is an intel runner, macos-14 is apple silicon
9+
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-13, macos-14]
10+
steps:
11+
- uses: actions/checkout@v4
12+
with: {fetch-depth: 0, submodules: false}
13+
- uses: pypa/cibuildwheel@2.x
14+
with: {output-dir: dist}
15+
env: {CIBW_ARCHS: auto64, CIBW_SKIP: pp*} # skip 32bit & PyPy
16+
- uses: actions/upload-artifact@v4
17+
with:
18+
name: wheels-${{ matrix.os }}-${{ strategy.job-index }}
19+
path: ./dist/*.whl
420
pypi:
21+
needs: wheels
522
permissions: {id-token: write}
623
runs-on: ubuntu-latest
724
steps:
825
- uses: actions/checkout@v4
926
with: {fetch-depth: 0, submodules: false}
1027
- uses: actions/setup-python@v5
1128
with: {python-version: '3.x'}
29+
- uses: actions/download-artifact@v4
30+
with:
31+
pattern: wheels-*
32+
path: dist
33+
merge-multiple: true
1234
- uses: casperdcl/deploy-pypi@v2
13-
with: {build: -s, upload: true}
35+
with:
36+
build: -s
37+
upload: ${{ startsWith(github.ref, 'refs/tags/v') }}

.gitignore

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,14 @@ __pycache__/
1616

1717
dist
1818
node_modules
19-
dcm2niix.js
20-
dcm2niix.wasm
19+
dcm2niix*.js
20+
dcm2niix*.wasm
21+
22+
# pixi environments
23+
.pixi
24+
*.egg-info
25+
26+
*.tar.gz
27+
openjpeg-2.5.3/
28+
v2.5.3.tar.gz*
29+
niivue-dcm2niix-*.tgz

BIDS/extract_units.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
-o OUT --out=OUT If given, save the output to this filename.
2222
(Overrides the implicit destination of -e.)
2323
"""
24-
from __future__ import print_function
2524
try:
2625
import json_tricks as json
2726
except ImportError:

COMPILE.md

Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,71 @@
11
## About
22

3-
The README.md file describes the typical compilation of the software, using the `make` command to build the software. This document describes advanced methods for compiling and tuning the software.
3+
The [README.md file] describes the typical compilation of the software, using the `cmake` command. This document introduces advanced methods for compiling and tuning the software.
44

5-
Beyond the complexity of compiling the software, the only downside to adding optional modules is that the dcm2niix executable size will require a tiny bit more disk space. For example, on MacOS the stripped basic executable is 238kb, miniz (GZip support) adds 18kb, NanoJPEG (lossy JPEG support) adds 13kb, CharLS (JPEG-LS support) adds 271kb, and OpenJPEG (JPEG2000 support) adds 192kb. So with all these features installed the executable weighs in at 732kb.
5+
The design of dcm2niix is fairly modular. In particular, it can be built to use different libraries to handle the decompression and compression of files. It can even be built without these dependencies, resulting in compact software that will be unable to handle compressed images. Beyond the complexity of compiling the software, the only downside to adding optional modules is that the dcm2niix executable size will require a tiny bit more disk space. For example, miniz (GZip support) adds 18kb, NanoJPEG (lossy JPEG support) adds 13kb, CharLS (JPEG-LS support) adds 271kb, and OpenJPEG (JPEG2000 support) adds 192kb.
66

7-
## Choosing your compiler
7+
The first two sections describe using `make` and `cmake` to build dcm2niix. The subsequent sections provide in depth notes on compiling directly from the command line. Beware that those notes can get outdated as compilers and options evolve. Further, they can make explicit assumptions regarding the location of libraries. You can always run the `make` script to see the current typical compile for your system.
88

9-
The text below generally describes how to build dcm2niix using the [GCC](https://gcc.gnu.org) compiler using the `g++` command. However, the code is portable and you can use different compilers. For [clang/llvm](https://clang.llvm.org) compile using `clang++`. If you have the [Intel C compiler](https://software.intel.com/en-us/c-compilers), you can substitute the `icc` command. The code is compatible with Microsoft's VS 2015 or later. For [Microsoft's C compiler](http://landinghub.visualstudio.com/visual-cpp-build-tools) you would use the `cl` command. In theory, the code should support other compilers, but this has not been tested. Be aware that if you do not have gcc installed the `g++` command may use a default to a compiler (e.g. clang). To check what compiler was used, run the dcm2niix software: it always reports the version and the compiler used for the build.
9+
##### MAKE INSTALLATION
1010

11-
Note that in the commands below we increase the [stack size](https://stackoverflow.com/questions/18909395/how-do-i-increase-the-stack-size-when-compiling-with-clang-on-os-x)zgit to 16mb, which is larger than the Unix (8mb) and Windows (1mb) defaults.
11+
To download and compile dcm2niix with make you can run these commands from the command line (remove `--branch development` to get the current stable release):
12+
13+
```bash
14+
git clone --branch development git@github.com:rordenlab/dcm2niix.git
15+
cd dcm2niix\console
16+
make
17+
```
18+
19+
The make file supports different build configurations.
20+
21+
| command | conifguratio |
22+
| --------------- | ------------------------ |
23+
| make | |
24+
| make debug | unoptimized code |
25+
| make jp2 | JP2000 support |
26+
| make noroi | Ignore [overlays](https://dicom.nema.org/dicom/2013/output/chtml/part03/sect_C.9.html#:~:text=A%20Region%20of%20Interest%20(ROI,the%20image%20of%20particular%20interest.)|
27+
| make sanitize | [memory error detector.](https://clang.llvm.org/docs/AddressSanitizer.html) |
28+
| make wasm | [WebAssembly](https://github.com/rordenlab/dcm2niix/tree/master/js)|.
29+
30+
You can also append prefix(es) to each of these configurations, for example `JPEGLS=1 ZLIB=1 make jp2` will use the system zlib, CharLS and OpenJPEG:
31+
32+
| prefix | features |
33+
| --------------- | ------------------------ |
34+
| JPEGLS=1 | Statically add CharLS library |
35+
| ZLIB=1 | Dynamically link to system zlib instead of static miniz |
36+
| JNIfTI=0 | compile without [jnifti](https://github.com/NeuroJSON/jnifti) support |
37+
##### CMAKE INSTALLATION
1238

13-
## Building the command line version without cmake
39+
`cmake` can automatically aid complex builds. The [home page](https://github.com/rordenlab/dcm2niix) describes typical cmake options.
1440

15-
You can also build the software without C-make. The easiest way to do this is to run the function "make" from the "console" folder. Note that this only creates the default version of dcm2niix, not the optional batch version described above. The make command simply calls the g++ compiler, and if you want you can tune this for your build. In essence, the make function simply calls
41+
To download and compile dcm2niix with cmake you can run these commands from the command line (remove `--branch development` to get the current stable release; remove `-DZLIB_IMPLEMENTATION=Cloudflare` to produce with the miniz compressor, remove `-DUSE_JPEGLS=ON` to build without CharLS and remove `-DUSE_OPENJPEG=ON` to compile without JPEG2000 support):
1642

43+
```bash
44+
git clone --branch development git@github.com:rordenlab/dcm2niix.git
45+
cd dcm2niix
46+
mkdir build && cd build
47+
cmake -DZLIB_IMPLEMENTATION=Cloudflare -DUSE_JPEGLS=ON -DUSE_OPENJPEG=ON ..
48+
make
1749
```
18-
g++ -O3 -I. main_console.cpp nii_dicom.cpp jpg_0XC3.cpp ujpeg.cpp nifti1_io_core.cpp nii_ortho.cpp nii_dicom_batch.cpp nii_foreign.cpp -o dcm2niix -DmyDisableOpenJPEG -Wl,-stack_size -Wl,3f00000
50+
51+
If you get the following error:
52+
53+
```
54+
fatal: unable to connect to github.com:
55+
github.com[0: 140.82.121.4]: errno=Connection timed out
1956
```
2057

21-
The following sub-sections list how you can modify this basic recipe for your needs.
58+
This suggests git is unable to connect using ssh. One solution is to use https instead:
59+
60+
```
61+
git clone --branch development https://github.com/rordenlab/dcm2niix.git
62+
```
63+
64+
## Choosing your compiler
65+
66+
The text below generally describes how to build dcm2niix using the [GCC](https://gcc.gnu.org) compiler using the `g++` command. However, the code is portable and you can use different compilers. For [clang/llvm](https://clang.llvm.org) compile using `clang++`. If you have the [Intel C compiler](https://software.intel.com/en-us/c-compilers), you can substitute the `icc` command. The code is compatible with Microsoft's VS 2015 or later. For [Microsoft's C compiler](http://landinghub.visualstudio.com/visual-cpp-build-tools) you would use the `cl` command. In theory, the code should support other compilers, but this has not been tested. Be aware that if you do not have gcc installed the `g++` command may use a default to a compiler (e.g. clang). To check what compiler was used, run the dcm2niix software: it always reports the version and the compiler used for the build.
67+
68+
Note that in the commands below we increase the [stack size](https://stackoverflow.com/questions/18909395/how-do-i-increase-the-stack-size-when-compiling-with-clang-on-os-x)zgit to 16mb, which is larger than the Unix (8mb) and Windows (1mb) defaults.
2269

2370
## Trouble Shooting
2471

@@ -30,7 +77,7 @@ cmake -DUSE_OPENJPEG=ON -DCMAKE_CXX_FLAGS=-g .. && make
3077
```
3178

3279
##### ZLIB BUILD
33-
If we have zlib, we can use it (-lz) and disable [miniz](https://code.google.com/p/miniz/) (-myDisableMiniZ)
80+
If we have zlib, we can use it (-lz) and disable [miniz](https://code.google.com/p/miniz/) (-DmyDisableMiniZ)
3481

3582
```
3683
g++ -O3 -DmyDisableOpenJPEG -I. main_console.cpp nii_dicom.cpp nifti1_io_core.cpp nii_ortho.cpp nii_dicom_batch.cpp jpg_0XC3.cpp ujpeg.cpp nii_foreign.cpp -o dcm2niix -lz -DmyDisableMiniZ g++ -O3 -I. main_console.cpp nii_dicom.cpp jpg_0XC3.cpp ujpeg.cpp nifti1_io_core.cpp nii_ortho.cpp nii_dicom_batch.cpp nii_foreign.cpp -o dcm2niix -DmyDisableOpenJPEG -Wl,-stack_size -Wl,3f00000
@@ -46,7 +93,7 @@ g++ -O3 -s -DmyDisableOpenJPEG -DmyDisableZLib -I. main_console.cpp nii_dicom.cp
4693

4794
##### DISABLING CLASSIC JPEG
4895

49-
DICOM images can be stored as either raw data or compressed using one of many formats as described by the [transfer syntaxes](https://www.nitrc.org/plugins/mwiki/index.php/dcm2nii:MainPage#Transfer_Syntaxes_and_Compressed_Images). One of the compressed formats is the lossy classic JPEG format (which is separate from and predates the lossy JPEG 2000 format). This software comes with the [NanoJPEG](http://keyj.emphy.de/nanojpeg/) library to handle these images. However, you can use the `myDisableClassicJPEG` compiler switch to remove this dependency. The resulting executable will be smaller but will not be able to convert images stored with this format.
96+
DICOM images can be stored as either raw data or compressed using one of many formats as described by the [transfer syntaxes](https://www.nitrc.org/plugins/mwiki/index.php/dcm2nii:MainPage#Transfer_Syntaxes_and_Compressed_Images). One of the compressed formats is the lossy classic JPEG format (which is separate from and predates the JPEG2000 and JPEG-LS formats). This software comes with the [NanoJPEG](http://keyj.emphy.de/nanojpeg/) library to handle these images. However, you can use the `myDisableClassicJPEG` compiler switch to remove this dependency. The resulting executable will be smaller but will not be able to convert images stored with this format.
5097

5198
```
5299
g++ -O3 -I. main_console.cpp nii_dicom.cpp jpg_0XC3.cpp nifti1_io_core.cpp nii_ortho.cpp nii_dicom_batch.cpp nii_foreign.cpp -o dcm2niix -DmyDisableClassicJPEG -DmyDisableOpenJPEG g++ -O3 -I. main_console.cpp nii_dicom.cpp jpg_0XC3.cpp ujpeg.cpp nifti1_io_core.cpp nii_ortho.cpp nii_dicom_batch.cpp nii_foreign.cpp -o dcm2niix -DmyDisableOpenJPEG -Wl,-stack_size -Wl,3f00000
@@ -131,25 +178,3 @@ lipo -create dcm2niix32 dcm2niix64 -o dcm2niix
131178
file ./dcm2niix
132179
```
133180

134-
##### CMAKE INSTALLATION
135-
136-
While most of this page describes how to use `make` to compile dcm2niix, `cmake` can automatically aid complex builds. The [home page](https://github.com/rordenlab/dcm2niix) describes typical cmake options. The cmake command will attempt to pull additional code from git as needed for zlib, OpenJPEG etc. If you get the following error:
137-
138-
```
139-
fatal: unable to connect to github.com:
140-
github.com[0: 140.82.121.4]: errno=Connection timed out
141-
```
142-
143-
This suggests git is unable to connect using ssh. You have two options, first you can disable the cmake option USE_GIT_PROTOCOL (which is on by default). Alternatively, to use https instead using the following lines prior to running cmake:
144-
145-
```
146-
git config --global url."https://github.com/".insteadOf git@github.com:
147-
git config --global url."https://".insteadOf git://
148-
```
149-
150-
Once the installation is completed, you can revert these changes:
151-
152-
```
153-
git config --global --unset-all url.https://github.com/.insteadof
154-
git config --global --unset-all url.https://.insteadof
155-
```

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ The following tools exploit dcm2niix
207207
- [pydra-dcm2niix](https://github.com/nipype/pydra-dcm2niix) is a contains Pydra task interface for dcm2niix.
208208
- [qsm](https://github.com/CAIsr/qsm) Quantitative Susceptibility Mapping software.
209209
- [QSMxT](https://github.com/QSMxT/QSMxT) is an end-to-end software toolbox for Quantitative Susceptibility Mapping.
210+
- [qunex](https://github.com/ULJ-Yale/qunex) Quantitative Neuroimaging Environment & ToolboX for data organization, preprocessing, and quality assurance neuroimaging modalities.
210211
- [reproin](https://github.com/ReproNim/reproin) is a setup for automatic generation of shareable, version-controlled BIDS datasets from MR scanners.
211212
- [Retina_OCT_dcm2nii](https://github.com/Choupan/Retina_OCT_dcm2nii) converts optical coherence tomography (OCT) data to NIfTI.
212213
- [sci-tran dcm2niix](https://github.com/scitran-apps/dcm2niix) Flywheel Gear (docker).

SuperBuild/External-CLOUDFLARE-ZLIB.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ ExternalProject_Add(zlib
77
BINARY_DIR cloudflare-zlib-build
88
CMAKE_ARGS
99
-Wno-dev
10-
${EXTERNAL_PROJECT_BUILD_TYPE_CMAKE_ARGS}
11-
${OSX_ARCHITECTURES}
10+
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
11+
-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
12+
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
1213
# Compiler settings
1314
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
1415
# Install directories

SuperBuild/External-OPENJPEG.cmake

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(OPENJPEG_TAG v2.1-static) # version v2.1-static
1+
set(OPENJPEG_TAG openjpeg-2.5)
22

33
ExternalProject_Add(openjpeg
44
GIT_REPOSITORY "https://github.com/ningfei/openjpeg.git"
@@ -8,12 +8,14 @@ ExternalProject_Add(openjpeg
88
CMAKE_ARGS
99
-Wno-dev
1010
--no-warn-unused-cli
11-
${EXTERNAL_PROJECT_BUILD_TYPE_CMAKE_ARGS}
12-
${OSX_ARCHITECTURES}
13-
# Compiler settings
11+
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
12+
-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
13+
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
14+
# Compiler settings
1415
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
1516
# Install directories
1617
-DCMAKE_INSTALL_PREFIX:PATH=${DEP_INSTALL_DIR}
1718
)
1819

19-
set(OpenJPEG_DIR ${DEP_INSTALL_DIR}/lib/openjpeg-2.1)
20+
include(GNUInstallDirs)
21+
set(OpenJPEG_DIR ${DEP_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/cmake/${OPENJPEG_TAG})

SuperBuild/External-YAML-CPP.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ ExternalProject_Add(yaml-cpp
88
CMAKE_ARGS
99
-Wno-dev
1010
--no-warn-unused-cli
11-
${EXTERNAL_PROJECT_BUILD_TYPE_CMAKE_ARGS}
12-
${OSX_ARCHITECTURES}
13-
# Compiler settings
11+
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
12+
-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
13+
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
14+
# Compiler settings
1415
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
1516
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
1617
# Install directories

0 commit comments

Comments
 (0)