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

rotates sagittal acr images #445

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion hazenlib/ACRObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def sort_dcms(self, dcm_list):
logger.info("image orientation is %s", orientation)
dcm_stack = [dcm_list[i] for i in np.argsort(positions)]
# img_stack = [dcm.pixel_array for dcm in dcm_stack]

return dcm_stack # , img_stack

def order_phantom_slices(self, dcm_list):
Expand Down
15 changes: 15 additions & 0 deletions hazenlib/tasks/acr_slice_thickness.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

from hazenlib.HazenTask import HazenTask
from hazenlib.ACRObject import ACRObject
from hazenlib.utils import get_image_orientation



class ACRSliceThickness(HazenTask):
Expand All @@ -43,6 +45,19 @@ def run(self) -> dict:
"""
# Identify relevant slice
slice_thickness_dcm = self.ACR_obj.slice_stack[0]
# TODO image may be 90 degrees cw or acw, could use code to identify which or could be added as extra arg

ori = get_image_orientation(slice_thickness_dcm)
if ori == 'Sagittal':
# Get the pixel array from the DICOM file
img = slice_thickness_dcm.pixel_array

# Rotate the image 90 degrees clockwise

rotated_img = np.rot90(img, k=-1) # k=-1 for 90 degrees clockwise

# Update the pixel array in the DICOM object
slice_thickness_dcm.PixelData = rotated_img.tobytes()

# Initialise results dictionary
results = self.init_result_dict()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ACRObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def setUp(self):
self.img7 = self.ACR_object.slice_stack[6].pixel_array


# Siemens saggital
# Siemens sagittal
class TestACRToolsSAG(TestACRTools):
rotation = -90.0
centre = (130, 148)
Expand Down
5 changes: 1 addition & 4 deletions tests/test_acr_geometric_accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ def test_distortion_metrics(self):
metrics = np.round(metrics, 2)
assert (metrics == self.distortion_metrics).all() == True


# TODO: Add unit tests for Philips datasets.


# TODO: Add unit tests for Philips datasets (when Philips data is available).
class TestACRGeometricAccuracyGE(TestACRGeometricAccuracySiemens):
ACR_DATA = pathlib.Path(TEST_DATA_DIR / "acr" / "GE")
L1 = 190.42, 188.9
Expand Down
Loading