Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACR slice ordering #409

Merged
merged 56 commits into from
Feb 29, 2024
Merged

ACR slice ordering #409

merged 56 commits into from
Feb 29, 2024

Conversation

sophie22
Copy link
Contributor

@sophie22 sophie22 commented Jan 29, 2024

This PR includes important changes to how the ACR phantom image slices are being processed prior to specific task measurements.

An instance of the ACRObject class now has the following attributes:

  • dx and dy corresponding to the PixelSpacing values from the DICOM header (in x and y directions)
  • slice_stack is a list of the input DICOMs, ordered by position (from ImageOrientationPatient) and ordered by phantom orientation (see below)
  • there is no LR flipping of pixel values

The following methods are available for ACRobjects:

  • sort_dcms: orders DICOMs based on the changing coordinate according to acquisition orientation
  • order_phantom_slices: orders DICOMs based on phantom orientation - first slice is expected to have a circle while the last one is expected not to have one
  • find_phantom_centre: locate the coordinates of the phantom (circle) in the image and also return its radius
  • get_mask_image: pixel array with values above given threshold from input image
  • circular_mask: list of coordinate matrices from coordinate vectors with given centre and radius
  • determine_rotation: determines rotation angle of phantom images
  • rotate_images: rotate the pixel array of all phantom slices by a defined angle
  • `rotate_point': calculate new coordinates of a point (pixel) after rotation by a defined angle
  • measure_orthogonal_lengths and find_n_highest_peaks are specific to task measurements

Other important changes:

In task-specific classes, the phantom centre is now being calculated based on the specific slice, not taken from the flood field slice as previously.
Resolution is now being used from the ACRObject dx, dy attributes rather than being accessed from the DICOM header values.
determine_orientation and detect_circle are new functions moved to the utilities to make them more widely reusable.
scipy version was updated to make use of a predefined function rather than specifying our own.
Unit tests were simplified for ACR tasks and new tests were added for ACRObject for a more comprehensive coverage of this class.
Some test values had to be updated to account for different rounding methods, but all are within tolerance as per ACR guidelines.

@sophie22 sophie22 linked an issue Jan 29, 2024 that may be closed by this pull request
@sophie22 sophie22 changed the title 404 ACR slice ordering ACR slice ordering Jan 29, 2024
@sophie22 sophie22 changed the base branch from main to 397-standardise-docstrings January 29, 2024 17:12
Copy link

github-actions bot commented Jan 29, 2024

Coverage

Coverage Report
FileStmtsMissCoverMissing
hazenlib
   ACRObject.py1071091%77–83, 119, 134–137, 191–194
   HazenTask.py28389%67–71
   __init__.py561573%102, 135–144, 146–155, 157–159, 176–180, 184
   exceptions.py21576%19–23, 42
   utils.py2225973%77, 81, 102, 115, 148, 163–176, 195, 202–209, 226–228, 243–247, 263–267, 287, 292, 303, 375–376, 378–379, 384–397, 450, 453, 461–466, 469, 524, 533, 562
hazenlib/tasks
   acr_geometric_accuracy.py1115848%53–100, 124–239
   acr_ghosting.py1064260%42–58, 104–107, 154–157, 201–283
   acr_slice_position.py1364865%56–80, 281–348
   acr_slice_thickness.py1356056%45–64, 235–319
   acr_snr.py1325757%60–111, 131, 227–242, 287–305, 355–380
   acr_spatial_resolution.py2066867%70–100, 187, 285, 302–313, 460–539
   acr_uniformity.py803260%43–60, 150–202
   ghosting.py1495166%28–47, 67, 171–172, 179, 196–197, 252–256, 271–275, 346–387
   relaxometry.py2908969%210–211, 213, 226–231, 238–246, 277–326, 375, 409–431, 609, 655–659, 726, 811–833, 851–866
   slice_position.py1244068%30, 43–71, 129–130, 157, 273, 283–306
   slice_width.py3515385%44–48, 52, 123, 188–213, 383, 555, 560–561, 567, 572, 648–649, 1020–1084
   snr.py1736960%45–48, 87, 103–113, 206–225, 237–247, 287–302, 330–340, 345–361, 399–415, 428–434, 477–495
   snr_map.py107199%159
   spatial_resolution.py2464582%50–54, 58, 90, 191, 213, 294, 460–503
   uniformity.py801976%59–63, 67, 118–119, 126, 175–205
TOTAL288582471% 

Tests Skipped Failures Errors Time
208 0 💤 0 ❌ 0 🔥 2m 20s ⏱️

@sophie22
Copy link
Contributor Author

sophie22 commented Feb 1, 2024

  • nothing works for Sagittal due to a 90 degree anticlockwise rotation.
  • all tasks (and especially their report images) for all orientation need to be checked - things like correctly shifting the centre coordinates, sampling from relevant regions, etc
  • report image generation should be split and moved to their respective functions calculating the values being represented

@sophie22
Copy link
Contributor Author

sophie22 commented Feb 1, 2024

all tests are failing as these haven't been updated to use the new functions yet

@sophie22 sophie22 marked this pull request as ready for review February 14, 2024 15:42
@sophie22
Copy link
Contributor Author

expected values were updated following discussion with Molly, having concluded that differences are due to rounding and are well within the tolerances for their respective measurement as per ACR guidelines.

Base automatically changed from 397-standardise-docstrings to main February 27, 2024 11:34
@sophie22 sophie22 requested a review from tomaroberts February 27, 2024 11:58
Copy link
Contributor

@tomaroberts tomaroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sophie22 – I think this is fine. Bit tricky to tell the extent of the changes, but if the tests are passing, then that's okay.

One comment about the phantom_orientation function. Ultimately, the user should configure the phantom in an orientation compliant with the guidelines, but if this helps iron out some issues, then go ahead.

@sophie22 sophie22 requested a review from tomaroberts February 28, 2024 20:47
@tomaroberts tomaroberts merged commit 2862836 into main Feb 29, 2024
4 checks passed
@tomaroberts tomaroberts deleted the 404-acr-slice-ordering branch February 29, 2024 09:21
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.

ACR object slice ordering results in use of incorrect slice
3 participants