PTB-MR / mrpro

MR image reconstruction and processing.
https://ptb-mr.github.io/mrpro/
Apache License 2.0
9 stars 3 forks source link

RFC: Coil Compression #180

Open fzimmermann89 opened 4 months ago

fzimmermann89 commented 4 months ago

I would like to use a simple SVD coil compression.

Questions is how and where to implement it.

Version 1

First I thought for me it might be a function coil_compress(target:Kdata|Idata, basis:KDataIData|None, virutual_coils:int, compressionmatrix=None,separate_dims:tuple[int]=None, return_Compressionmatrix:bool) -> Kdata | tuple[Kdata, tensor]

Explanation: target: that will be compressed if basis is None: Use target to figure out the compression matrix. if IData or KData: use IData.data to figure out the compression matrix virtual_coils: number of virtual coils to compres into.

if compressionmatrix is supplied, use it instead of calculating a new one. return_Compressionmatrix: wether the compression matrix be returned as well for reuse on a different dataset.

not sure about how to specify broadcasting: Like should the same compression be applied for all "other" axis or separate? I consider separate_dims which defaults to the same compression for all other dimensions, but you can give a tuple of dimensions numbers the operations will be looped over. So specifiny sparate_dims=0 would mean: Make a different compression matrix for each 'other'. Or should this be done by first selecting only the part of KData that should be used and looping outside of the function?

Version 2

Even though initially I thought having another operator for the compression matrix might be overkill. But it would allow for writing

coil_compressinion=Compression.from_kdata(k)
compressed=coil_compression(other_k)

so it would a bit cleaner to apply it to different data..

Discussion

Now after writing this, I think I prefer version 2... .... What do you think? Maybe @ckolbPTB @schuenke @JoHa0811 (and of course anybody else who has an opinion on that!)

ckolbPTB commented 4 months ago

I also prefer version 2, because the compression matrix should usually be calculated for a subset of the data (e.g. only for one echo and then applied to all other echos). With the above split that can be easily done by the user, otherwise we would have to put this logic into the coil_compression function.