Unblock step 13 and write the cropped cine frames - #97
Open
avhekkink wants to merge 1 commit into
Open
Conversation
Step 13 stopped with an ITK error and wrote no cropped frames. Step 14 reads nifti/dcm-crop-<N>.nii, so it had no input. Two defects composed. Repair the qform before the load. The CCTA container rebuilds the NIfTI header from the image affine and leaves qform_code at 0. SegmentExtract already calls CemrgNiftiUtils::RepairNiftiQform on the same container's output. CropImage did not. Crop every frame through CemrgCommonUtils::CropImage. The crop loop and the afmotion cropImages call were commented out, so the step measured a bounding box and discarded it. The container hardcodes its crop box to another dataset, so the crop runs on the host instead. MmcwView::CropinIMGS crops a cine series with the same three functions. Guard the bounding box. GetBoundingBox returns an empty list for a label that the image does not hold, so the loop read six elements past the end of it. A HasLabel test now stops the step first. Pad the box by a share of the length of each axis, then hold it inside the image. The padding scaled each index by a share of its own value, so it depended on the position of the atrium in the volume. Add the failure checks that SegmentExtract has: a named error for a missing reference frame, a copy that can overwrite, and a test of the segmentation result. Verified on V-0004. Step 13 writes 21 frames of 396 x 252 x 248. The origin of each frame equals the original origin plus M times the start index. Steps 14 to 20 then complete. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tz4XNNv9HTzUaJmdM2nFZ7
avhekkink
marked this pull request as ready for review
September 3, 2026 13:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All 20 steps of the pipeline now run successfully end to end on V-0004
Step 13 was blocked with an ITK error and produced nothing, so step 14 had no input. The crop itself was also never finished. The container's
cropImageshardcodes the crop box to one case, so this fix crops on the host instead, using the codebase's own utilities and a padded bounding box of the LA.Changes
CropImagerepairs the NIfTI header before it loads the segmentation. Why? Thecemrg/cctacontainer rebuilds the header from the image affine and leavesqform_codeat 0, which ITK refuses.SegmentExtractalready callsCemrgNiftiUtils::RepairNiftiQformon the output of the same container;CropImagedid not. This is the failure the step reported.CropImagewrites the cropped frames. The crop loop and theafmotion cropImagescall were commented out, so the step measured a bounding box, printed it to stdout and stopped. It now builds amitk::Cuboidfrom the padded box and writesnifti/dcm-crop-<N>.niithroughCemrgCommonUtils::CropImage, whichMmcwView::CropinIMGSalready uses to crop a cine series against one cube. Step 14 needs those files: the container writes<project>/nifti/dcm-crop- .niiintotracking/imgTimes.lst, and the host MIRTKregisterreads that list.afmotion cropImagesis not used, and should not be as-is.uac_pipeline.pyhardcodes the crop box to a specific case from another dataset and ignores the box the plugin measures. ItsCropNifti_v3.pyalso writes the affine shift with a guessed sign for each axis, correct only for one orientation.mitk::BoundingObjectCuttercallsIndexToWorldon the region start instead, which holds for any direction matrix.A
HasLabeltest guards the bounding box.itk::LabelStatisticsImageFilter::GetBoundingBoxreturns a default-constructedstd::vectorwhen the image does not hold the label, so the loop that follows read six elements past the end of an empty vector. This never fired only because the segmentation always found an atrium.The padding measures the box, not the position of the box. Each index was scaled by 30% of its own value, so the padding depended on where the atrium sat in the volume rather than how large it was. The padding is now a proportion of the length of each axis, held inside the image.
CropImagereports its failures. It names a missingnifti/dcm-10.nii, replaces the working copy rather than silently keeping the old one, stops when the segmentation writes nothing, and names the frame it cannot read or crop. The box now reachesafib_log<date>.logthroughMITK_INFO;std::coutnever did.Impacted areas
AtrialStrainMotionView.cppNothing shared changes.
CemrgCommandLine,CemrgCommonUtilsandCemrgNiftiUtilsare used as they are, so no other plugin is affected.The cropped frames land in
nifti/, beside the frames the user supplies, because the container hardcodes that path.Testing
Run in the GUI on
V-0004, 21 frames of 512 x 512 x 269:7 306 98 255 73 249and the padded box0 395 51 302 21 268. It wrote 21 frames in 113 seconds and left no scratch file.tracking/tsffd.dofat 9,039,844 bytes. Every per-frame output holds different content, checked bymd5sum, so no step repeated a result or wrote an empty one.This is the first end-to-end run of all twenty steps.
Not tested:
V-0004. Both demo datasets carry 21 frames of the same geometry.dcm-10.nii.