简体   繁体   中英

How to access dicom attributes in nested sequences using pixelmed (java)?

I need to access all GantryAngle values within each ControlPointSequence attribute within the BeamSequence attribute.

Here is a quick visualization of the nesting

Beam Sequence
    ...
    Control Point Sequence
        Gantry Angle
        ...
    ...
    Control Point Sequence
        Gantry Angle
        ...
    ...
    Control Point Sequence
        Gantry Angle
    ...

How could I access each gantry angle using the pixelmed library?

EDIT:

thanks to help from cnellar, here is what ended up working

private ArrayList<Double> getAngles( SequenceAttribute beamSequence ) {
ArrayList<Double> n = new ArrayList<Double>();

Iterator is = beamSequence.iterator();
while (is.hasNext()) {
    SequenceItem item = (SequenceItem)is.next();
    if (item != null) { 
        AttributeList itemList = item.getAttributeList();
        if (itemList != null) {
            SequenceAttribute ctrlPoint = (SequenceAttribute)itemList.get( TagFromName.ControlPointSequence );
            //System.out.print(ctrlPoint);
            Iterator is1 = ctrlPoint.iterator();
            while (is1.hasNext()) {
                SequenceItem item1 = (SequenceItem)is1.next();
                if (item1 != null) { 
                    AttributeList itemList1 = item1.getAttributeList();
                    if (itemList1 != null) {

                        Attribute gantry_angle = itemList1.get( TagFromName.GantryAngle );
                        if(gantry_angle!=null)
                            n.add(gantry_angle.getSingleDoubleValueOrDefault(0));


                    }
                }

            }



        }
    }
}
return n;

}

I expect something like:

private double[] getAngles( SequenceAttribute beamSequence ) {

Iterator is = beamSequence.iterator();
while (is.hasNext()) {
    SequenceItem item = (SequenceItem)is.next();
    if (item != null) { 
        AttributeList itemList = item.getAttributeList();
        if (itemList != null) {
            Attribute ctrlPoint = itemList.get( TagFromName.ControlPointSequence );

            // Do the same sifting through this sequence to get your gantry angle
            // and add it to your list of values.
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM