當前位置: 首頁>>代碼示例>>Python>>正文


Python Dataset.AccessionNumber方法代碼示例

本文整理匯總了Python中dicom.dataset.Dataset.AccessionNumber方法的典型用法代碼示例。如果您正苦於以下問題:Python Dataset.AccessionNumber方法的具體用法?Python Dataset.AccessionNumber怎麽用?Python Dataset.AccessionNumber使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dicom.dataset.Dataset的用法示例。


在下文中一共展示了Dataset.AccessionNumber方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __downloadFromDali

# 需要導入模塊: from dicom.dataset import Dataset [as 別名]
# 或者: from dicom.dataset.Dataset import AccessionNumber [as 別名]
    def __downloadFromDali(self, foldername,
                           ptid,
                           series_description,
                           accession_number):

        print "making dir ", os.path.join(
            constants.dicom_dir, foldername)
        os.mkdir(os.path.join(
            constants.dicom_dir, foldername))

        def OnAssociateResponse(association):
            print "Association response received"

        def OnReceiveStore(SOPClass, DS):
            file_meta = Dataset()
            file_meta.MediaStorageSOPClassUID = DS.SOPClassUID
            file_meta.MediaStorageSOPInstanceUID = DS.SOPInstanceUID
            file_meta.ImplementationClassUID = DS.SOPClassUID
            filename = os.path.join(
                constants.dicom_dir, foldername, DS.SOPInstanceUID + ".dcm")
            print "making file ", filename
            ds = FileDataset(
                filename, {}, file_meta=file_meta, preamble="\0" * 128)
            ds.update(DS)
            ds.is_little_endian = True
            ds.is_implicit_VR = True

            ds.save_as(filename)
            # print "File %s written" % filename
            # must return appropriate status
            return SOPClass.Success

        self.MyAE.OnAssociateResponse = OnAssociateResponse
        self.MyAE.OnReceiveStore = OnReceiveStore

        # perform a DICOM ECHO
        try:
            print "DICOM Echo ... ",
            st = self.assoc.VerificationSOPClass.SCU(1)
            print 'done with status "%s"' % st
        except Exception as e:
            raise RuntimeError(
                "Error when testing connectiont to DALI: %s" % e)

        try:
            print "DICOM FindSCU ... ",
            d = Dataset()
            d.PatientsName = '*'
            d.PatientID = ptid
            d.SeriesDescription = series_description
            d.AccessionNumber = accession_number
            d.StudyInstanceUID = "*"
            d.SeriesInstanceUID = "*"
            d.QueryRetrieveLevel = "SERIES"
            st = self.assoc.PatientRootFindSOPClass.SCU(d, 1)
            print 'done with status "%s"' % st

        except Exception as e:
            raise RuntimeError(
                "Error when searching patient data from DALI: %s" % e)

        try:
            SSUIDs = [(d[1].StudyInstanceUID, d[1].SeriesInstanceUID)
                      for d in st
                      if isinstance(d[1],
                                    Dataset) and d[1].keys() != []]
            print SSUIDs
            if(SSUIDs == []):
                raise RuntimeError("No patient data matching query")
        except Exception as e:
            raise RuntimeError("Error when quering DALI: %s" % e)

        # send dataset using RTPlanStorageSOPClass
        for SSUID in SSUIDs[0:1]:
            try:
                print "DICOM GetSCU ... ",
                d = Dataset()
                d.QueryRetrieveLevel = "SERIES"
                d.StudyInstanceUID = SSUID[0]
                d.SeriesInstanceUID = SSUID[1]
                d.SeriesDescription = series_description
                d.SeriesDescription = accession_number
                d.PatientID = ptid
                st = self.assoc.PatientRootGetSOPClass.SCU(d, 1)
            except Exception as e:
                raise RuntimeError(
                    "Error when retrieving patient data from DALI: %s" % e)
開發者ID:wonkykludge,項目名稱:fsspmnl_webinterface,代碼行數:89,代碼來源:views.py


注:本文中的dicom.dataset.Dataset.AccessionNumber方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。