Skip to content

Transform section pattern for some cases of non-auto axis image saver - #654

Merged
yousefmoazzam merged 1 commit into
mainfrom
transform-section-pattern
Dec 2, 2025
Merged

yousefmoazzam merged 1 commit into
mainfrom
transform-section-pattern

Conversation

@yousefmoazzam

@yousefmoazzam yousefmoazzam commented Nov 25, 2025 •

Copy link
Copy Markdown
Collaborator

Fixes https://jira.diamond.ac.uk/browse/IMGDA-606

For cases where the axis parameter of the image saver is configured to:

  • not be auto
  • and the given integer value is not the slicing dim represented by the pattern associated with the section the image saver method is in

then the images saved are likely not what is intended.

For example, consider the following sequence of methods:

  • normaliser
  • stats calculator (produces side output)
  • rescaler (depends on side output of global stats)
  • image saver (with axis set to 1)

The fact that the rescaler requires the side output produced by the stats calculator means that a new section is started after the stats calculator. Thus, where will be two sections made from this sequence of methods.

The normaliser will have the projection pattern, and this means that the first section has the projection pattern (which has slicing dimension 0).

The rescaler has the "all" pattern and so does the image saver. This will ultimately result in the second section having the projection pattern, which means that a chunk will be split into blocks of projections.

However, the image saver's setting of axis=1 will result in saving images sliced along axis 1 of each of the blocks of projections, which are something like "partial sinograms" within each block of projections. This is unlikely to be what the user intended, and instead what was probably intended was to save the output of the rescaler as "full sinograms". In order to accomplish this, a reslice operation is needed between the first and second section, and this can be achieved by transforming the pattern for the second section from projection to sinogram.

The changes made in this commit perform such a transformation where relevant.

Note that the above example is one specific case, but more generally, this transformation will be applied to a section containing an image saver method if the image saver is configured with an axis value that is not auto and this value is not the slicing dim represented by the pattern of the image saver's section.

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have made corresponding changes to the documentation

For cases where the `axis` parameter of the image saver is configured
to:
- not be `auto`
- and the given integer value is not the slicing dim represented by the
  pattern associated with the section the image saver method is in

then the images saved are likely not what is intended.

For example, consider the following sequence of methods:
- normaliser
- stats calculator (produces side output)
- rescaler (depends on side output of global stats)
- image saver (with `axis` set to 1)

The fact that the rescaler requires the side output produced by the
stats calculator means that a new section is started after the stats
calculator. Thus, where will be two sections made from this sequence of
methods.

The normaliser will have the projection pattern, and this means that the
first section has the projection pattern (which has slicing dimension
0).

The rescaler has the "all" pattern and so does the image saver. This
will ultimately result in the second section having the projection
pattern, which means that a chunk will be split into blocks of
projections.

However, the image saver's setting of `axis=1` will result in saving
images sliced along axis 1 of each of the blocks of projections, which
are something like "partial sinograms" within each block of projections.
This is unlikely to be what the user intended, and instead what was
probably intended was to save the output of the rescaler as "full
sinograms". In order to accomplish this, a reslice operation is needed
between the first and second section, and this can be achieved by
transforming the pattern for the second section from projection to
sinogram.

The changes made in this commit perform such a transformation where
relevant.

Note that the above example is one specific case, but more generally,
this transformation will be applied to a section containing an image
saver method if the image saver is configured with an `axis` value that
is not `auto` and this value is not the slicing dim represented by the
pattern of the image saver's section.
@yousefmoazzam
yousefmoazzam force-pushed the transform-section-pattern branch from 68ac701 to abc15b3 Compare November 28, 2025 10:10
@dkazanc

dkazanc commented Dec 1, 2025

Copy link
Copy Markdown
Collaborator

thanks! So, if I understand correctly, the reslice operation happens only if the user select the right axis in the image saver method. For instance axis=1 will trigger the reslice?

@yousefmoazzam

Copy link
Copy Markdown
Collaborator Author

thanks! So, if I understand correctly, the reslice operation happens only if the user select the right axis in the image saver method. For instance axis=1 will trigger the reslice?

I'm not sure what "the right axis" means, so I'll defer to enumerating the options in the hope that it answers the question 😅; if the image saver is in a section whose pattern is projection:

  • if axis=0, the section pattern stays as projection, so no reslice is triggered
  • if axis=1, the section pattern is changed to sinogram, so a reslice to sinograms is triggered

Perhaps a succinct way to describe the behaviour is the following: if the axis value doesn't match the pattern of the section that the image saver is in, a reslice will be triggered.

@dkazanc

dkazanc commented Dec 2, 2025

Copy link
Copy Markdown
Collaborator

thanks, yes this axis 0,1 is slightly less intuitive as the string-based pattern. But I understand some inconveniences when moving to defining quite a lot of different strings for different cases, like volume_xz, volume_xy, etc. Happy with the changes.

@yousefmoazzam

Copy link
Copy Markdown
Collaborator Author

The IRIS GPU runners are still experiencing issues, but the framework and small data tests pass locally, so I'll go ahead and merge this.

@yousefmoazzam
yousefmoazzam merged commit f01b22e into main Dec 2, 2025
6 of 7 checks passed
@yousefmoazzam
yousefmoazzam deleted the transform-section-pattern branch December 2, 2025 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants