[CCPPETMR/Hackathon-SIRF] Unify data containers: CIL <=> SIRF (#5)

0 pagtingin
Lumaktaw sa unang mensaheng hindi pa nababasa

Matthias J. Ehrhardt

hindi pa nababasa,
Hul 26, 2018, 11:44:50 AM7/26/18
para kayCCPPETMR/Hackathon-SIRF, Subscribed


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Matthias J. Ehrhardt

hindi pa nababasa,
Okt 16, 2018, 12:43:57 PM10/16/18
para kayCCPPETMR/Hackathon-SIRF, Subscribed

I encountered a new issue with the CIL-SIRF compatibility. The following example

import os
import shutil
import pSTIR as pet

os.chdir(pet.petmr_data_path('pet'))
shutil.rmtree('working_folder/thorax_single_slice',True)
shutil.copytree('thorax_single_slice','working_folder/thorax_single_slice')
os.chdir('working_folder/thorax_single_slice')

image = pet.ImageData('emission.hv');
image_array=image.as_array()*.05
image.fill(image_array);

from ccpi.optimisation.funcs import IndicatorBox
g = IndicatorBox(lower=0, upper=1)               
        
image_new = g.prox(image, 1)

results in

Traceback (most recent call last):

  File "<ipython-input-2-2381c0694166>", line 4, in <module>
    image_new = g.prox(image, 1)

  File "/home/sirfuser/devel/install/python/ccpi/optimisation/funcs.py", line 247, in prox
    return  (x.maximum(self.lower)).minimum(self.upper)

AttributeError: 'ImageData' object has no attribute 'maximum'

Edoardo Pasca

hindi pa nababasa,
Okt 17, 2018, 5:28:13 PM10/17/18
para kayCCPPETMR/Hackathon-SIRF, Subscribed

Is the method maximum relevant? Should it be a method of DataContainer or could we create a function that does this job?

Kris Thielemans

hindi pa nababasa,
Okt 18, 2018, 5:42:54 AM10/18/18
para kayCCPPETMR/Hackathon-SIRF, Subscribed

We did discuss if we should add various functions like this (max/min/norm etc) and voted for not doing it to keep SIRF lightweight. Obviously, we' re adding more stuff all the time (including arithmetical operators) so I suppose it makes sense now.

If we do go ahead, I think the DataContainer should have virtual methods such that it can call the relevant function from the underlying container (e.g. STIR has find_max for images). This would be faster then first copying the stuff somehwere and then determining the max. At first sight, we could have a default implementation that calls as_array, but interestingly as_array is Python/MATLAB specific (while the C++ code obviously isn't), so I wouldn't do that. It could be done once we have iterators for DataContainers, see CCPPETMR/SIRF#212.

Final thing to consider then is naming etc. You'd want to be close to the native feel. Sadly, in MATLAB max just works on 1 dimension of the array, so I suppose there is no native equivalent for maximum. numpy has amax which defaults to axis=None to use everything, but users might expect a SIRF function to be able to specify axis as well, which would really lead us to far.

Oh, and of course, it'd have to throw if the data is complex.

so, not as trivial as you'd hope.

Matthias J. Ehrhardt

hindi pa nababasa,
Okt 18, 2018, 6:56:27 AM10/18/18
para kayCCPPETMR/Hackathon-SIRF, Subscribed

I suggest to close this issue as we have a new one in SIRF.

Tumugon sa lahat
Sumagot sa may-akda
Ipasa
0 bagong mensahe