Commit 3ec3d69b2db78a540c6b22dbec6c33fdc60f9fec
1 parent
1702e940
Exists in
master
and in
68 other branches
ENH: Add new's DICOM's tags
Showing
1 changed file
with
66 additions
and
28 deletions
Show diff stats
invesalius/reader/dicom.py
@@ -124,6 +124,20 @@ class Parser(): | @@ -124,6 +124,20 @@ class Parser(): | ||
124 | return int(str(data)) | 124 | return int(str(data)) |
125 | return None | 125 | return None |
126 | 126 | ||
127 | + def GetAccessionNumber(self): | ||
128 | + """ | ||
129 | + Return integer related to acession number | ||
130 | + | ||
131 | + DICOM standard tag (0x0008, 0x0050) was used. | ||
132 | + """ | ||
133 | + tag = gdcm.Tag(0x0008, 0x0050) | ||
134 | + ds = self.gdcm_reader.GetFile().GetDataSet() | ||
135 | + if ds.FindDataElement(tag): | ||
136 | + data = ds.GetDataElement(tag).GetValue() | ||
137 | + if (data): | ||
138 | + return int(str(data)) | ||
139 | + return None | ||
140 | + | ||
127 | def GetAcquisitionTime(self): | 141 | def GetAcquisitionTime(self): |
128 | """ | 142 | """ |
129 | Return string containing the acquisition time using the | 143 | Return string containing the acquisition time using the |
@@ -582,16 +596,16 @@ class Parser(): | @@ -582,16 +596,16 @@ class Parser(): | ||
582 | return data | 596 | return data |
583 | return None | 597 | return None |
584 | 598 | ||
585 | - def GetPhysicianName(self): | 599 | + |
600 | + def GetPhysicianReferringName(self): | ||
586 | """ | 601 | """ |
587 | - Return string containing patient's primary (reffering) | ||
588 | - physician. | 602 | + Return string containing physician |
603 | + of the patient. | ||
589 | Return None if field is not defined. | 604 | Return None if field is not defined. |
590 | 605 | ||
591 | DICOM standard tag (0x0008, 0x0090) was used. | 606 | DICOM standard tag (0x0008, 0x0090) was used. |
592 | """ | 607 | """ |
593 | - #tag = gdcm.Tag(0x0008, 0x0090) | ||
594 | - tag = gdcm.Tag(0x0008,0x1060) | 608 | + tag = gdcm.Tag(0x0008,0x0090) |
595 | ds = self.gdcm_reader.GetFile().GetDataSet() | 609 | ds = self.gdcm_reader.GetFile().GetDataSet() |
596 | if ds.FindDataElement(tag): | 610 | if ds.FindDataElement(tag): |
597 | data = str(ds.GetDataElement(tag).GetValue()) | 611 | data = str(ds.GetDataElement(tag).GetValue()) |
@@ -599,7 +613,8 @@ class Parser(): | @@ -599,7 +613,8 @@ class Parser(): | ||
599 | return data | 613 | return data |
600 | return "" | 614 | return "" |
601 | 615 | ||
602 | - def GetPhysicianAddress(self): | 616 | + |
617 | + def GetPhysicianReferringAddress(self): | ||
603 | """ | 618 | """ |
604 | Return string containing physician's address. | 619 | Return string containing physician's address. |
605 | Return None if field is not defined. | 620 | Return None if field is not defined. |
@@ -614,7 +629,7 @@ class Parser(): | @@ -614,7 +629,7 @@ class Parser(): | ||
614 | return data | 629 | return data |
615 | return None | 630 | return None |
616 | 631 | ||
617 | - def GetPhysicianTelephone(self): | 632 | + def GetPhysicianeReferringTelephone(self): |
618 | """ | 633 | """ |
619 | Return string containing physician's telephone. | 634 | Return string containing physician's telephone. |
620 | Return None if field is not defined. | 635 | Return None if field is not defined. |
@@ -679,6 +694,20 @@ class Parser(): | @@ -679,6 +694,20 @@ class Parser(): | ||
679 | return data | 694 | return data |
680 | return None | 695 | return None |
681 | 696 | ||
697 | + def GetSeriesDescription(self): | ||
698 | + """ | ||
699 | + Return string containing Series description. | ||
700 | + | ||
701 | + DICOM tag (0x0008, 0x1030). Cannot be edited. | ||
702 | + """ | ||
703 | + tag = gdcm.Tag(0x0008, 0x1030) | ||
704 | + ds = self.gdcm_reader.GetFile().GetDataSet() | ||
705 | + if ds.FindDataElement(tag): | ||
706 | + data = str(ds.GetDataElement(tag).GetValue()) | ||
707 | + if (data): | ||
708 | + return data | ||
709 | + return None | ||
710 | + | ||
682 | def GetStudyInstanceUID(self): | 711 | def GetStudyInstanceUID(self): |
683 | """ | 712 | """ |
684 | Return string containing Unique Identifier of the | 713 | Return string containing Unique Identifier of the |
@@ -1655,8 +1684,13 @@ class Patient(object): | @@ -1655,8 +1684,13 @@ class Patient(object): | ||
1655 | 1684 | ||
1656 | def SetParser(self, parser): | 1685 | def SetParser(self, parser): |
1657 | self.name = parser.GetPatientName() | 1686 | self.name = parser.GetPatientName() |
1658 | - self.physician = parser.GetPhysicianName() | ||
1659 | - | 1687 | + self.id = parser.GetPatientID() |
1688 | + self.age = parser.GetPatientAge() | ||
1689 | + self.birthdate = parser.GetPatientBirthDate() | ||
1690 | + self.gender = parser.GetPatientGender() | ||
1691 | + self.physician = parser.GetPhysicianReferringName() | ||
1692 | + | ||
1693 | + | ||
1660 | class Acquisition(object): | 1694 | class Acquisition(object): |
1661 | 1695 | ||
1662 | def __init__(self): | 1696 | def __init__(self): |
@@ -1669,7 +1703,13 @@ class Acquisition(object): | @@ -1669,7 +1703,13 @@ class Acquisition(object): | ||
1669 | self.serie_number = parser.GetImageSeriesNumber() | 1703 | self.serie_number = parser.GetImageSeriesNumber() |
1670 | self.id_study = parser.GetStudyID() | 1704 | self.id_study = parser.GetStudyID() |
1671 | self.modality = parser.GetAcquisitionModality() | 1705 | self.modality = parser.GetAcquisitionModality() |
1672 | - | 1706 | + self.study_description = parser.GetStudyDescription() |
1707 | + self.acquisition_date = parser.GetAcquisitionDate() | ||
1708 | + self.institution = parser.GetInstitutionName() | ||
1709 | + self.date = parser.GetAcquisitionDate() | ||
1710 | + self.acession_number = parser.GetAccessionNumber() | ||
1711 | + self.series_description = parser.GetSeriesDescription() | ||
1712 | + | ||
1673 | class Image(object): | 1713 | class Image(object): |
1674 | 1714 | ||
1675 | def __init__(self): | 1715 | def __init__(self): |
@@ -1684,30 +1724,28 @@ class Image(object): | @@ -1684,30 +1724,28 @@ class Image(object): | ||
1684 | self.position = [1, 1, 1] | 1724 | self.position = [1, 1, 1] |
1685 | 1725 | ||
1686 | self.number = parser.GetImageNumber() | 1726 | self.number = parser.GetImageNumber() |
1687 | - print "*****************" | ||
1688 | self.spacing = spacing = parser.GetPixelSpacing() | 1727 | self.spacing = spacing = parser.GetPixelSpacing() |
1689 | - print "Spacing:", spacing | ||
1690 | self.orientation_label = parser.GetImageOrientationLabel() | 1728 | self.orientation_label = parser.GetImageOrientationLabel() |
1691 | self.file = parser.filename | 1729 | self.file = parser.filename |
1692 | 1730 | ||
1693 | - if self.spacing: | ||
1694 | - print "Thickness:", parser.GetImageThickness() | ||
1695 | - # If the image is "alone", we set thickness as z axis | ||
1696 | - if (parser.GetImageThickness()): | ||
1697 | - spacing.append(parser.GetImageThickness()) | ||
1698 | - else: | ||
1699 | - try: | ||
1700 | - spacing.append(1.5) | ||
1701 | - except(AttributeError): | ||
1702 | - spacing = [1, 1, 1] | ||
1703 | - | ||
1704 | - # If there are too many float digits | ||
1705 | - spacing[0] = round(spacing[0],2) | ||
1706 | - spacing[1] = round(spacing[1],2) | ||
1707 | - spacing[2] = round(spacing[2],2) | ||
1708 | - self.spacing = spacing | 1731 | + if (parser.GetImageThickness()): |
1732 | + try: | ||
1733 | + spacing.append(parser.GetImageThickness()) | ||
1734 | + except(AttributeError): | ||
1735 | + spacing = [1, 1, 1] | ||
1736 | + else: | ||
1737 | + try: | ||
1738 | + spacing.append(1.5) | ||
1739 | + except(AttributeError): | ||
1740 | + spacing = [1, 1, 1] | ||
1741 | + | ||
1742 | + spacing[0] = round(spacing[0],2) | ||
1743 | + spacing[1] = round(spacing[1],2) | ||
1744 | + spacing[2] = round(spacing[2],2) | ||
1745 | + self.spacing = spacing | ||
1709 | 1746 | ||
1710 | try: | 1747 | try: |
1711 | self.type = parser.GetImageType()[2] | 1748 | self.type = parser.GetImageType()[2] |
1712 | except(IndexError): | 1749 | except(IndexError): |
1713 | self.type = None | 1750 | self.type = None |
1751 | + |