Skip to content

Issue with some uncompressed TRX files #86

@neurolabusc

Description

@neurolabusc

Even though the scripts in this library create uncompressed files, it seems to have problems with some uncompressed files created y other tools, while being fine with compressed files. Note in this example, it succeeds with the compressed "dpsv_9", but has issues with the uncompressed "dpsv_0". NiiVue handles both, and zipinfo suggests identical contents.

$ python tff_convert_tractogram.py dpsv_9.trx dpsv9.tck

$ python tff_convert_tractogram.py dpsv_0.trx dpsv0.tck
Traceback (most recent call last):
  File "/Users/chris/src/trx-python/scripts/tff_convert_tractogram.py", line 59, in <module>
    main()
    ~~~~^^
  File "/Users/chris/src/trx-python/scripts/tff_convert_tractogram.py", line 53, in main
    convert_tractogram(args.in_tractogram, args.out_tractogram, args.reference,
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                       pos_dtype=args.positions_dtype,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                       offsets_dtype=args.offsets_dtype)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chris/py3/lib/python3.13/site-packages/trx/workflows.py", line 97, in convert_tractogram
    sft = trx.to_sft()
  File "/Users/chris/py3/lib/python3.13/site-packages/trx/trx_file_memmap.py", line 1719, in to_sft
    sft = StatefulTractogram(
        deepcopy(self.streamlines),
    ...<3 lines>...
        data_per_streamline=deepcopy(self.data_per_streamline),
    )
  File "/Users/chris/py3/lib/python3.13/site-packages/dipy/testing/decorators.py", line 201, in wrapper
    return convert_positional_to_keyword(func, args, kwargs)
  File "/Users/chris/py3/lib/python3.13/site-packages/dipy/testing/decorators.py", line 192, in convert_positional_to_keyword
    return func(*args, **kwargs)
  File "/Users/chris/py3/lib/python3.13/site-packages/dipy/io/stateful_tractogram.py", line 117, in __init__
    streamlines = streamlines.copy()
  File "/Users/chris/py3/lib/python3.13/site-packages/nibabel/streamlines/array_sequence.py", line 352, in copy
    seq._data[next_offset : next_offset + length] = chunk
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not broadcast input array from shape (0,3) into shape (192094477,3)

$ zipinfo dpsv_9.trx 
Archive:  dpsv_9.trx
Zip file size: 625723 bytes, number of entries: 5
-rw-r--r--  3.0 unx   383460 bx defN 22-Apr-12 08:44 dpv/z.float32
-rw-r--r--  3.0 unx     1836 bx defN 25-Feb-15 09:29 dps/DataSetID.float32
-rw-r--r--  3.0 unx      195 tx defN 25-Feb-15 09:22 header.json
-rw-r--r--  3.0 unx     3680 bx defN 22-Apr-08 08:47 offsets.uint64
-rw-r--r--  3.0 unx   575190 bx defN 22-Apr-08 08:47 positions.3.float16
5 files, 964361 bytes uncompressed, 624925 bytes compressed:  35.2%

$ zipinfo dpsv_0.trx
Archive:  dpsv_0.trx
Zip file size: 965159 bytes, number of entries: 5
-rw-r--r--  3.0 unx   383460 bx stor 22-Apr-12 08:44 dpv/z.float32
-rw-r--r--  3.0 unx     1836 bx stor 25-Feb-15 09:29 dps/DataSetID.float32
-rw-r--r--  3.0 unx      195 tx stor 25-Feb-15 09:22 header.json
-rw-r--r--  3.0 unx     3680 bx stor 22-Apr-08 08:47 offsets.uint64
-rw-r--r--  3.0 unx   575190 bx stor 22-Apr-08 08:47 positions.3.float16
5 files, 964361 bytes uncompressed, 964361 bytes compressed:  0.0%

TRK.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions