Slicer / Slicer

Multi-platform, free open source software for visualization and image computing.
https://www.slicer.org
Other
1.65k stars 544 forks source link

Support IO of sequences of vector images #7185

Open cpinter opened 1 year ago

cpinter commented 1 year ago

Currently there is no way to save/load sequences of vector images, because the vtkMRMLVolumeSequenceStorageNode class does not support images with more than one scalar components.

Describe the solution you'd like

Add support in said class to save/load vector image sequences.

Describe alternatives you've considered

We could improve the vtkTeemNRRDReader/vtkTeemNRRDWriter classes, or start using the vtkITKArchetypeImageSeriesReader/vtkITKImageWriter classes in vtkMRMLVolumeSequenceStorageNode instead.

cpinter commented 1 year ago

I will work on this.

@lassoan Please feel free to add/change anything in the above description.

cpinter commented 1 year ago

For the record: https://discourse.itk.org/t/reading-and-writing-of-5d-images-a-dimension-disappears/6210

cpinter commented 9 months ago

@mattjolley 5D image sequence export finally works for my test data! (The test case is: 5 RGBA images of 320x320x1)

This is the header of the output NRRD:

# Complete NRRD file format specification at:
# http://teem.sourceforge.net/nrrd/format.html
type: unsigned char
dimension: 5
space dimension: 4
sizes: 4 320 320 1 5
space directions: none (1,0,0,0) (0,1,0,0) (0,0,1,0) (0,0,0,1.0185579796238055e-313)
kinds: vector domain domain domain domain
encoding: gzip
space origin: (0,0,0,1)

When loading back in Slicer as Volume (and not as Sequence, as that direction is not yet implemented), the first image appears correctly, which is what is expected.

For the record, this is the experimental topic branch: https://github.com/cpinter/Slicer/tree/volume-sequence-io-5D

cpinter commented 4 months ago

Working on the reader class, and I have some questions to @lassoan about how to continue.

The current state is that I have the vtkITKImageSequenceReader class, which now can split the test sequence file into frames (time point volumes) if used directly. Now I want to make it a proper VTK algorithm, and also to support all the scalar types and component types. But first things first, the VTK pipeline. What is new to me is that here we have N output ports, and we don't know how many until we run the filter.

Thank you!

Also, leaving this topic here for the record: https://discourse.itk.org/t/using-splitcomponentsimagefilter-to-split-by-dimension/6603

cpinter commented 4 months ago

This week I finished the implementation of the 5D IO in a way that our basic use case should now work. There is a crash the source of which I don't know. I asked @lassoan about it. I'll continue there next week.

cpinter commented 4 months ago

Reading the first test sequence file happened without a crash!

There are still many details to finalize, but at least the circle is now closed with:

cpinter commented 4 months ago

One of the things to fix is that the writer assigns a 0 voxel spacing in the sequence frames dimension, which the reader cannot handle. See these two headers (on the right is a header that loads successfully, on the left is the header after saving the data Slicer loads from the right one):

image

Also, the component voxel type was changed from RGBA to vector, but the scalar types and vector types part needs to be revised anyway.

cpinter commented 1 month ago

Update to @mattjolley considering he can't attend today's meeting:

We agreed with @lassoan yesterday that

I'll do this as priorities allow.