GSTT-CSC / hazen

Quality assurance framework for Magnetic Resonance Imaging
https://github.com/GSTT-CSC/hazen
Apache License 2.0
22 stars 12 forks source link

ACR v1.1 - Refactor and Improved Masking #343

Closed YassineAzma closed 1 year ago

YassineAzma commented 1 year ago

This PR introduces the ACRTools class in acr_tools.py, which contains a number of useful functions that are frequently used throughout the ACR analysis scripts.

sort_images = DICOM and image sorting via the image position

determine_rotation = Estimate the rotation angle of the phantom using the Hough circle detector

rotate_images = Rotates the images by the rotation angle

mask_image = Thresholds the image - if the intensity variation in the image is sufficiently large, local thresholding methods are used rather than a global intensity threshold.

find_phantom_center = Now decoupled from the masking routine. The image is blurred and the edges are then sharpened along the diagonal. The Hough circle detector is then used to identify the phantom using prior knowledge of its geometry.

circular_mask = Draw a circular mask

measure_orthogonal_lengths = Measure the horizontal and vertical extent of the mask.

rotate_point = Find x' and y' for a point rotated around a given centre by a given angle.

find_n_highest_peaks = Given an array, report the location and intensity of the highest peaks.

Along with other general improvements, these functions have been used to refactor the existing ACR functions. This will prevent unneeded repetition in the unit tests for the individual analysis scripts by grouping tests for reused functions in the acr_tools.py module.

NOTE: All ACR test outputs have changed by <2% owing to changes in the masking and centre definition methods. These changes should make them more robust to issues seen in Issues #333 and #332.

Pending: Complete unit tests for acr_tools module.

Resolves #333, #332

github-actions[bot] commented 1 year ago

Coverage

Coverage Report
FileStmtsMissCoverMissing
hazenlib
   ACRObject.py83396%66, 82–83
   HazenTask.py26388%32–34
   __init__.py541769%125–133, 145, 179–181, 184–186, 193–196, 207
   exceptions.py21481%17–21
   relaxometry.py2868670%182–200, 377, 423–425, 492, 566–588, 606–621, 1037–1040, 1046–1052, 1085–1130
   utils.py1894377%61, 65, 75, 80, 117, 124–129, 140, 143–150, 170–172, 190–192, 211–213, 222, 227, 233, 284, 287, 295–300, 303, 346, 355, 371
hazenlib/tasks
   acr_geometric_accuracy.py1216447%41–73, 121–146, 160–194
   acr_ghosting.py1094361%34–49, 75–77, 107–109, 145–186
   acr_slice_position.py1354765%46–61, 187–233
   acr_slice_thickness.py1345857%34–48, 157–216
   acr_snr.py1356353%43–83, 93, 163–173, 207–222, 255–272
   acr_spatial_resolution.py2097166%58–83, 128, 171, 184–193, 275–326
   acr_uniformity.py833360%35–51, 108–133
   ghosting.py1525365%18–35, 50, 112–113, 117, 127–128, 154–156, 173–175, 221–259
   relaxometry.py770%1–11
   slice_position.py1172380%28, 37–38, 49, 103–104, 130, 210, 217–234
   slice_width.py3605385%34–37, 41, 109, 168–188, 453, 458–459, 465, 470, 532–533, 782–823
   snr.py1666760%51, 68–73, 167–185, 200–209, 227–237, 264–274, 279–289, 320–333, 338–346, 375–388
   snr_map.py104199%291
   spatial_resolution.py2484582%36–39, 43, 64, 149, 208, 334–370
   uniformity.py792075%42–45, 51, 93–94, 101, 135–149
TOTAL284380472% 

Tests Skipped Failures Errors Time
201 0 :zzz: 0 :x: 0 :fire: 3m 20s :stopwatch:
tomaroberts commented 1 year ago

Just to add to this, you've written a fair amount of documentation in the files, which is great. When we come to fully uplifting the hazen ReadTheDocs, we'll definitely need your input on making the guidance as clear as possible. Thanks.