Commit 3ec3d69b2db78a540c6b22dbec6c33fdc60f9fec

Authored by Paulo Henrique Junqueira Amorim
1 parent 1702e940

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 124 return int(str(data))
125 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 141 def GetAcquisitionTime(self):
128 142 """
129 143 Return string containing the acquisition time using the
... ... @@ -582,16 +596,16 @@ class Parser():
582 596 return data
583 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 604 Return None if field is not defined.
590 605  
591 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 609 ds = self.gdcm_reader.GetFile().GetDataSet()
596 610 if ds.FindDataElement(tag):
597 611 data = str(ds.GetDataElement(tag).GetValue())
... ... @@ -599,7 +613,8 @@ class Parser():
599 613 return data
600 614 return ""
601 615  
602   - def GetPhysicianAddress(self):
  616 +
  617 + def GetPhysicianReferringAddress(self):
603 618 """
604 619 Return string containing physician's address.
605 620 Return None if field is not defined.
... ... @@ -614,7 +629,7 @@ class Parser():
614 629 return data
615 630 return None
616 631  
617   - def GetPhysicianTelephone(self):
  632 + def GetPhysicianeReferringTelephone(self):
618 633 """
619 634 Return string containing physician's telephone.
620 635 Return None if field is not defined.
... ... @@ -679,6 +694,20 @@ class Parser():
679 694 return data
680 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 711 def GetStudyInstanceUID(self):
683 712 """
684 713 Return string containing Unique Identifier of the
... ... @@ -1655,8 +1684,13 @@ class Patient(object):
1655 1684  
1656 1685 def SetParser(self, parser):
1657 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 1694 class Acquisition(object):
1661 1695  
1662 1696 def __init__(self):
... ... @@ -1669,7 +1703,13 @@ class Acquisition(object):
1669 1703 self.serie_number = parser.GetImageSeriesNumber()
1670 1704 self.id_study = parser.GetStudyID()
1671 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 1713 class Image(object):
1674 1714  
1675 1715 def __init__(self):
... ... @@ -1684,30 +1724,28 @@ class Image(object):
1684 1724 self.position = [1, 1, 1]
1685 1725  
1686 1726 self.number = parser.GetImageNumber()
1687   - print "*****************"
1688 1727 self.spacing = spacing = parser.GetPixelSpacing()
1689   - print "Spacing:", spacing
1690 1728 self.orientation_label = parser.GetImageOrientationLabel()
1691 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 1747 try:
1711 1748 self.type = parser.GetImageType()[2]
1712 1749 except(IndexError):
1713 1750 self.type = None
  1751 +
... ...