SyneRBI / SIRF

Main repository for the CCP SynerBI software
http://www.ccpsynerbi.ac.uk
Other
58 stars 29 forks source link

Loading an AcquisitionData template with storage scheme memory fails #862

Closed paskino closed 3 years ago

paskino commented 3 years ago

I am not sure this is meant or a bug but running the following fails. In practice it seems that we cannot load the AcquisitionData template in memory.

import  sirf.STIR as pet
from sirf.Utilities import examples_data_path as data_path
import os

pet.AcquisitionData.set_storage_scheme('file')

data = pet.AcquisitionData(os.path.join(data_path('PET'), 'mMR', 'mMR_template_span11_small.hs'))
data = data.get_uniform_copy(0)
print ("file ok")
# INFO: Setting energy window keys as in STIR3.0
# file ok

pet.AcquisitionData.set_storage_scheme('memory')
data = pet.AcquisitionData(os.path.join(data_path('PET'), 'mMR', 'mMR_template_span11_small.hs'))
data = data.get_uniform_copy(0)
print("memory ok")
# INFO: Setting energy window keys as in STIR3.0

# WARNING: read_data: error after reading from stream.

# ERROR: ProjDataFromStream: error reading data

# File: /home/ofn77899/devel/install/python/sirf/STIR.py
# Line: 793
# check_status found the following message sent from the engine:
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
#   File "/home/ofn77899/devel/install/python/sirf/STIR.py", line 793, in __init__
#     check_status(self.handle)
#   File "/home/ofn77899/devel/install/python/sirf/Utilities.py", line 410, in check_status
#     raise error(errorMsg)
# sirf.Utilities.error: ??? "'ProjDataFromStream: error reading data' exception caught at line 314 of /home/ofn77899/devel/buildVM/sources/SIRF/src/xSTIR/cSTIR/cstir.cpp; the reconstruction engine output may provide more information"
KrisThielemans commented 3 years ago

As explained multiple times elsewhere, the provided "templates" contain no data (they are a template only!). Therefore, you cannot load them in memory.

I don't know how to resolve this confusion satisfactorily, but it is strictly not a bug in my opinion (but I might be the only one).

Unrelated to this remark, but certainly related regarding confusion is #716

paskino commented 3 years ago

:D

To me it doesn't make sense that I cannot load a template in memory, it's just metadata. But on the other hand I have no idea of how this is implemented.

I personally don't like that the AcquisitionData class may not have data and still be called AcquisitionData. Swapping pet.AcquisitionData.set_storage_scheme('memory') with data = data.get_uniform_copy(0) does the trick.

KrisThielemans commented 3 years ago

To me it doesn't make sense that I cannot load a template in memory, it's just metadata

agreed, but as we have no AcquisitionDataTemplate class, or AcquisitionDataInfo, this is our work-around.

It would make sense to have that (for STIR, it'd have to contain stir::ExamInfo and stir::ProjDataInfo). I don't know if it's possible for ISMRMRD data.

Do I see a volunteer?

paskino commented 3 years ago

Do you see a volunteer? I don't :D