示例#1
0
        public MediaFileSet Read(string filename)
        {
            DicomFile file = new DicomFile(filename);

            file.Load(DicomTags.SopClassUid, DicomReadOptions.Default);

            if (file.MediaStorageSopClassUid == SopClass.MediaStorageDirectoryStorageUid)
            {
                return(DicomDirFileSet.Load(filename));
            }
            else
            {
                if (file.DataSet[DicomTags.SopClassUid] != SopClass.MediaStorageDirectoryStorageUid)
                {
                    return(null);
                }

                return(DicomDirFileSet.Load(filename));
            }
        }
示例#2
0
        public static DicomDirFileSet Load(string filename)
        {
            var dicomDirectory = new DicomDirectory(String.Empty);

            dicomDirectory.Load(filename);

            var directoryName = Path.GetDirectoryName(filename);

            DicomDirFileSet tmp = new DicomDirFileSet(dicomDirectory.FileSetId);

            foreach (var item in dicomDirectory.RootDirectoryRecordCollection)
            {
                if (item.DirectoryRecordType != DirectoryRecordType.Patient)
                {
                    throw new InvalidOperationException();
                }

                foreach (var subItem in item.LowerLevelDirectoryRecordCollection)
                {
                    if (subItem.DirectoryRecordType == DirectoryRecordType.Study)
                    {
                        try
                        {
                            tmp.Studies.Add(new LocalStudy(subItem, tmp, directoryName));
                        }
                        catch (Exception)
                        {
                            // TODO
                            Platform.Log(LogLevel.Warn, "invaild data when load dicom dir");
                        }
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
            }

            return(tmp);
        }