modify within a sequence

Hi all,

I can get the beam type from :

beamtype = ToolBox.DoGet(LOCAL, '/instances/%s/content/BeamSequence/%s/BeamType' % (instance['ID'],bs))

how do I go about modifying the BeamType tag for all items in BeamSequence ?


Does anyone have an idea how to change and item in a sequence ?


Here is what I tried: Physicists, Don't ask why I am doing this/ :slight_smile:

for serie_index, serie in enumerate(series):

    instances = ToolBox.DoGet(LOCAL, '/series/%s/instances' % (serie['ID']))

    for instance in instances:
        # 300a,00b0 (BeamSequence)
        beamSequence = ToolBox.DoGet(LOCAL, '/instances/%s/tags' % instance['ID'])['300a,00b0']['Value']
        for bs in beamSequence:
            # 300a,00c4 (BeamType): u'DYNAMIC'
            # 300a,00c4 (BeamType): u'STATIC'
            bs['300a,00c4']['Value'] = 'STATIC'
        #300a,00b0 (BeamSequence): []
        j = ToolBox.DoPost(LOCAL, '/instances/%s/modify' % instance['ID'],
                    "Replace" : {
                        'BeamSequence': beamSequence,
        #j = DoPost(_REMOTE, '/instances', j, 'application/dicom')['ID']
        #DoDelete(_REMOTE, '/instances/%s' % i)


  File "C:/Users/xxx/Development/PycharmProjects/scripts/", line 72, in <module>
  File "C:/Users/xxx/Development/PycharmProjects/scripts\", line 156, in DoPost
    return _DoPutOrPost(orthanc, uri, 'POST', data, contentType, headers)
  File "C:/Users/xxx/Development/PycharmProjects/scripts\", line 137, in _DoPutOrPost
    raise Exception(resp.status)
Exception: 400


You will find attached to this message, a working example to fulfill your request.

The main trick consists in adding “?simplify” to your “DoGet()” query, in order to retrieve a JSON value that is compatible with what is expected by the “Replace” call.

Sébastien- (1.25 KB)