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

Task 1 - XR Files #290

Merged
merged 4 commits into from
Aug 30, 2023
Merged

Task 1 - XR Files #290

merged 4 commits into from
Aug 30, 2023

Conversation

danielhorton4001
Copy link
Contributor

Sample file IM000001 can be opened and have a temporary rtss applied.
Files IM000002 through 4 cannot be opened.

Phil made the RTSTURCT function.

Daniel Horton added 2 commits August 17, 2023 18:41
… and ImageLoading.py changes.

RTSTRUCTs can be generated, and XR files with RTSTRUCTs can be opened, however they are not added automatically yet.
Additionally, the XR display needs adjustement.
Temp RTSTRUCTS are now applied to XR files.
Removed some testing code from and renamed xr-rtstruct.py -> xrRtstruct.py.
IM000001 sample file can be opened, but IM000002-IM000004 cause issues.
Copy link
Collaborator

@sjswerdloff sjswerdloff left a comment

Choose a reason for hiding this comment

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

Please take a look at Photometric Interpretation.
It should allow you to simplify some of the code.

src/Model/CalculateImages.py Show resolved Hide resolved
@@ -68,6 +68,11 @@
"1.2.840.10008.5.1.4.1.1.88.33": {
"name": "sr",
"sliceable": False
},
# XR Image
Copy link
Collaborator

Choose a reason for hiding this comment

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

XR is not a standard acronym or name for this, although it may be understood by others. Formally it is CR Image:
https://dicom.innolitics.com/ciods/cr-image

orientation = img_dataset.ImageOrientationPatient
position = img_dataset.ImagePositionPatient
sort_key = img_stack_displacement(orientation, position)

return sort_key


def add_missing_cr_components(cr):
"""
:param cr: a dictionary key, value item that represents a CR file
Copy link
Collaborator

Choose a reason for hiding this comment

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

The data type is pydicom.Dataset

src/Model/ImageLoading.py Show resolved Hide resolved
@@ -36,6 +36,11 @@ def create_initial_model():
if dataset[0].Modality == "CT":
is_ct = True

# Determine if dataset is CR for grayscale inverting
is_cr = False
Copy link
Collaborator

Choose a reason for hiding this comment

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

See comment in ImageLoading regarding Photometric Interpretation

@@ -41,6 +41,11 @@ def create_moving_model():
if dataset[0].Modality == "CT":
is_ct = True

# Determine if dataset is CR for grayscale inverting
Copy link
Collaborator

Choose a reason for hiding this comment

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

see comment regarding Photometric Interpretation

rt_ss.SoftwareVersions = "2021"

# Frame of Reference module
rt_ss.PositionReferenceIndicator = ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Body Part Examined might be a reasonable value to use for the RT SS Position Reference Indicator.
https://dicom.innolitics.com/ciods/cr-image/cr-series/00180015

from copy import deepcopy
import datetime

#AttributeError: 'Dataset' object has no attribute 'FrameOfReferenceUID'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Frame Of Reference is what ties together a 3D Volume (and more generally, a Series of images). A CR isn't a volume, and it predated the concept of a Frame Of Reference (or else it would have been a type 3 or type 2, where for CT and other objects it is frequently type 1).

import datetime

#AttributeError: 'Dataset' object has no attribute 'FrameOfReferenceUID'
#removed 2 lines relating to this error, might need to be looked at if this is required
Copy link
Collaborator

Choose a reason for hiding this comment

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

For the RT SS to be DICOM conformant (and can have an expectation of being usable by anything else), it will need to have a FrameOfReferenceUID. Given that one is trying to tie the RT SS to the CR, one could generate a new UID for the FoR, insert that in to the RT SS, and update the CR object by adding the FoR UID to that. Given that you know you will need to do this up front, it would be better to update the CR first (with a generated FoR UID), and update the SOP Instance UID of the CR (because it's a new object and not interchangeable with the original CR that lacks the FoR UID), and then use that FoR UID in the RT SS. Having a DICOM object with a public element it wouldn't normally have tends to be reasonably interoperable. Having a DICOM object without a public element that it is required to have is problematic.

Copy link
Collaborator

Choose a reason for hiding this comment

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

this seems like it would better to have in the test area, or if we want to have separate utilities.
It doesn't seem necessary for the application itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file was supposed to be removed, I guess I forgot to do that. Sorry!

@sjswerdloff
Copy link
Collaborator

Very good draft pull request.

@sjswerdloff
Copy link
Collaborator

The pyradiomics issue is one for the maintainers to work out.
I've submitted a PR to pyradiomics to get them to fix the issue with metadata in pyradiomics 3.1.0.

@sjswerdloff
Copy link
Collaborator

Please fetch and pull from upstream master (to address pyradiomics issue and the poetry.lock issue)

@sjswerdloff
Copy link
Collaborator

Yeah! All checks have passed, so the master branch is a known good starting point.
And... @danielhorton4001 your changes have all passed tests as well.
Please move forward on using Photometric Interpretation (and drop me a line if you would like any assistance).

… equal dimensions, but CR files do not, requiring a change.

Made some requested changes.
@danielhorton4001
Copy link
Contributor Author

Still need to fix up xrStruct.py, but everything else (including functionality with the other sample files) is in.

@sjswerdloff sjswerdloff marked this pull request as ready for review August 30, 2023 16:00
@sjswerdloff
Copy link
Collaborator

Still need to fix up xrStruct.py, but everything else (including functionality with the other sample files) is in.

please do this in a separate PR.

@sjswerdloff sjswerdloff merged commit d2d164a into didymo:master Aug 30, 2023
5 checks passed
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.

2 participants