Closed CPBridge closed 8 months ago
[like] Schacherer, Daniela reacted to your message:
From: Chris Bridge @.> Sent: Monday, September 11, 2023 10:46:21 PM To: ImagingDataCommons/highdicom @.> Cc: Schacherer, Daniela @.>; Mention @.> Subject: [ImagingDataCommons/highdicom] Improvements for working with tiled segmentations (PR #248)
A major set of improvements for working with segmentations of TILED images:
Note that currently this PR contains all of the contents of #245https://github.com/ImagingDataCommons/highdicom/pull/245 as I branched from there.
@fedorovhttps://github.com/fedorov @dcluniehttps://github.com/dclunie @DanielaSchachererhttps://github.com/DanielaSchacherer @curtislislehttps://github.com/curtislisle
You can view, comment on, or merge this pull request online at:
https://github.com/ImagingDataCommons/highdicom/pull/248
Commit Summary
File Changes
(10 fileshttps://github.com/ImagingDataCommons/highdicom/pull/248/files)
Patch Links:
— Reply to this email directly, view it on GitHubhttps://github.com/ImagingDataCommons/highdicom/pull/248, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACVDZQORSA7CTDIBZGXU22LXZ6ID3ANCNFSM6AAAAAA4EU3RUY. You are receiving this because you were mentioned.Message ID: @.***>
A major set of improvements for working with segmentations of TILED images:
tile_input_array
boolean parameter. If it is True, the user passes a single frame to the constructor representing the full total pixel matrix, and highdicom performs the tiling automatically. The user may specify atile_size
, otherwise it will be copied from the source image. This process avoids unnecessarily reshaping the input array and should therefore also be considerably more efficient than reshaping to a stack of tiled frames before compressing/storing.TILED_FULL
dimension organization type upon construction. The user can specify thedimension_organization_type
asTILED_FULL
and, if the requirements are met for this to be possible, the segmentation will be stored in this way. Note that I anticipate this primarily being used with the aforementionedtile_input_array
option, though that is not a requirement. The previous behaviour was to useTILED_SPARSE
(although this was not actually stored in the dataset) and store the frames in an order that was different to that required forTILED_FULL
. Given comments in @hackermd 's existing code, I believe this was a mistake and that the intention was that frames should always have been stored in an order that matchesTILED_FULL
. Therefore I chose to change the order of frames for all segmentations to match that required byTILED_FULL
regardless of whether the segmentation is actually stored asTILED_FULL
. I suppose you could consider this a backwards incompatible change, although hopefully no-one was relying on the frame ordering in a nonTILED_FULL
. Also note that a clarification of the standard regarding where segment number should live in theTILED_FULL
frame order has been prepared by @dclunie and I have followed this convention (segment number varies more slowly than row and column position).get_total_pixel_matrix
to the segmentation object. This returns the segmentation array of a segmentation object as the total pixel matrix rather than a stack of frames. It works for both TILED_FULL and TILED_SPARSE (or unspecified dimension organization type). Furthermore, the user can specify a rectangular sub-region of the total pixel matrix rather than the full array. Otherwise, behaviour is similar to the existing methods for accessing the segmentation mask (the user may specify segments of interest and use thecombine_segments
option to have a labelmap style array returned to them). I implemented this by generalizing the underlying efficient segmentation "reconstruction" routine so most of the code is shared with the implementation of the existing methods.utils
module. Previously thecompute_plane_position_slide_per_frame
function returned a list ofPlanePositionObjects
but for the tasks above it is inefficient to do this as we just want the underlying values stored in the objects. Therefore that method has been refactored to call another public function (iter_tiled_full_frame_data
) that just yields the underlying data (plane positions and x/y/z offsets).Note that currently this PR contains all of the contents of #245 as I branched from there.
@fedorov @dclunie @DanielaSchacherer @curtislisle