Skip to content

Commit

Permalink
Merge pull request #83 from celeron533/search_sequence
Browse files Browse the repository at this point in the history
Able to search the sequence tag
  • Loading branch information
celeron533 authored Jun 25, 2024
2 parents 1a8fbc9 + f80e48b commit 27dbaf0
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions DicomGrepCore/Services/SearchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using System.Threading.Tasks;
using DicomGrepCore.Enums;
using FellowOakDicom;
using System.Xml.Linq;
using System.Diagnostics;

namespace DicomGrepCore.Services
{
Expand Down Expand Up @@ -70,7 +72,7 @@ public void Search(SearchCriteria criteria, CancellationTokenSource tokenSource)

ParallelOptions options = new ParallelOptions
{
MaxDegreeOfParallelism = criteria.SearchThreads <= 0 ? Environment.ProcessorCount : criteria.SearchThreads ,
MaxDegreeOfParallelism = criteria.SearchThreads <= 0 ? Environment.ProcessorCount : criteria.SearchThreads,
CancellationToken = this.token
};
try
Expand Down Expand Up @@ -209,7 +211,15 @@ private IList<ResultDicomItem> CompareDicomTagAndValue(DicomDataset dataset, ref
// dig into sub sequence
if (dicomItem.ValueRepresentation == DicomVR.SQ)
{
foreach (DicomDataset innerDataset in ((DicomSequence)dicomItem).Items)
DicomSequence sequenceItem = (DicomSequence)dicomItem;

if (string.IsNullOrWhiteSpace(criteria.SearchTag) ||
CompareDicomTag(dicomItem.Tag, criteria.DicomSearchTag))
{
resultDicomItems ??= new List<ResultDicomItem>();
resultDicomItems.Add(new ResultDicomItem(dicomItem.Tag, $"Count = {sequenceItem.Items.Count}", []));
}
foreach (DicomDataset innerDataset in sequenceItem.Items)
{
CompareDicomTagAndValue(innerDataset, ref resultDicomItems);
}
Expand Down Expand Up @@ -250,10 +260,7 @@ private IList<ResultDicomItem> CompareDicomTagAndValue(DicomDataset dataset, ref
if (string.IsNullOrWhiteSpace(criteria.SearchText) || CompareString(valueString, criteria, false))
{
//handle match
if (resultDicomItems == null)
{
resultDicomItems = new List<ResultDicomItem>();
}
resultDicomItems ??= new List<ResultDicomItem>();

resultDicomItems.Add(new ResultDicomItem(element.Tag, valueString, rawValue));

Expand Down

0 comments on commit 27dbaf0

Please sign in to comment.