Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8002947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:31:27+00:00 2026-06-04T16:31:27+00:00

Currently I building a small desktop application that can handle DICOM files. I am

  • 0

Currently I building a small desktop application that can handle DICOM files. I am coding in C# and .NET and using the ClearCanvas library. One thing that I need to do is to be able to display the full contents of the file including all of the sequences. But the sequences are done in a recursive manner, so each sequence can have more sequences inside of it. Right now my code can access the first two levels, but I am just doing this as a tester, since I need to be able to access the nth level of sequences. So I need to somehow automate this. This is what my code looks like right now for the first two levels.

DicomSequenceItem[] seq = attrs2[i].Values as DicomSequenceItem[];
if (seq != null)
{
for (int j = 0; j < seq.Length; j++)
{
      for (int n = 0; n < seq[j].Count; n++)
      {
           DicomSequenceItem[] level2 = seq[j].ElementAt(n).Values as DicomSequenceItem[];
           if(seq[j].ElementAt(n).GetValueType().ToString().Equals("ClearCanvas.Dicom.DicomSequenceItem"))
           {               
                for (int k = 0; k < level2.Length; k++)
                {
                     for (int l = 0; l < level2[k].Count; l++)
                     {
                          text += "\t\t" + level2[k].ElementAt(l) + "\r\n";
                     }
                }
            }
            else
            {
                text += "\t" + seq[j].ElementAt(n) + "\r\n";
            }
       }
}
}

Any help (code samples) would be greatly appreciated.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:31:28+00:00Added an answer on June 4, 2026 at 4:31 pm

    Here’s a simple recursive routine to traverse through the tags in an attribute collection, including stepping recursively through any Sequence elements that may be in the collection:

        void Dump(DicomAttributeCollection collection, string prefix, StringBuilder sb)
        {     
            foreach (DicomAttribute attribute in collection)
            {
                var attribSQ = attribute as DicomAttributeSQ;
                if (attribSQ != null)
                {                    
                    for (int i=0; i< attribSQ.Count; i++) 
                    {
                        sb.AppendLine(prefix + "SQ Item: " + attribSQ.ToString());
    
                        DicomSequenceItem sqItem = attribSQ[i];
                        Dump(sqItem, prefix + "\t", sb);
                    }
                }
                else
                {
                    sb.AppendLine(prefix + attribute.ToString());
                }
            }
        }
    

    DicomAttributeCollection is Enumerable, so you can just use a foreach loop to go through all of the attributes in the collection. The attributes themselves are stored in a SortedDictionary, so they will also be in ascending tag order when enumerated.

    Note that if you downloaded the source code for the ClearCanvas libraries, you also could look at the real Dump() method that is part of the DicomAttributeCollection class. It traverses through a collection and writes to a StringBuilder instance all of the tags in the collection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently building a very small/simple web application in ASP.NET MVC with ADO.NET
I am currently building a small web application for publishing stories using PHP and
I'm currently building a small web application that includes a fair amount of JavaScript.
Currently I am building a small application that allows a user to sign in
I am building a small web application to run midi files. Currently I am
I am currently building a small visual designer using the Netbeans Platform. All my
I'm currently building a web form using APEX that is losely modelled after a
I'm currently building a class in PHP that generates PDF documents using the WKHTMLTOPDF
I'm currently building a small website where I write down problems that arise and
We're currently building an application that executes a number of external tools. We often

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.