adjustReferencedImages(dest, Tag.SourceImageSequence);
return dest;
}
private void adjustReferencedImages(Attributes attrs, int sqtag) {
Sequence sq = attrs.getSequence(sqtag);
if (sq == null)
return;
ArrayList<Attributes> newRefs = new ArrayList<Attributes>();
for (Iterator<Attributes> itr = sq.iterator(); itr.hasNext();) {
Attributes ref = (Attributes) itr.next();
String cuid = legacySOPClassUID(ref.getString(Tag.ReferencedSOPClassUID));
if (cuid == null)
continue;
itr.remove();
String iuid = uidMapper.get(ref.getString(Tag.ReferencedSOPInstanceUID));
int[] frames = ref.getInts(Tag.ReferencedFrameNumber);
int n = frames == null ? nofAccessor.getNumberOfFrames(iuid)
: frames.length;
ref.remove(Tag.ReferencedFrameNumber);
ref.setString(Tag.ReferencedSOPClassUID, VR.UI, cuid);
for (int i = 0; i < n; i++) {
Attributes newRef = new Attributes(ref);
newRef.setString(Tag.ReferencedSOPInstanceUID, VR.UI,
iuid + '.' + (frames != null ? frames[i] : (i+1)));
newRefs.add(newRef);
}
}
for (Attributes ref : newRefs)
sq.add(ref);
}