From 77f1b3eaaa6dc5c6483df27f6306a077f4617fb9 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 16 Jun 2023 09:21:58 -0400 Subject: [PATCH 1/7] Add github action to codespell master on push and PRs --- .github/workflows/codespell.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/codespell.yml diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 00000000..7373affc --- /dev/null +++ b/.github/workflows/codespell.yml @@ -0,0 +1,22 @@ +--- +name: Codespell + +on: + push: + branches: [master] + pull_request: + branches: [master] + +permissions: + contents: read + +jobs: + codespell: + name: Check for spelling errors + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Codespell + uses: codespell-project/actions-codespell@v2 From af7afa399bd5b48d7b6880413fb203c66b0178d1 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 16 Jun 2023 09:21:58 -0400 Subject: [PATCH 2/7] Add rudimentary codespell config --- .codespellrc | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .codespellrc diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 00000000..da3c0571 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,4 @@ +[codespell] +skip = .git,*.pdf,*.svg +# +# ignore-words-list = From 7ff4509abd2ffe099d0637d15d5ef5212e8a77b7 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 16 Jun 2023 09:23:17 -0400 Subject: [PATCH 3/7] Custom skips --- .codespellrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.codespellrc b/.codespellrc index da3c0571..d808b203 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,4 +1,4 @@ [codespell] -skip = .git,*.pdf,*.svg -# -# ignore-words-list = +skip = .git,*.pdf,*.svg,*.ipynb +# te,fo - either abbreviations of variables +ignore-words-list = te,fo From 4b15886c530c170ac1a3acf17309fd0d2736fdfe Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 16 Jun 2023 09:24:11 -0400 Subject: [PATCH 4/7] Fix ambiguous typos --- src/highdicom/seg/sop.py | 14 +++++++------- src/highdicom/sr/__init__.py | 2 +- src/highdicom/utils.py | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/highdicom/seg/sop.py b/src/highdicom/seg/sop.py index bf16c5c2..b86940b7 100644 --- a/src/highdicom/seg/sop.py +++ b/src/highdicom/seg/sop.py @@ -589,7 +589,7 @@ def iterate_indices_by_source_instance( relabel: bool, optional If True and ``combine_segments`` is ``True``, the output segment numbers are relabelled into the range ``0`` to - ``len(segment_numbers)`` (inclusive) accoring to the position of + ``len(segment_numbers)`` (inclusive) according to the position of the original segment numbers in ``segment_numbers`` parameter. If ``combine_segments`` is ``False``, this has no effect. @@ -690,7 +690,7 @@ def iterate_indices_by_source_frame( relabel: bool, optional If True and ``combine_segments`` is ``True``, the output segment numbers are relabelled into the range ``0`` to - ``len(segment_numbers)`` (inclusive) accoring to the position of + ``len(segment_numbers)`` (inclusive) according to the position of the original segment numbers in ``segment_numbers`` parameter. If ``combine_segments`` is ``False``, this has no effect. @@ -793,7 +793,7 @@ def iterate_indices_by_dimension_index_values( relabel: bool, optional If True and ``combine_segments`` is ``True``, the output segment numbers are relabelled into the range ``0`` to - ``len(segment_numbers)`` (inclusive) accoring to the position of + ``len(segment_numbers)`` (inclusive) according to the position of the original segment numbers in ``segment_numbers`` parameter. If ``combine_segments`` is ``False``, this has no effect. @@ -2637,7 +2637,7 @@ def _get_pixels_by_seg_frame( relabel: bool If True and ``combine_segments`` is ``True``, the pixel values in the output array are relabelled into the range ``0`` to - ``len(segment_numbers)`` (inclusive) accoring to the position of + ``len(segment_numbers)`` (inclusive) according to the position of the original segment numbers in ``segment_numbers`` parameter. If ``combine_segments`` is ``False``, this has no effect. rescale_fractional: bool @@ -3009,7 +3009,7 @@ def get_pixels_by_source_instance( relabel: bool, optional If True and ``combine_segments`` is ``True``, the pixel values in the output array are relabelled into the range ``0`` to - ``len(segment_numbers)`` (inclusive) accoring to the position of + ``len(segment_numbers)`` (inclusive) according to the position of the original segment numbers in ``segment_numbers`` parameter. If ``combine_segments`` is ``False``, this has no effect. ignore_spatial_locations: bool, optional @@ -3228,7 +3228,7 @@ def get_pixels_by_source_frame( relabel: bool, optional If True and ``combine_segments`` is ``True``, the pixel values in the output array are relabelled into the range ``0`` to - ``len(segment_numbers)`` (inclusive) accoring to the position of + ``len(segment_numbers)`` (inclusive) according to the position of the original segment numbers in ``segment_numbers`` parameter. If ``combine_segments`` is ``False``, this has no effect. ignore_spatial_locations: bool, optional @@ -3493,7 +3493,7 @@ def get_pixels_by_dimension_index_values( relabel: bool, optional If True and ``combine_segments`` is ``True``, the pixel values in the output array are relabelled into the range ``0`` to - ``len(segment_numbers)`` (inclusive) accoring to the position of + ``len(segment_numbers)`` (inclusive) according to the position of the original segment numbers in ``segment_numbers`` parameter. If ``combine_segments`` is ``False``, this has no effect. assert_missing_frames_are_empty: bool, optional diff --git a/src/highdicom/sr/__init__.py b/src/highdicom/sr/__init__.py index 69008253..8a479aff 100644 --- a/src/highdicom/sr/__init__.py +++ b/src/highdicom/sr/__init__.py @@ -1,4 +1,4 @@ -"""Package for creationg of Structured Report (SR) instances.""" +"""Package for creation of Structured Report (SR) instances.""" from highdicom.sr.coding import CodedConcept from highdicom.sr.content import ( FindingSite, diff --git a/src/highdicom/utils.py b/src/highdicom/utils.py index 85521e87..07c9a15f 100644 --- a/src/highdicom/utils.py +++ b/src/highdicom/utils.py @@ -106,7 +106,7 @@ def compute_plane_position_tiled_full( Returns ------- highdicom.PlanePositionSequence - Positon of the plane in the slide coordinate system + Position, of the plane in the slide coordinate system Raises ------ @@ -262,7 +262,7 @@ def _compute_plane_position_tiled_full_efficiently( Returns ------- highdicom.PlanePositionSequence - Positon of the plane in the slide coordinate system + Position, of the plane in the slide coordinate system """ row_offset_frame = ((row_index - 1) * rows) From c31828004873856d772d54e1cc564dd4a650d000 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 16 Jun 2023 09:24:15 -0400 Subject: [PATCH 5/7] [DATALAD RUNCMD] run codespell throughout === Do not change lines below === { "chain": [], "cmd": "codespell -w", "exit": 0, "extra_inputs": [], "inputs": [], "outputs": [], "pwd": "." } ^^^ Do not change lines above ^^^ --- docs/usage.rst | 2 +- src/highdicom/ann/enum.py | 2 +- src/highdicom/frame.py | 2 +- src/highdicom/ko/sop.py | 2 +- src/highdicom/legacy/sop.py | 2 +- src/highdicom/pm/sop.py | 2 +- src/highdicom/pr/content.py | 2 +- src/highdicom/pr/sop.py | 6 +++--- src/highdicom/sr/sop.py | 10 +++++----- src/highdicom/sr/templates.py | 4 ++-- src/highdicom/sr/value_types.py | 6 +++--- tests/test_ko.py | 4 ++-- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index a6f50b58..7abac4d5 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -351,7 +351,7 @@ Finding relevant content in the nested SR content tree: print(containers) # Query content of SR document, where content is structured according - # to TID 1500 "Measurment Report" + # to TID 1500 "Measurement Report" if sr_dataset.ContentTemplateSequence[0].TemplateIdentifier == 'TID1500': # Determine who made the observations reported in the document observers = hd.sr.utils.find_content_items( diff --git a/src/highdicom/ann/enum.py b/src/highdicom/ann/enum.py index b5008277..8a53d783 100644 --- a/src/highdicom/ann/enum.py +++ b/src/highdicom/ann/enum.py @@ -57,7 +57,7 @@ class GraphicTypeValues(Enum): """ POINT = 'POINT' - """An individual piont defined by a single coordinate.""" + """An individual point defined by a single coordinate.""" POLYLINE = 'POLYLINE' """Connected line segments defined by two or more ordered coordinates. diff --git a/src/highdicom/frame.py b/src/highdicom/frame.py index 6055d38d..0f55cda2 100644 --- a/src/highdicom/frame.py +++ b/src/highdicom/frame.py @@ -63,7 +63,7 @@ def encode_frame( ------- bytes Encoded pixel data (potentially compressed in case of encapsulated - format encoding, depending on the transfer snytax) + format encoding, depending on the transfer syntax) Raises ------ diff --git a/src/highdicom/ko/sop.py b/src/highdicom/ko/sop.py index 947d9e2d..454abc66 100644 --- a/src/highdicom/ko/sop.py +++ b/src/highdicom/ko/sop.py @@ -68,7 +68,7 @@ def __init__( Name of the department of the person or device that creates the document instance requested_procedures: Union[Sequence[pydicom.dataset.Dataset], None], optional - Requested procedures that are being fullfilled by creation of the + Requested procedures that are being fulfilled by creation of the document transfer_syntax_uid: str, optional UID of transfer syntax that should be used for encoding of diff --git a/src/highdicom/legacy/sop.py b/src/highdicom/legacy/sop.py index d7c3df4f..9c6e872a 100644 --- a/src/highdicom/legacy/sop.py +++ b/src/highdicom/legacy/sop.py @@ -328,7 +328,7 @@ def _convert_legacy_to_enhanced( # All remaining unassigned attributes will be collected in either the # UnassignedSharedConvertedAttributesSequence or the # UnassignedPerFrameConvertedAttributesSequence, depending on whether - # values vary accross frames (original single-frame image instances). + # values vary across frames (original single-frame image instances). unassigned_shared_ca_item = Dataset() unassigned_perframe_ca_items = [ Dataset() diff --git a/src/highdicom/pm/sop.py b/src/highdicom/pm/sop.py index ef29b73a..9c36e783 100644 --- a/src/highdicom/pm/sop.py +++ b/src/highdicom/pm/sop.py @@ -222,7 +222,7 @@ def __init__( Identifying information for the person who created the content of this parametric map. palette_color_lut_transformation: Union[highdicom.PaletteColorLUTTransformation, None], optional - Description of the Palette Color LUT Transformation for tranforming + Description of the Palette Color LUT Transformation for transforming grayscale into RGB color pixel values **kwargs: Any, optional Additional keyword arguments that will be passed to the constructor diff --git a/src/highdicom/pr/content.py b/src/highdicom/pr/content.py index 48809dd1..fd1df003 100644 --- a/src/highdicom/pr/content.py +++ b/src/highdicom/pr/content.py @@ -136,7 +136,7 @@ def __init__( label: str Name used to identify the Graphic Group (maximum 64 characters). description: Union[str, None], optional - Description of the group (maxiumum 10240 characters). + Description of the group (maximum 10240 characters). """ super().__init__() diff --git a/src/highdicom/pr/sop.py b/src/highdicom/pr/sop.py index 36e4ec5e..d3b7afca 100644 --- a/src/highdicom/pr/sop.py +++ b/src/highdicom/pr/sop.py @@ -389,7 +389,7 @@ def __init__( device_serial_number: Union[str, None] Manufacturer's serial number of the device palette_color_lut_transformation: highdicom.PaletteColorLUTTransformation - Description of the Palette Color LUT Transformation for tranforming + Description of the Palette Color LUT Transformation for transforming grayscale into RGB color pixel values content_label: str A label used to describe the content of this presentation state. @@ -419,10 +419,10 @@ def __init__( Identifying information for the person who created the content of this presentation state. modality_lut_transformation: Union[highdicom.ModalityLUTTransformation, None], optional - Description of the Modality LUT Transformation for tranforming modality + Description of the Modality LUT Transformation for transforming modality dependent into modality independent pixel values voi_lut_transformations: Union[Sequence[highdicom.pr.SoftcopyVOILUTTransformation], None], optional - Description of the VOI LUT Transformation for tranforming + Description of the VOI LUT Transformation for transforming modality pixel values into pixel values that are of interest to a user or an application icc_profile: Union[bytes, None], optional diff --git a/src/highdicom/sr/sop.py b/src/highdicom/sr/sop.py index c4a4aaf9..44ed97a2 100644 --- a/src/highdicom/sr/sop.py +++ b/src/highdicom/sr/sop.py @@ -127,7 +127,7 @@ def __init__( performed_procedure_codes: Union[List[highdicom.sr.CodedConcept], None], optional Codes of the performed procedures that resulted in the SR document requested_procedures: Union[List[pydicom.dataset.Dataset], None], optional - Requested procedures that are being fullfilled by creation of the + Requested procedures that are being fulfilled by creation of the SR document previous_versions: Union[List[pydicom.dataset.Dataset], None], optional Instances representing previous versions of the SR document @@ -356,7 +356,7 @@ class EnhancedSR(_SR): """SOP class for an Enhanced Structured Report (SR) document, whose content may include textual and a minimal amount of coded information, - numeric measurement values, references to SOP Instances (retricted to the + numeric measurement values, references to SOP Instances (restricted to the leaves of the tree), as well as 2D spatial or temporal regions of interest within such SOP Instances. """ @@ -432,7 +432,7 @@ def __init__( performed_procedure_codes: Union[List[highdicom.sr.CodedConcept], None], optional Codes of the performed procedures that resulted in the SR document requested_procedures: Union[List[pydicom.dataset.Dataset], None], optional - Requested procedures that are being fullfilled by creation of the + Requested procedures that are being fulfilled by creation of the SR document previous_versions: Union[List[pydicom.dataset.Dataset], None], optional Instances representing previous versions of the SR document @@ -563,7 +563,7 @@ def __init__( performed_procedure_codes: Union[List[highdicom.sr.CodedConcept], None], optional Codes of the performed procedures that resulted in the SR document requested_procedures: Union[List[pydicom.dataset.Dataset], None], optional - Requested procedures that are being fullfilled by creation of the + Requested procedures that are being fulfilled by creation of the SR document previous_versions: Union[List[pydicom.dataset.Dataset], None], optional Instances representing previous versions of the SR document @@ -725,7 +725,7 @@ def __init__( performed_procedure_codes: Union[List[highdicom.sr.CodedConcept], None], optional Codes of the performed procedures that resulted in the SR document requested_procedures: Union[List[pydicom.dataset.Dataset], None], optional - Requested procedures that are being fullfilled by creation of the + Requested procedures that are being fulfilled by creation of the SR document previous_versions: Union[List[pydicom.dataset.Dataset], None], optional Instances representing previous versions of the SR document diff --git a/src/highdicom/sr/templates.py b/src/highdicom/sr/templates.py index 484c2556..42681bf2 100644 --- a/src/highdicom/sr/templates.py +++ b/src/highdicom/sr/templates.py @@ -2350,7 +2350,7 @@ def __init__( "General Region of Interest Measurement Modifiers" for options) finding_sites: Union[Sequence[highdicom.sr.FindingSite], None], optional - Coded description of one or more anatomic locations corresonding + Coded description of one or more anatomic locations corresponding to the image region from which measurement was taken method: Union[highdicom.sr.CodedConcept, pydicom.sr.coding.Code, None], optional Measurement method (see @@ -3274,7 +3274,7 @@ def __init__( algorithm_id: Union[highdicom.sr.AlgorithmIdentification, None], optional Identification of algorithm used for making measurements finding_sites: Union[Sequence[highdicom.sr.FindingSite], None], optional - Coded description of one or more anatomic locations corresonding + Coded description of one or more anatomic locations corresponding to the image region from which measurement was taken session: Union[str, None], optional Description of the session diff --git a/src/highdicom/sr/value_types.py b/src/highdicom/sr/value_types.py index dfa07487..16a1958c 100644 --- a/src/highdicom/sr/value_types.py +++ b/src/highdicom/sr/value_types.py @@ -1458,7 +1458,7 @@ def __init__( Number of frame(s) to which the reference applies in case of a multi-frame image referenced_segment_numbers: Union[int, Sequence[int], None], optional - Number of segment(s) to which the refernce applies in case of a + Number of segment(s) to which the reference applies in case of a segmentation image relationship_type: Union[highdicom.sr.RelationshipTypeValues, str, None], optional Type of relationship with parent content item @@ -1702,7 +1702,7 @@ class Scoord3DContentItem(ContentItem): Note ---- Spatial coordinates are defined in the patient or specimen-based coordinate - system and have milimeter unit. + system and have millimeter unit. """ @@ -1955,7 +1955,7 @@ def __init__( referenced_waveform_channels: Union[Sequence[Tuple[int, int]], None], optional Pairs of waveform number (number of item in the Waveform Sequence) and channel definition number (number of item in the Channel - Defition Sequence) to which the reference applies in case of a + Definition Sequence) to which the reference applies in case of a multi-channel waveform relationship_type: Union[highdicom.sr.RelationshipTypeValues, str, None], optional Type of relationship with parent content item diff --git a/tests/test_ko.py b/tests/test_ko.py index d4ab94db..c88fdf4b 100644 --- a/tests/test_ko.py +++ b/tests/test_ko.py @@ -89,8 +89,8 @@ def test_construction(self): container = content[0] assert isinstance(container, ContainerContentItem) assert container.ContentTemplateSequence[0].TemplateIdentifier == '2010' - # Oberver Context (Person): 2 - # Oberver Context (Device): 3 + # Observer Context (Person): 2 + # Observer Context (Device): 3 # Description: 1 # Referenced Objects: 4 assert len(container.ContentSequence) == 10 From 03a546af8494c6cca33ef233764b6c3da97c54f3 Mon Sep 17 00:00:00 2001 From: Chris Bridge Date: Mon, 19 Jun 2023 11:44:57 -0400 Subject: [PATCH 6/7] Fixes to various VR flagged by tests --- src/highdicom/pm/sop.py | 8 +++++--- src/highdicom/pr/content.py | 2 +- src/highdicom/seg/sop.py | 23 +++++++++++++---------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/highdicom/pm/sop.py b/src/highdicom/pm/sop.py index ef29b73a..b1e5b9fa 100644 --- a/src/highdicom/pm/sop.py +++ b/src/highdicom/pm/sop.py @@ -737,9 +737,11 @@ def __init__( # Frame Content frame_content_item = Dataset() frame_content_item.DimensionIndexValues = [ - np.where( - (dimension_position_values[idx] == pos) - )[0][0] + 1 + int( + np.where( + (dimension_position_values[idx] == pos) + )[0][0] + 1 + ) for idx, pos in enumerate(plane_position_values[i]) ] diff --git a/src/highdicom/pr/content.py b/src/highdicom/pr/content.py index 48809dd1..715a8b2d 100644 --- a/src/highdicom/pr/content.py +++ b/src/highdicom/pr/content.py @@ -431,7 +431,7 @@ def __init__( raise ValueError( 'All coordinates in the bounding box must be non-negative.' ) - self.AnchorPoint = anchor_point + self.AnchorPoint = list(anchor_point) self.AnchorPointAnnotationUnits = units.value self.AnchorPointVisibility = 'Y' if anchor_point_visible else 'N' if units == AnnotationUnitsValues.DISPLAY: diff --git a/src/highdicom/seg/sop.py b/src/highdicom/seg/sop.py index bf16c5c2..ad87973a 100644 --- a/src/highdicom/seg/sop.py +++ b/src/highdicom/seg/sop.py @@ -1612,9 +1612,11 @@ def __init__( CoordinateSystemNames.SLIDE ): index_values = [ - np.where( - (dimension_position_values[idx] == pos) - )[0][0] + 1 + int( + np.where( + (dimension_position_values[idx] == pos) + )[0][0] + 1 + ) for idx, pos in enumerate( plane_position_values[j] ) @@ -1625,11 +1627,12 @@ def __init__( # Sequence points to (Image Position Patient) has a # value multiplicity greater than one. index_values = [ - np.where( - (dimension_position_values[idx] == pos).all( - axis=1 - ) - )[0][0] + 1 + int( + np.where( + (dimension_position_values[idx] == pos) + .all(axis=1) + )[0][0] + 1 + ) for idx, pos in enumerate( plane_position_values[j] ) @@ -1641,7 +1644,7 @@ def __init__( 'dimension index values: {}'.format(j, error) ) frame_content_item.DimensionIndexValues = ( - [segment_number] + index_values + [int(segment_number)] + index_values ) pffp_item.FrameContentSequence = [frame_content_item] if has_ref_frame_uid: @@ -1696,7 +1699,7 @@ def __init__( logger.warning('spatial locations not preserved') identification = Dataset() - identification.ReferencedSegmentNumber = segment_number + identification.ReferencedSegmentNumber = int(segment_number) pffp_item.SegmentIdentificationSequence = [ identification, ] From 3aa8ea6d974f74d63bcdb56c373e8337a019441f Mon Sep 17 00:00:00 2001 From: Chris Bridge Date: Mon, 19 Jun 2023 11:48:09 -0400 Subject: [PATCH 7/7] Exclude pydicom 2.4.0 in setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 857d77da..a1034d4c 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,7 @@ def get_version(): package_dir={'': 'src'}, python_requires='>=3.6', install_requires=[ - 'pydicom>=2.3.0', + 'pydicom>=2.3.0,!=2.4.0', 'numpy>=1.19', 'pillow>=8.3', 'pillow-jpls>=1.0',