tee-ar-ex / trx-python

Python implementation of the TRX file format
https://tee-ar-ex.github.io/trx-python/
BSD 2-Clause "Simplified" License
20 stars 16 forks source link

Allow other types into `append` #39

Open arokem opened 1 year ago

arokem commented 1 year ago

Right now, append only takes a TRX as input:

https://github.com/tee-ar-ex/trx-python/blob/d2e5d9f300ef16f3ded5e8b7e29bfc8e1841d30b/trx/trx_file_memmap.py#L1239

For practical purposes, it would be useful to be allowed to append SFT and other types (ArraySequence, LazyTractogram) into an existing TRX.

arokem commented 1 year ago

For now, the pattern is:

  1. Initialize an empty TRX (optionally preallocate, if you know how large this will be)
  2. Create a LazyTractogram out of a batch of streamlines.
  3. Create a small TRX out of that.
  4. Append to the empty TRX you created in step 0
  5. Delete the LazyTractogram.
  6. Repeat steps 1-4 until done.
  7. Optional: Resize if you preallocated (a lot more efficient if this thing is going to be big enough).

But this should eventually be superseded by resolving this issue.