コード例 #1
0
ファイル: JobBuilder.cs プロジェクト: mh-cad/vistarsier
        /// <summary>
        /// Find study series (only one) that match the selection critera and add details to the study
        /// </summary>
        /// <param name="study"></param>
        /// <param name="criteria"></param>
        /// <param name="localNode"></param>
        /// <param name="sourceNode"></param>
        /// <returns></returns>
        private IDicomStudy AddMatchingSeriesToStudy(
            IDicomStudy study, IEnumerable <SeriesSelectionCriteria> criteria, DicomService dicomSource)
        {
            var allSeries = dicomSource.GetSeriesForStudy(study.StudyInstanceUid);
            var criterion = criteria.FirstOrDefault(c => !string.IsNullOrEmpty(c.SeriesDescription));

            if (criterion == null)
            {
                study.Series.ToList().AddRange(allSeries);
            }
            else
            {
                var matchedSeries = allSeries.FirstOrDefault(series =>
                                                             _valueComparer.CompareStrings(
                                                                 series.SeriesDescription, criterion.SeriesDescription,
                                                                 criterion.SeriesDescriptionOperand, criterion.SeriesDescriptionDelimiter));

                if (matchedSeries != null)
                {
                    study.Series.Add(matchedSeries);
                }
            }

            return(study);
        }
コード例 #2
0
ファイル: JobBuilder.cs プロジェクト: mh-cad/vistarsier
        private string GetReferenceSeriesForRegistration(Job job, IEnumerable <IDicomStudy> allStudiesForPatient, DicomService dicomSource)
        {
            var studiesForPatient = allStudiesForPatient.ToList();

            if (string.IsNullOrEmpty(job.Attempt.ReferenceSeries))
            {
                job.Attempt.ReferenceSeries = FindReferenceSeriesInPreviousJobs(job.Attempt.PatientId);
            }

            if (string.IsNullOrEmpty(job.Attempt.ReferenceSeries))
            {
                return(string.Empty);
            }

            var studyId  = job.GetStudyIdFromReferenceSeries();
            var seriesId = job.GetSeriesIdFromReferenceSeries();
            var study    = studiesForPatient.FirstOrDefault(s => s.StudyInstanceUid == studyId);

            if (study == null)
            {
                _log.Error($"Failed to find reference study to register series against StudyInstanceUid: [{studyId}]");
                return(string.Empty);
            }
            var allSeries      = dicomSource.GetSeriesForStudy(study.StudyInstanceUid);
            var matchingSeries = allSeries.FirstOrDefault(s => s.SeriesInstanceUid == seriesId);

            if (matchingSeries == null)
            {
                _log.Error($"Failed to find reference study with matching series to register series against StudyInstanceUid: [{studyId}] SeriesInstanceUid: [{seriesId}]");
                return(string.Empty);
            }
            study.Series.Add(matchingSeries);
            _log.Info("Saving reference series to disk...");
            string referenceFolderPath;

            try
            {
                referenceFolderPath = SaveDicomFilesToFilesystem(study, job.ProcessingFolder, Reference, dicomSource);
            }
            catch (Exception ex)
            {
                _log.Error("Failed to save reference series dicom files to disk.", ex);
                throw;
            }
            return(referenceFolderPath);
        }