nbiatoolkit.dicomtags

Submodules

Package Contents

Functions

convert_element_to_int(→ int)

Converts a DICOM element string representation to an integer.

convert_int_to_element(→ str)

Converts a combined integer into a DICOM element string representation.

LOOKUP_TAG(→ int)

Looks up a DICOM tag based on the keyword. A wrapper around the pydicom's tag_for_keyword function.

element_VR_lookup(→ tuple[int, str])

Looks up the VR (Value Representation) for a given DICOM element.

getSeriesModality(→ str)

Retrieves the modality of a DICOM series.

subsetSeriesTags(→ pandas.DataFrame)

Subsets a DataFrame containing DICOM series tags based on the start and end elements.

getReferencedFrameOfReferenceSequence(→ pandas.DataFrame)

Given a DataFrame containing DICOM series tags, retrieves the ReferencedFrameOfReferenceSequence.

getReferencedSeriesUIDS(→ List[str])

Given a DataFrame containing DICOM series tags, retrieves the SeriesInstanceUIDs of the referenced series.

extract_ROI_info(→ dict[str, dict[str, str]])

Extracts ROI information from the StructureSetROISequence.

nbiatoolkit.dicomtags.convert_element_to_int(element_str: str) int[source]

Converts a DICOM element string representation to an integer.

Parameters:

element_str (str) – The DICOM element string representation.

Returns:

The converted integer value.

Return type:

int

Examples

>>> convert_element_to_int('(0028,0010)')
2621456
Raises:

ValueError – If the element format is invalid.

nbiatoolkit.dicomtags.convert_int_to_element(combined_int: int) str[source]

Converts a combined integer into a DICOM element string representation.

Parameters:

combined_int (int) – The combined integer to be converted.

Returns:

The DICOM element string representation of the combined integer.

Return type:

str

Examples

>>> convert_int_to_element(0x00080060)
(0008,0060)
>>> convert_int_to_element(524384)
(0008,0060)
nbiatoolkit.dicomtags.LOOKUP_TAG(keyword: str) int[source]

Looks up a DICOM tag based on the keyword. A wrapper around the pydicom’s tag_for_keyword function.

nbiatoolkit.dicomtags.element_VR_lookup(element_str: str) tuple[int, str][source]

Looks up the VR (Value Representation) for a given DICOM element.

Parameters:

element_str (str) – The DICOM element as a string.

Returns:

A tuple containing the combined integer representation of the element and its VR.

Return type:

tuple[int, str]

nbiatoolkit.dicomtags.getSeriesModality(series_tags_df: pandas.DataFrame) str[source]

Retrieves the modality of a DICOM series.

Parameters:

series_tags_df (pd.DataFrame) – A DataFrame containing DICOM series tags.

Returns:

The modality of the DICOM series.

Return type:

str

Raises:

ValueError – If the modality tag is not found in the DICOM dictionary.

nbiatoolkit.dicomtags.subsetSeriesTags(series_tags_df: pandas.DataFrame, element: str) pandas.DataFrame[source]

Subsets a DataFrame containing DICOM series tags based on the start and end elements.

Parameters:
  • series_tags_df (pd.DataFrame) – A DataFrame containing DICOM series tags.

  • element (str) – The element to subset the DataFrame.

Returns:

A DataFrame containing the subset of the series tags.

Return type:

pd.DataFrame

Raises:
  • ValueError – If the element is not found in the series tags.

  • ValueError – If more than two elements are found in the series tags.

nbiatoolkit.dicomtags.getReferencedFrameOfReferenceSequence(series_tags_df: pandas.DataFrame) pandas.DataFrame[source]

Given a DataFrame containing DICOM series tags, retrieves the ReferencedFrameOfReferenceSequence.

Parameters:

series_tags_df (pd.DataFrame) – A DataFrame containing DICOM series tags.

Returns:

A DataFrame containing the ReferencedFrameOfReferenceSequence.

Return type:

pd.DataFrame

Raises:

ValueError – If the series is not an RTSTRUCT.

nbiatoolkit.dicomtags.getReferencedSeriesUIDS(series_tags_df: pandas.DataFrame) List[str][source]

Given a DataFrame containing DICOM series tags, retrieves the SeriesInstanceUIDs of the referenced series. Useful for RTSTRUCT DICOM files to find the series that the RTSTRUCT references. TODO:: implement SEG and RTDOSE

Parameters:

series_tags_df (pd.DataFrame) – A DataFrame containing DICOM series tags.

Returns:

A list of SeriesInstanceUIDs of the referenced series.

Return type:

List[str]

Raises:

ValueError – If the series is not an RTSTRUCT.

nbiatoolkit.dicomtags.extract_ROI_info(StructureSetROISequence) dict[str, dict[str, str]][source]

Extracts ROI information from the StructureSetROISequence.

Parameters:

StructureSetROISequence (pandas.DataFrame) – A pandas DataFrame representing the StructureSetROISequence.

Returns:

A dictionary containing ROI information, where the key is the ROI number and the value is the ROI information.

Return type:

dict[str, dict[str, str]]

Raises:

ValueError – If ROI Number is not found in the StructureSetROISequence.