InsightSoftwareConsortium / InsightSoftwareConsortium/ITKIOOpenJPH

itkwasm_htj2k.encode() errors: TypeError: object of type 'NoneType' has no len()

Open
#22 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
9
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Running on MacOS (M2) with Python 3.11.2 I am receiving this error:

```
Exception has occurred: TypeError
object of type 'NoneType' has no len()
File "/Users/xxxxx/code/DICOM-HTJ2K-Conv/itk.py", line 15, in
htj2k_bytes = itkwasm_htj2k.encode(
^^^^^^^^^^^^^^^^^^^^^
TypeError: object of type 'NoneType' has no len()
```

when trying to use this simple example:

```
import itkwasm_dicom
import itkwasm_htj2k
from pathlib import Path

original = Path(".") / "original.dcm"

images = itkwasm_dicom.read_image_dicom_file_series([original])

print(f"{type(images)=}")
print(f"{type(images[0])=}")

# Encode to HTJ2K
# Customize parameters as needed
htj2k_bytes = itkwasm_htj2k.encode(
images[0],
decompositions=5, # Default number of decomposition levels
not_reversible=False, # Use lossless compression
quantization_step=1.0, # Quantization step size
progression_order=2, # Default progression order
)
```

Any hints greatly appreciated.

Installed modules in the venv:

```
$ pip freeze
importlib_resources==6.4.5
itk==5.4.0
itk-core==5.4.0
itk-filtering==5.4.0
itk-io==5.4.0
itk-numerics==5.4.0
itk-registration==5.4.0
itk-segmentation==5.4.0
itkwasm==1.0b185
itkwasm-compare-images==5.2.3
itkwasm-compare-images-wasi==5.2.3
itkwasm-dicom==7.2.3
itkwasm-dicom-wasi==7.2.3
itkwasm-htj2k==2.3.1
itkwasm-htj2k-wasi==2.3.1
itkwasm-image-io==1.3.1
itkwasm-image-io-wasi==1.3.1
numpy==2.1.3
opencv-python==4.10.0.84
pillow==11.0.0
platformdirs==4.3.6
pydicom==3.0.1
ruff==0.7.4
SimpleITK==2.4.0
typing_extensions==4.12.2
wasmtime==27.0.2
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.