STIR
STIR copied to clipboard
stir_math fails for parametric images that have the number of time frames on them
stir_math
does not support parametric images, so currently one needs to extract_single_images_from_parametric_image
, then call twice stir_math
in their components and finally make_parametric_image_from_components
.
I think it would make sense for stir_math
to just be able to accept these as input and interpret each channel as independent (i.e. do the operation channel-wise).
are you sure that doesn't work yet? https://github.com/UCL/STIR/blob/40545147179fbe2b1131679672375cc91a39ab55/src/utilities/stir_math.cxx#L507
mmm the specific error I get is
WARNING: Discretised density should contain 1 time frame, but this image contains 16. Only the first will be kept, and the rest discarded.
Which is confusing, because they are indeed parametric images, not dynamic ones, as the error suggests, there are no time-frames.
Upon further inspection, I can see that the parametric images outputed from the direct recon (POSMAPOSL
) contain the following lines in the header:
number of time frames := 16
number of image data types := 2
So, yes, they are 2 channel, and if I inspect the data and treat them as parametric images, they are indeed parametric. But they also have the number of time frames in the header. This is what is causing stir_math
to fail.
So either stir_math
can not handle parametric images with this extra information, or this extra information should never be there, and the error is that they are saved with it.
POSMAPOSL
will return a parametric image with time frame numbers, regardless if the initial image given has it or not. So this is not caused by some spurious initial image to the algorithm.
This was changed a while ago (I'd have to go hunting for the PR). The rationale for allowing number of time frames>1 in parametric images was that it does give some information on how the parametric image was obtained.
The error message is generated by read_interfile_image
which is specific to VoxelsOnCartesianGrid
. It shouldn't have been called at all. (should have been read_interfile_parameteric_image
(both defined in interfile.cxx
)).
As extract_single_images_from_parametric_image
presumably works on the data? If so, it cannot be an issue with the reading routine in general, so must have something to do with stir_math
specifically. A bit hard to see how this can be the case though...
Probably best to insert some debugging statements on where it is in all of this
https://github.com/UCL/STIR/blob/40545147179fbe2b1131679672375cc91a39ab55/src/utilities/stir_math.cxx#L159-L169
I see that read_from_file
is called in 2 different ways, where the second one is obsolete. On the other hand, the second one should be calling the first
https://github.com/UCL/STIR/blob/40545147179fbe2b1131679672375cc91a39ab55/src/modelling_buildblock/ParametricDiscretisedDensity.cxx#L167-L170
extract_single_images_from_parametric_image
does indeed work in the data, so it indeed has to be something with stir_math
. Ill check.