Skip to content

2.1 ChRIS DS plugin workflow: anonymize DICOM images.

Rudolph Pienaar edited this page Feb 12, 2019 · 6 revisions

2.1 ChRIS DS plugin workflow: anomymize DICOM images.

(WARNING -- This page is incomplete as of Feb 2019 due to issues with nesting JSON strings within JSON strings in the calling protocols. The final call instructions do not work.)

Abstract

This page describes interacting with the ChRIS Ultron Back End (CUBE) using pfurl and running a DS type plugin called pl-pfdicom_tagsub. This plugin wraps around an underlying pfdicom_tagSub python module and provides the ability to edit, or sub, DICOM meta data values.

The set of operations is simply to call CUBE with the correct plugin instance and appropriate arguments for the plugin.See

Preconditions

An existing FS feed containing the DICOM data to anomymize.

Please follow the steps here to create a new source, or FS, feed containing data to anonymize.

Set some convenience environment variables

In a new terminal, set HOST_IP to the IP of the actual host you are using. In Linux, this is

export HOST_IP=$(ip route | grep -v docker | awk '{if(NF==11) print $9}')
export HOST_PORT=8000

Backend user

At least one user with name/password combination as

  • chris/chris1234

The FS example will take care of this.

Containerized data/processing services:

  • pfcon
  • pfioh
  • pman

The FS example will take care of this.

GET list of plugins and check for pl-pfdicom_tagsub plugin:

Call

pfurl --auth chris:chris1234 --http ${HOST_IP}:${HOST_PORT}/api/v1/plugins/ \
    --quiet --jsonpprintindent 4

Look through the list for pl-pfdicom_tagsub. For example, let's say that this is located at

http://10.17.24.163:8000/api/v1/plugins/9/

we can call

export P=9
pfurl --auth chris:chris1234 --http ${HOST_IP}:8000/api/v1/plugins/$P/ \
    --quiet --jsonpprintindent 4

Receive

{
  "collection": {
    "version": "1.0",
    "href": "http://10.72.76.155:8000/api/v1/plugins/9/",
    "items": [
      {
        "data": [
          { "name": "name", "value": "pfdicom_tagsub" },
          { "name": "dock_image", "value": "fnndsc/pl-pfdicom_tagsub" },
          { "name": "type", "value": "ds" },
          { "name": "authors", "value": "FNNDSC (dev@babyMRI.org)" },
          { "name": "title", "value": "Edits various specified DICOM tags" },
          { "name": "category", "value": "DICOM" },
          {
            "name": "description",
            "value": "This plugin wraps around pfdicom_tagSub and is used to edit the contents of user-specified DICOM tags."
          },
          {
            "name": "documentation",
            "value": "https://github.com/FNNDSC/pl-pfdicom_tagSub"
          },
          { "name": "license", "value": "Opensource (MIT)" },
          { "name": "version", "value": "1.0.2" },
          { "name": "execshell", "value": "python3" },
          { "name": "selfpath", "value": "/usr/src/dcm_tagSub" },
          { "name": "selfexec", "value": "dcm_tagSub.py" },
          { "name": "compute_resource_identifier", "value": "host" },
          { "name": "min_number_of_workers", "value": 1 },
          { "name": "max_number_of_workers", "value": 1 },
          { "name": "min_cpu_limit", "value": 1000 },
          { "name": "max_cpu_limit", "value": 2147483647 },
          { "name": "min_memory_limit", "value": 200 },
          { "name": "max_memory_limit", "value": 2147483647 },
          { "name": "min_gpu_limit", "value": 0 },
          { "name": "max_gpu_limit", "value": 0 }
        ],
        "href": "http://10.72.76.155:8000/api/v1/plugins/9/",
        "links": [
          {
            "rel": "parameters",
            "href": "http://10.72.76.155:8000/api/v1/plugins/9/parameters/"
          },
          {
            "rel": "instances",
            "href": "http://10.72.76.155:8000/api/v1/plugins/9/instances/"
          }
        ]
      }
    ],
    "links": [ ]
  }
}

GET parameter info for plugin

Follow the links provided to get information on the parameters for the plugin

Call

pfurl --auth chris:chris1234 --http ${HOST_IP}:${HOST_PORT}/api/v1/plugins/$P/parameters/ \
    --quiet --jsonpprintindent 4

Receive

{
  "collection": {
    "version": "1.0",
    "href": "http://10.72.76.155:8000/api/v1/plugins/9/parameters/",
    "items": [
      {
        "data": [
          { "name": "name", "value": "inputFile" },
          { "name": "type", "value": "string" },
          { "name": "optional", "value": true },
          { "name": "default", "value": "" },
          { "name": "flag", "value": "-i" },
          { "name": "action", "value": "store" },
          { "name": "help", "value": "input file" }
        ],
        "href": "http://10.72.76.155:8000/api/v1/plugins/parameters/62/",
        "links": [{ "rel": "plugin", "href": "http://10.72.76.155:8000/api/v1/plugins/9/" }]
      },
      {
        "data": [
          { "name": "name", "value": "extension" },
          { "name": "type", "value": "string" },
          { "name": "optional", "value": true },
          { "name": "default", "value": "" },
          { "name": "flag", "value": "-e" },
          { "name": "action", "value": "store" },
          { "name": "help", "value": "DICOM file extension" }
        ],
        "href": "http://10.72.76.155:8000/api/v1/plugins/parameters/63/",
        "links": [{ "rel": "plugin", "href": "http://10.72.76.155:8000/api/v1/plugins/9/" }]
      },
      {
        "data": [
          { "name": "name", "value": "tagFile" },
          { "name": "type", "value": "string" },
          { "name": "optional", "value": true },
          { "name": "default", "value": "" },
          { "name": "flag", "value": "-F" },
          { "name": "action", "value": "store" },
          { "name": "help", "value": "JSON formatted file containing tags to sub" }
        ],
        "href": "http://10.72.76.155:8000/api/v1/plugins/parameters/64/",
        "links": [{ "rel": "plugin", "href": "http://10.72.76.155:8000/api/v1/plugins/9/" }]
      },
      {
        "data": [
          { "name": "name", "value": "tagStruct" },
          { "name": "type", "value": "string" },
          { "name": "optional", "value": true },
          { "name": "default", "value": "" },
          { "name": "flag", "value": "-T" },
          { "name": "action", "value": "store" },
          { "name": "help", "value": "JSON formatted tag sub struct" }
        ],
        "href": "http://10.72.76.155:8000/api/v1/plugins/parameters/65/",
        "links": [{ "rel": "plugin", "href": "http://10.72.76.155:8000/api/v1/plugins/9/" }]
      },
      {
        "data": [
          { "name": "name", "value": "outputFileStem" },
          { "name": "type", "value": "string" },
          { "name": "optional", "value": true },
          { "name": "default", "value": "" },
          { "name": "flag", "value": "-o" },
          { "name": "action", "value": "store" },
          { "name": "help", "value": "output file" }
        ],
        "href": "http://10.72.76.155:8000/api/v1/plugins/parameters/66/",
        "links": [{ "rel": "plugin", "href": "http://10.72.76.155:8000/api/v1/plugins/9/" }]
      },
      {
        "data": [
          { "name": "name", "value": "printElapsedTime" },
          { "name": "type", "value": "boolean" },
          { "name": "optional", "value": true },
          { "name": "default", "value": "False" },
          { "name": "flag", "value": "--printElapsedTime" },
          { "name": "action", "value": "store_true" },
          { "name": "help", "value": "print program run time" }
        ],
        "href": "http://10.72.76.155:8000/api/v1/plugins/parameters/67/",
        "links": [{ "rel": "plugin", "href": "http://10.72.76.155:8000/api/v1/plugins/9/" }]
      },
      {
        "data": [
          { "name": "name", "value": "threads" },
          { "name": "type", "value": "string" },
          { "name": "optional", "value": true },
          { "name": "default", "value": "0" },
          { "name": "flag", "value": "--threads" },
          { "name": "action", "value": "store" },
          { "name": "help", "value": "number of threads for innermost loop processing" }
        ],
        "href": "http://10.72.76.155:8000/api/v1/plugins/parameters/68/",
        "links": [{ "rel": "plugin", "href": "http://10.72.76.155:8000/api/v1/plugins/9/" }]
      },
      {
        "data": [
          { "name": "name", "value": "outputLeafDir" },
          { "name": "type", "value": "string" },
          { "name": "optional", "value": true },
          { "name": "default", "value": "" },
          { "name": "flag", "value": "--outputLeafDir" },
          { "name": "action", "value": "store" },
          { "name": "help", "value": "formatting spec for output leaf directory" }
        ],
        "href": "http://10.72.76.155:8000/api/v1/plugins/parameters/69/",
        "links": [{ "rel": "plugin", "href": "http://10.72.76.155:8000/api/v1/plugins/9/" }]
      },
      {
        "data": [
          { "name": "name", "value": "man" },
          { "name": "type", "value": "boolean" },
          { "name": "optional", "value": true },
          { "name": "default", "value": "False" },
          { "name": "flag", "value": "-x" },
          { "name": "action", "value": "store_true" },
          { "name": "help", "value": "man" }
        ],
        "href": "http://10.72.76.155:8000/api/v1/plugins/parameters/70/",
        "links": [{ "rel": "plugin", "href": "http://10.72.76.155:8000/api/v1/plugins/9/" }]
      },
      {
        "data": [
          { "name": "name", "value": "synopsis" },
          { "name": "type", "value": "boolean" },
          { "name": "optional", "value": true },
          { "name": "default", "value": "False" },
          { "name": "flag", "value": "-y" },
          { "name": "action", "value": "store_true" },
          { "name": "help", "value": "short synopsis" }
        ],
        "href": "http://10.72.76.155:8000/api/v1/plugins/parameters/71/",
        "links": [{ "rel": "plugin", "href": "http://10.72.76.155:8000/api/v1/plugins/9/" }]
      }
    ],
    "links": [
      { "rel": "plugin", "href": "http://10.72.76.155:8000/api/v1/plugins/9/" },
      {
        "rel": "next",
        "href": "http://10.72.76.155:8000/api/v1/plugins/9/parameters/?limit=10&offset=10"
      }
    ]
  }
}

Run an instance of the plugin

Call

Using httpie

DO NOT USE! This call is under construction!

http -a chris:chris1234 POST http://${HOST_IP}:${HOST_PORT}/api/v1/plugins/$P/instances/ \
Content-Type:application/vnd.collection+json \
Accept:application/vnd.collection+json \
template:='{"data":
    [
     {"name":"outputFileType",
      "value":"jpg"},
     {"name":"sliceToConvert",
      "value":"-1"},
     {"name":"func",
      "value":"invertIntensities"},
     {"name":"previous_id",
      "value":"1"}
    ]
}'

Using pfurl

DO NOT USE! This call fails via pfurl due to the nested JSON string that needs to be passed.

pfurl --auth chris:chris1234 --verb POST --http ${HOST_IP}:${HOST_PORT}/api/v1/plugins/$P/instances/ \
--content-type application/vnd.collection+json \
--jsonwrapper 'template' --msg '
{"data":
    [
     {"name":"extension",
      "value":"dcm"},
     {"name":"threads",
      "value":"0"},
     {"name":"tagStruct",
      "value":{"PatientName":       "anonymized-again"}},
     {"name":"previous_id",
      "value":"1"}
    ]
}' \
--quiet --jsonpprintindent 4

Receive

{
  "stdout": {
    "collection": {
      "items": [
        {
          "href": "http://10.17.24.163:8000/api/v1/plugins/instances/2/",
          "links": [
            {
              "href": "http://10.17.24.163:8000/api/v1/plugins/instances/1/",
              "rel": "previous"
            },
            { "href": "http://10.17.24.163:8000/api/v1/plugins/5/", "rel": "plugin" },
            {
              "href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/2/",
              "rel": "string_param"
            },
            {
              "href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/3/",
              "rel": "string_param"
            },
            {
              "href": "http://10.17.24.163:8000/api/v1/plugins/int-parameter/1/",
              "rel": "int_param"
            }
          ],
          "data": [
            { "value": 2, "name": "id" },
            { "value": 1, "name": "previous_id" },
            { "value": "med2img", "name": "plugin_name" },
            { "value": "2017-09-21T21:47:21.718499Z", "name": "start_date" },
            { "value": "2017-09-21T21:47:21.718551Z", "name": "end_date" },
            { "value": "started", "name": "status" },
            { "value": "chris", "name": "owner" }
          ]
        }
      ],
      "href": "http://10.17.24.163:8000/api/v1/plugins/5/instances/",
      "links": [ ],
      "version": "1.0"
    }
  },
  "msg": "push OK."
}
Clone this wiki locally