Exemplo n.º 1
0
        //SeriesTagの取得
        public static void GetSeriesTag(string file, out SeriesTag tag)
        {
            tag = new SeriesTag();

            using (var dcm = new DicomData(file))
            {
                var dic = DicomTagDictionary.Open(dcm, DcmTag.ToTagArray(DCM.SERIES_TAG));

                tag.Modality          = dic.GetValue <string>(DcmTag.Modality.Tag, "");
                tag.SeriesDescription = dic.GetValue <string>(DcmTag.SeriesDescription.Tag, "");
                tag.SeriesNumber      = dic.GetValue <long>(DcmTag.SeriesNumber.Tag, 0);
                tag.NumberOfImages    = 1;

                if (dcm.Images.Load())
                {
                    tag.NumberOfFrames = dcm.Images.NumberOfFrame;
                }
            }
        }
Exemplo n.º 2
0
        //シリーズ一覧の取得
        public static void GetSeriesList(StudyKey key, out List <SeriesTag> tags)
        {
            tags = new List <SeriesTag>();

            using (var db = new TryDbConnection(settings))
            {
                using (var cmd = db.CreateCommand())
                {
                    var sb = new StringBuilder();
                    sb.Append("SELECT SeriesInstanceUID,SOPInstanceUID,Modality,SeriesDescription,SeriesNumber,NumberOfImages,NumberOfFrames,StorageID");
                    sb.Append(" FROM T_Series");
                    sb.Append(" WHERE StudyInstanceUID=@0");

                    cmd.CommandText = sb.ToString();
                    cmd.Add(key.StudyInstanceUID);

                    //シリーズ
                    using (var dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            //無視するモダリティ
                            if (Array.IndexOf(AppUtil.SkipModality, (string)dr["Modality"]) >= 0)
                            {
                                continue;
                            }

                            string seriesUid = (string)dr["SeriesInstanceUID"];
                            int    noi       = (int)dr["NumberOfImages"];
                            int    nof       = (int)dr["NumberOfFrames"];

                            int cnt = 0;
                            if (nof > noi)
                            {
                                //ウォーターラインのチェック
                                using (var cmd2 = db.CreateCommand())
                                {
                                    cmd2.CommandText = "SELECT COUNT(*) FROM T_Image WHERE StudyInstanceUID=@0 AND SeriesInstanceUID=@1";
                                    cmd2.Add(key.StudyInstanceUID);
                                    cmd2.Add(seriesUid);

                                    cnt = Convert.ToInt32(cmd2.ExecuteScalar());
                                }
                            }

                            //マルチフレームでない or 画像がない
                            if (cnt == 0)
                            {
                                var sekey = new SeriesKey()
                                {
                                    StudyInstanceUID  = key.StudyInstanceUID,
                                    SeriesInstanceUID = seriesUid,
                                    SOPInstanceUID    = (string)dr["SOPInstanceUID"],
                                    StorageID         = (string)dr["StorageID"],
                                    IsImage           = false
                                };

                                var tag = new SeriesTag();
                                tag.SeriesKey         = ConvertUtil.Serialize(sekey);
                                tag.Modality          = (string)dr["Modality"];
                                tag.SeriesDescription = (string)dr["SeriesDescription"];
                                tag.SeriesNumber      = (long)dr["SeriesNumber"];
                                tag.NumberOfImages    = noi;
                                tag.NumberOfFrames    = noi;

                                //ソート用
                                tag.SeriesInstanceUID = seriesUid;

                                //GSPS
                                using (var cmd3 = db.CreateCommand())
                                {
                                    cmd3.CommandText = "SELECT COUNT(*) FROM T_GSPS_R WHERE StudyInstanceUID=@0 AND ReferencedSeriesInstanceUID=@1";
                                    cmd3.Add(key.StudyInstanceUID);
                                    cmd3.Add(seriesUid);

                                    var gsps = Convert.ToInt32(cmd3.ExecuteScalar());
                                    tag.IsGSPS = gsps > 0 ? true : false;
                                }

                                tags.Add(tag);
                            }
                            else
                            {
                                //マルチフレーム
                                using (var cmd2 = db.CreateCommand())
                                {
                                    cmd2.CommandText = "SELECT SOPInstanceUID,InstanceNumber,NumberOfFrames,StorageID FROM T_Image WHERE StudyInstanceUID=@0 AND SeriesInstanceUID=@1";
                                    cmd2.Add(key.StudyInstanceUID);
                                    cmd2.Add(seriesUid);

                                    using (var dr2 = cmd2.ExecuteReader())
                                    {
                                        while (dr2.Read())
                                        {
                                            var sekey = new SeriesKey()
                                            {
                                                StudyInstanceUID  = key.StudyInstanceUID,
                                                SeriesInstanceUID = seriesUid,
                                                SOPInstanceUID    = (string)dr2["SOPInstanceUID"],
                                                StorageID         = (string)dr2["StorageID"],
                                                IsImage           = true
                                            };

                                            var tag = new SeriesTag();
                                            tag.SeriesKey         = ConvertUtil.Serialize(sekey);
                                            tag.Modality          = (string)dr["Modality"];
                                            tag.SeriesDescription = (string)dr["SeriesDescription"];
                                            tag.SeriesNumber      = (long)dr["SeriesNumber"];
                                            tag.NumberOfImages    = 1;
                                            tag.NumberOfFrames    = (int)dr2["NumberOfFrames"];

                                            //ソート用
                                            tag.SeriesInstanceUID = seriesUid;
                                            tag.SOPInstanceUID    = (string)dr2["SOPInstanceUID"];
                                            tag.InstanceNumber    = (long)dr2["InstanceNumber"];

                                            //GSPS
                                            using (var cmd3 = db.CreateCommand())
                                            {
                                                cmd3.CommandText = "SELECT COUNT(*) FROM T_GSPS_R WHERE StudyInstanceUID=@0 AND ReferencedSeriesInstanceUID=@1 AND ReferencedSOPInstanceUID=@2";
                                                cmd3.Add(key.StudyInstanceUID);
                                                cmd3.Add(seriesUid);
                                                cmd3.Add((string)dr2["SOPInstanceUID"]);

                                                var gsps = Convert.ToInt32(cmd3.ExecuteScalar());
                                                tag.IsGSPS = gsps > 0 ? true : false;
                                            }

                                            tags.Add(tag);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //ソート
            tags.Sort(new SeriesTagComparer());
        }
Exemplo n.º 3
0
        //シリーズ一覧の取得
        public static void GetSeriesList(StudyKey key, out List <SeriesTag> seTags)
        {
            seTags = new List <SeriesTag>();
            var tags = new List <SeriesTag>();

            using (var pc = new PacsComm())
            {
                DicomTagsResult ret = pc.CFindSeries(key.StudyInstanceUID);
                if (!ret.IsSuccess)
                {
                    LogUtil.Error("CFINDに失敗しました。");
                    return;
                }

                foreach (var dcmTag in ret.Tags)
                {
                    string mod = dcmTag.GetTagValue(DicomDic.Find("Modality").Tag);

                    //無視するモダリティ
                    if (Array.IndexOf(AppUtil.SkipModality, mod) >= 0)
                    {
                        continue;
                    }

                    var sekey = new SeriesKey()
                    {
                        StudyInstanceUID  = key.StudyInstanceUID,
                        SeriesInstanceUID = dcmTag.GetTagValue(DicomDic.Find("SeriesInstanceUID").Tag),
                        IsImage           = false,
                        IsPacsSearch      = true
                    };

                    var tag = new SeriesTag();
                    tag.SeriesKey = ConvertUtil.Serialize(sekey);
                    tag.Modality  = mod;
                    Int64.TryParse(dcmTag.GetTagValue(DicomDic.Find("SeriesNumber").Tag), out tag.SeriesNumber);
                    Int32.TryParse(dcmTag.GetTagValue(DicomDic.Find("NumberOfSeriesRelatedInstances").Tag), out tag.NumberOfImages);
                    tag.SeriesDescription = dcmTag.GetTagValue(DicomDic.Find("SeriesDescription").Tag);

                    //ソート用
                    tag.SeriesInstanceUID = dcmTag.GetTagValue(DicomDic.Find("SeriesInstanceUID").Tag);

                    tags.Add(tag);
                }
            }

            //ソート
            tags.Sort(new SeriesTagComparer());

            //重複チェック
            foreach (var tag in tags)
            {
                var sekey = ConvertUtil.Deserialize <SeriesKey>(tag.SeriesKey);

                bool chk = true;
                foreach (var setag in seTags)
                {
                    var sekey2 = ConvertUtil.Deserialize <SeriesKey>(setag.SeriesKey);

                    if (sekey.StudyInstanceUID == sekey2.StudyInstanceUID && sekey.SeriesInstanceUID == sekey2.SeriesInstanceUID)
                    {
                        chk = false;
                        break;
                    }
                }

                if (chk)
                {
                    seTags.Add(tag);
                }
            }
        }
Exemplo n.º 4
0
        //シリーズ一覧の取得
        public static void GetSeriesList(StudyKey key, out List <SeriesTag> tags)
        {
            tags = new List <SeriesTag>();

            var seriesQuery = new RBSeriesQuery();

            seriesQuery.is_filter_on = 1;
            seriesQuery.location     = Int32.Parse(key.StorageID);
            seriesQuery.StudyUID     = key.StudyInstanceUID;

            List <RBSeries> seriesList;

            if (!GetSeriesList(seriesQuery, out seriesList))
            {
                return;
            }

            //ソート
            seriesList.Sort((x, y) =>
            {
                int c = x.SeriesNo.CompareTo(y.SeriesNo);
                if (c == 0)
                {
                    return(x.SeriesUID.CompareTo(y.SeriesUID));
                }
                else
                {
                    return(c);
                }
            });

            foreach (var series in seriesList)
            {
                var imageQuery = new RBObjectQuery();
                imageQuery.is_filter_on = 1;
                imageQuery.location     = Int32.Parse(key.StorageID);
                imageQuery.StudyUID     = key.StudyInstanceUID;
                imageQuery.SeriesUID    = series.SeriesUID;

                List <RBImage> imageList;
                if (!GetImageList(imageQuery, out imageList))
                {
                    continue;
                }

                //ソート
                imageList.Sort((x, y) =>
                {
                    int c = x.ImageNo.CompareTo(y.ImageNo);
                    if (c == 0)
                    {
                        return(x.InstUID.CompareTo(y.InstUID));
                    }
                    else
                    {
                        return(c);
                    }
                });

                int nof = 0;
                foreach (var image in imageList)
                {
                    nof += image.NoOfFrames;
                }

                if (nof == 0)
                {
                    var sekey = new SeriesKey()
                    {
                        StudyInstanceUID  = key.StudyInstanceUID,
                        SeriesInstanceUID = series.SeriesUID,
                        SOPInstanceUID    = null,
                        StorageID         = key.StorageID,
                        IsImage           = false
                    };

                    var tag = new SeriesTag();
                    tag.SeriesKey         = ConvertUtil.Serialize(sekey); //new RsSeriesKey(key, series.SeriesUID, series.Modality, series.SeriesDesc, series.SeriesNo);
                    tag.SeriesNumber      = series.SeriesNo;
                    tag.Modality          = series.Modality;
                    tag.SeriesDescription = series.SeriesDesc;
                    tag.NumberOfImages    = series.no_im;
                    tag.NumberOfFrames    = nof;

                    tags.Add(tag);
                }
                else
                {
                    //イメージ
                    foreach (var image in imageList)
                    {
                        var sekey = new SeriesKey()
                        {
                            StudyInstanceUID  = key.StudyInstanceUID,
                            SeriesInstanceUID = series.SeriesUID,
                            SOPInstanceUID    = image.InstUID,
                            StorageID         = key.StorageID,
                            IsImage           = true
                        };

                        var tag = new SeriesTag();
                        tag.SeriesKey         = ConvertUtil.Serialize(sekey); //new RsSeriesKey(key, series.SeriesUID, image.InstUID, image.NoOfFrames);
                        tag.SeriesNumber      = series.SeriesNo;
                        tag.Modality          = series.Modality;
                        tag.SeriesDescription = series.SeriesDesc;
                        tag.NumberOfImages    = 1;
                        tag.NumberOfFrames    = image.NoOfFrames;

                        tags.Add(tag);
                    }
                }
            }
        }