Example #1
0
        private static void CreateSeries(string studyInstanceUid, string modality)
        {
            var    db     = FilmingDbOperation.Instance.FilmingDbWrapper;
            Series series = db.CreateSeries();

            SeriesInstanceUid         = series.SeriesInstanceUID;
            series.StudyInstanceUIDFk = studyInstanceUid;
            // new seriesNumber equals the max seriesNumber of exist series add one
            _seriesNumber            = Convert.ToInt32(FilmingHelper.GetSerieNumber(studyInstanceUid)) + 1;
            series.SeriesNumber      = _seriesNumber;
            series.SeriesDescription = Printers.Instance.NewSeriesDescription;
            series.Modality          = modality;

            if (studyInstanceUid == FilmingHelper.StarsString)
            {
                return;
            }


            //check whether disk space is enough
            ICommunicationProxy pCommProxy = FilmingViewerContainee.Main.GetCommunicationProxy();
            var target = new SystemResManagerProxy(pCommProxy);

            if (!target.HaveEnoughSpace())
            {
                Logger.LogWarning("No enough disk space, so Electronic Image Series will not be created");
                //FilmingViewerContainee.ShowStatusWarning("UID_Filming_No_Enough_Disk_Space_To_Create_Electronic_Image_Series");
                FilmingViewerContainee.Main.ShowStatusWarning("UID_Filming_No_Enough_Disk_Space_To_Create_Electronic_Image_Series");
                return;
            }

            series.Save();
        }
Example #2
0
 public static void ModifyStringDicomElement(DicomAttributeCollection dataHeader, Tag stringTagName, string tagValue)
 {
     if (dataHeader.Contains(stringTagName))
     {
         dataHeader.RemoveDicomAttribute(stringTagName);
     }
     FilmingHelper.InsertStringDicomElement(dataHeader, stringTagName, tagValue);
 }
Example #3
0
        private static void FillTags(IDictionary <uint, string> dicomHeader, DicomAttributeCollection dataHeader)
        {
            //0. 测试代码写在什么地方?

            //1. 读取tags配置文件,获取所有的tag
            //放置在静态构造函数之中//var tags = GetTagsFromConfigFile();

            //2.查询dicomHeader填入所有的值
            foreach (var tag in _tags)
            {
                string tagValue = dicomHeader.ContainsKey(tag) ? dicomHeader[tag] : string.Empty;

                //Tag tagEnum;
                //Enum.Parse(typeof (Tag), tag, true);
                //if(Enum.TryParse(tag, true, out tagEnum))
                FilmingHelper.InsertStringDicomElement(dataHeader, tag, tagValue);
            }
        }
Example #4
0
        /// <summary>
        /// Assume that cell is not empty
        /// </summary>
        /// <param name="cell"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public static DicomAttributeCollection SaveCellAsDataHeader(MedViewerControlCell cell, int index)
        {
            try
            {
                Logger.LogFuncUp();

                Debug.Assert(cell != null && cell.Image != null && cell.Image.CurrentPage != null);

                var dataHeader = new DicomAttributeCollection();

                var displayData = cell.Image.CurrentPage;
                var dicomHeader = displayData.ImageHeader.DicomHeader;

                var uidManager = McsfDatabaseDicomUIDManagerFactory.Instance().CreateUIDManager();
                if (index == 0)
                {
                    SeriesInstanceUid = uidManager.CreateSeriesUID("1", "2", ""); //seriesUID; //
                    ClearSeries(dicomHeader);
                }

                //if (displayData.PixelData == null) return null;

                var pixelData = displayData.PixelData;
                if (pixelData == null)
                {
                    pixelData = new byte[displayData.ImageDataLength];
                    Marshal.Copy(displayData.ImageDataPtr, pixelData, 0, displayData.ImageDataLength);
                }

                var element = DicomAttribute.CreateAttribute(Tag.PixelData, VR.OB);
                if (!element.SetBytes(0, pixelData))
                {
                    Logger.LogWarning("Failed to Insert NULL  image Data to Data header");
                }
                dataHeader.AddDicomAttribute(element);

                FillTags(dicomHeader, dataHeader);

                //1. need to fill seriesDescription, from configuration, Default value is 3D-1
                FilmingHelper.InsertStringDicomElement(dataHeader, Tag.SeriesDescription, Printers.Instance.NewSeriesDescription);

                //2. remove wrong tag
                dataHeader.RemoveDicomAttribute(Tag.SmallestImagePixelValue);
                dataHeader.RemoveDicomAttribute(Tag.LargestImagePixelValue);

                //3. update some tag
                dataHeader.RemoveDicomAttribute(Tag.InstanceNumber);
                FilmingHelper.InsertStringDicomElement(dataHeader, Tag.InstanceNumber, "" + (index + 1));
                dataHeader.RemoveDicomAttribute(Tag.SeriesNumber);
                FilmingHelper.InsertStringDicomElement(dataHeader, Tag.SeriesNumber, "" + _seriesNumber);
                dataHeader.RemoveDicomAttribute(Tag.SeriesInstanceUid);
                FilmingHelper.InsertStringDicomElement(dataHeader, Tag.SeriesInstanceUid, SeriesInstanceUid);
                dataHeader.RemoveDicomAttribute(Tag.SOPInstanceUID);

                FilmingHelper.InsertStringDicomElement(dataHeader, Tag.SOPInstanceUID, uidManager.CreateImageUID(""));

                var ww = FilmingHelper.GetTagValueFrom(dataHeader, ServiceTagName.WindowWidth);
                dataHeader.RemoveDicomAttribute(Tag.WindowWidth);
                if (dicomHeader.ContainsKey(ServiceTagName.WindowWidth))
                {
                    if (!string.IsNullOrWhiteSpace(ww))
                    {
                        FilmingHelper.InsertStringArrayDicomElement(dataHeader, Tag.WindowWidth, dicomHeader[ServiceTagName.WindowWidth]);
                    }
                }

                var wc = FilmingHelper.GetTagValueFrom(dataHeader, ServiceTagName.WindowCenter);
                dataHeader.RemoveDicomAttribute(Tag.WindowCenter);
                if (dicomHeader.ContainsKey(ServiceTagName.WindowCenter))
                {
                    if (!string.IsNullOrWhiteSpace(wc))
                    {
                        FilmingHelper.InsertStringArrayDicomElement(dataHeader, Tag.WindowCenter, dicomHeader[ServiceTagName.WindowCenter]);
                    }
                }

                if (dicomHeader.ContainsKey(ServiceTagName.ImageType))
                {
                    dataHeader.RemoveDicomAttribute(Tag.ImageType);
                    FilmingHelper.InsertStringArrayDicomElement(dataHeader, Tag.ImageType, dicomHeader[ServiceTagName.ImageType]);
                }

                ////DICOM File Meta Information
                ////FillDicomFileMetaInformationTags(dataHeader);

                ////Patient Module
                //FillPatientModuleTags(dataHeader, dicomHeader);

                ////General Study Module
                //FillGeneralStudyModuleTags(dataHeader, dicomHeader);

                ////Patient Study Module
                //FillPatientStudyModuleTags(dataHeader, dicomHeader);

                ////General Series Module
                //FillGeneralSeriesModuleTags(dataHeader, dicomHeader);

                ////General Equipment Module

                //////SC Equipment Module
                ////FillSCEquipmentModuleTags(dataHeader);

                ////General Image Module
                //FillGeneralImageModuleTags(dataHeader, index, dicomHeader);

                //Image Pixel Module
                //FilmingHelper.AddConstDICOMAttributes(dataHeader);
                //FilmingHelper.InsertUInt16DicomElement(dataHeader, Tag.Columns, (ushort)imageWidth);
                //FilmingHelper.InsertUInt16DicomElement(dataHeader, Tag.Rows, (ushort)imageHeight);


                ////SC Image Module
                ////FillSCImageModuleTags(dataHeader);

                ////VOI LUT Module
                //FillVoilutMacroTags(dataHeader, dicomHeader);

                ////SOP Common Module
                //FillSopCommonModuleTags(dataHeader, dicomHeader);

                Logger.LogFuncDown();
                return(dataHeader);
            }
            catch (Exception ex)
            {
                Logger.LogFuncException(ex.Message + ex.StackTrace);
                return(null);
            }
        }