Skip to content

Commit

Permalink
rename to from_ref_dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
CPBridge committed Aug 10, 2021
1 parent dc93d43 commit 5cce71d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
34 changes: 17 additions & 17 deletions src/highdicom/sc/sop.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,9 @@ def __init__(
self.PixelData = encoded_frame

@classmethod
def from_study_dataset(
def from_ref_dataset(
cls,
study_dataset: Dataset,
ref_dataset: Dataset,
pixel_array: np.ndarray,
photometric_interpretation: Union[
str,
Expand Down Expand Up @@ -413,18 +413,18 @@ def from_study_dataset(
"""Constructor that copies patient and study from an existing dataset.
This provides a more concise way to construct an SCImage when an
existing dataset from the study is available. All patient- and study-
related attributes required by the main constructor are copied from the
``study_dataset``, if present.
existing reference dataset from the study is available. All patient-
and study- related attributes required by the main constructor are
copied from the ``ref_dataset``, if present.
The ``study_dataset`` may be any dataset
The ``ref_dataset`` may be any dataset
from the study to which the resulting SC image should belong, and
contain all the relevant patient and study metadata. It does not need to
be specifically related to the contents of the SCImage.
Parameters
----------
study_dataset: pydicom.dataset.Dataset
ref_dataset: pydicom.dataset.Dataset
An existing dataset from the study to which the SCImage should
belong. Patient- and study-related metadata will be copied from
this dataset.
Expand Down Expand Up @@ -493,22 +493,22 @@ def from_study_dataset(
photometric_interpretation=photometric_interpretation,
bits_allocated=bits_allocated,
coordinate_system=coordinate_system,
study_instance_uid=study_dataset.StudyInstanceUID,
study_instance_uid=ref_dataset.StudyInstanceUID,
series_instance_uid=series_instance_uid,
series_number=series_number,
sop_instance_uid=sop_instance_uid,
instance_number=instance_number,
manufacturer=manufacturer,
patient_id=getattr(study_dataset, 'PatientID', None),
patient_name=getattr(study_dataset, 'PatientName', None),
patient_birth_date=getattr(study_dataset, 'PatientBirthDate', None),
patient_sex=getattr(study_dataset, 'PatientSex', None),
accession_number=getattr(study_dataset, 'AccessionNumber', None),
study_id=getattr(study_dataset, 'StudyID', None),
study_date=getattr(study_dataset, 'StudyDate', None),
study_time=getattr(study_dataset, 'StudyTime', None),
patient_id=getattr(ref_dataset, 'PatientID', None),
patient_name=getattr(ref_dataset, 'PatientName', None),
patient_birth_date=getattr(ref_dataset, 'PatientBirthDate', None),
patient_sex=getattr(ref_dataset, 'PatientSex', None),
accession_number=getattr(ref_dataset, 'AccessionNumber', None),
study_id=getattr(ref_dataset, 'StudyID', None),
study_date=getattr(ref_dataset, 'StudyDate', None),
study_time=getattr(ref_dataset, 'StudyTime', None),
referring_physician_name=getattr(
study_dataset,
ref_dataset,
'ReferringPhysicianName',
None
),
Expand Down
22 changes: 11 additions & 11 deletions tests/test_sc.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def setUp(self):
self._specimen_uid = generate_uid()
file_path = Path(__file__)
data_dir = file_path.parent.parent.joinpath('data')
self._study_dataset = dcmread(
self._ref_dataset = dcmread(
str(data_dir.joinpath('test_files', 'ct_image.dcm'))
)

Expand Down Expand Up @@ -289,12 +289,12 @@ def test_rgb_rle(self):
frame
)

def test_construct_rgb_from_study_dataset(self):
def test_construct_rgb_from_ref_dataset(self):
bits_allocated = 8
photometric_interpretation = 'RGB'
coordinate_system = 'PATIENT'
instance = SCImage.from_study_dataset(
study_dataset=self._study_dataset,
instance = SCImage.from_ref_dataset(
ref_dataset=self._ref_dataset,
pixel_array=self._rgb_pixel_array,
photometric_interpretation=photometric_interpretation,
bits_allocated=bits_allocated,
Expand All @@ -311,18 +311,18 @@ def test_construct_rgb_from_study_dataset(self):
assert instance.SamplesPerPixel == 3
assert instance.PlanarConfiguration == 0
assert instance.PhotometricInterpretation == photometric_interpretation
assert instance.StudyInstanceUID == self._study_dataset.StudyInstanceUID
assert instance.StudyInstanceUID == self._ref_dataset.StudyInstanceUID
assert instance.SeriesInstanceUID == self._series_instance_uid
assert instance.SOPInstanceUID == self._sop_instance_uid
assert instance.SeriesNumber == self._series_number
assert instance.InstanceNumber == self._instance_number
assert instance.Manufacturer == self._manufacturer
assert instance.Laterality == self._laterality
assert instance.PatientOrientation == self._patient_orientation
assert instance.AccessionNumber == self._study_dataset.AccessionNumber
assert instance.PatientName == self._study_dataset.PatientName
assert instance.PatientSex == self._study_dataset.PatientSex
assert instance.StudyTime == TM(self._study_dataset.StudyTime)
assert instance.StudyDate == DA(self._study_dataset.StudyDate)
assert instance.StudyID == self._study_dataset.StudyID
assert instance.AccessionNumber == self._ref_dataset.AccessionNumber
assert instance.PatientName == self._ref_dataset.PatientName
assert instance.PatientSex == self._ref_dataset.PatientSex
assert instance.StudyTime == TM(self._ref_dataset.StudyTime)
assert instance.StudyDate == DA(self._ref_dataset.StudyDate)
assert instance.StudyID == self._ref_dataset.StudyID
assert instance.PixelData == self._rgb_pixel_array.tobytes()
2 changes: 1 addition & 1 deletion tests/test_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2749,7 +2749,7 @@ def setUp(self):
self._ref_dataset = Dataset()
self._ref_dataset.PatientID = '1'
self._ref_dataset.PatientName = 'patient'
self._ref_dataset.PatientBirthDate = '2000101'
self._ref_dataset.PatientBirthDate = '20000101'
self._ref_dataset.PatientSex = 'o'
self._ref_dataset.SOPClassUID = '1.2.840.10008.5.1.4.1.1.2.2'
self._ref_dataset.SOPInstanceUID = generate_uid()
Expand Down

0 comments on commit 5cce71d

Please sign in to comment.