Skip to content

combine_slices optimization #18

@jond01

Description

@jond01

After inspecting in detail the combine_slices code, I found some optimization possibilities:

  • _sort_by_slice_position is called twice:
    First in the voxels (_merge_slice_pixel_arrays),
    Second in the affine (_ijk_to_patient_xyz_transform_matrix).
    Obviously, it can be done once in the outer combine_slices function.
  • _slice_positions is called 4 times:
    _validate_slices_form_uniform_grid - 1 time
    _slice_spacing - 1 time
    _sort_by_slice_position - 1 time, but _sort_by_slice_position is called twice --> 2 times
  • _extract_cosines is called 6 times:
    _validate_image_orientation - 1 time
    _ijk_to_patient_xyz_transform_matrix - 1 time
    _slice_positions - 1 time, but _slice_positions is called 4 times --> 4 times

All these calls better be done once (and can be).
However,

  1. this may incorporate substantial redesign of the code,
  2. it will change the functionality of _merge_slice_pixel_arrays and _ijk_to_patient_xyz_transform_matrix, which should not be used alone, but there are some special tests for _merge_slice_pixel_arrays.

Originally posted by @jond01 in #16 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions