Commit 9c1b7383879d1963e798bde002e1838bc7e96eef
1 parent
862aa895
Exists in
master
and in
6 other branches
ENH: Add new's itens
Showing
1 changed file
with
48 additions
and
1 deletions
Show diff stats
invesalius/reader/dicom.py
@@ -646,6 +646,23 @@ class Parser(): | @@ -646,6 +646,23 @@ class Parser(): | ||
646 | return data | 646 | return data |
647 | return "" | 647 | return "" |
648 | 648 | ||
649 | + def GetProtocolName(self): | ||
650 | + """ | ||
651 | + Return string containing the protocal name | ||
652 | + used in the acquisition | ||
653 | + | ||
654 | + DICOM standard tag (0x0018, 0x1030) was used. | ||
655 | + """ | ||
656 | + tag = gdcm.Tag(0x0018, 0x1030) | ||
657 | + ds = self.gdcm_reader.GetFile().GetDataSet() | ||
658 | + if ds.FindDataElement(tag): | ||
659 | + data = str(ds.GetDataElement(tag).GetValue()) | ||
660 | + if (data): | ||
661 | + return data | ||
662 | + return None | ||
663 | + | ||
664 | + def Get | ||
665 | + | ||
649 | def GetImageType(self): | 666 | def GetImageType(self): |
650 | """ | 667 | """ |
651 | Return list containing strings related to image origin. | 668 | Return list containing strings related to image origin. |
@@ -1396,6 +1413,33 @@ class Parser(): | @@ -1396,6 +1413,33 @@ class Parser(): | ||
1396 | return data | 1413 | return data |
1397 | return "unnamed" | 1414 | return "unnamed" |
1398 | 1415 | ||
1416 | + def GetImageTime(self): | ||
1417 | + """ | ||
1418 | + Return the image time. | ||
1419 | + DICOM standard tag (0x0008,0x0033) was used. | ||
1420 | + """ | ||
1421 | + tag = gdcm.Tag(0x0008, 0x0033) | ||
1422 | + ds = self.gdcm_reader.GetFile().GetDataSet() | ||
1423 | + if ds.FindDataElement(tag): | ||
1424 | + data = str(ds.GetDataElement(tag).GetValue()) | ||
1425 | + if (data): | ||
1426 | + return data | ||
1427 | + return "" | ||
1428 | + | ||
1429 | + def GetAcquisitionTime(self): | ||
1430 | + """ | ||
1431 | + Return the acquisition time. | ||
1432 | + DICOM standard tag (0x0008,0x032) was used. | ||
1433 | + """ | ||
1434 | + tag = gdcm.Tag(0x0008, 0x0032) | ||
1435 | + ds = self.gdcm_reader.GetFile().GetDataSet() | ||
1436 | + if ds.FindDataElement(tag): | ||
1437 | + data = str(ds.GetDataElement(tag).GetValue()) | ||
1438 | + if (data): | ||
1439 | + return data | ||
1440 | + return "" | ||
1441 | + | ||
1442 | + | ||
1399 | 1443 | ||
1400 | 1444 | ||
1401 | class DicomWriter: | 1445 | class DicomWriter: |
@@ -1698,7 +1742,7 @@ class Patient(object): | @@ -1698,7 +1742,7 @@ class Patient(object): | ||
1698 | class Acquisition(object): | 1742 | class Acquisition(object): |
1699 | 1743 | ||
1700 | def __init__(self): | 1744 | def __init__(self): |
1701 | - self.time = "12:34 AM" | 1745 | + pass |
1702 | 1746 | ||
1703 | def SetParser(self, parser): | 1747 | def SetParser(self, parser): |
1704 | self.patient_orientation = parser.GetImagePatientOrientation() | 1748 | self.patient_orientation = parser.GetImagePatientOrientation() |
@@ -1712,6 +1756,8 @@ class Acquisition(object): | @@ -1712,6 +1756,8 @@ class Acquisition(object): | ||
1712 | self.date = parser.GetAcquisitionDate() | 1756 | self.date = parser.GetAcquisitionDate() |
1713 | self.accession_number = parser.GetAccessionNumber() | 1757 | self.accession_number = parser.GetAccessionNumber() |
1714 | self.series_description = parser.GetSeriesDescription() | 1758 | self.series_description = parser.GetSeriesDescription() |
1759 | + self.time = parser.GetAcquisitionTime() | ||
1760 | + self.protocol_name = parser.GetProtocolName() | ||
1715 | 1761 | ||
1716 | class Image(object): | 1762 | class Image(object): |
1717 | 1763 | ||
@@ -1730,6 +1776,7 @@ class Image(object): | @@ -1730,6 +1776,7 @@ class Image(object): | ||
1730 | self.spacing = spacing = parser.GetPixelSpacing() | 1776 | self.spacing = spacing = parser.GetPixelSpacing() |
1731 | self.orientation_label = parser.GetImageOrientationLabel() | 1777 | self.orientation_label = parser.GetImageOrientationLabel() |
1732 | self.file = parser.filename | 1778 | self.file = parser.filename |
1779 | + self.time = parser.GetImageTime() | ||
1733 | 1780 | ||
1734 | if (parser.GetImageThickness()): | 1781 | if (parser.GetImageThickness()): |
1735 | try: | 1782 | try: |