Skip to content

2.2 ChRIS DS plugin workflow: convert DICOM to jpg and invert image intensities.

Rudolph Pienaar edited this page Sep 17, 2018 · 1 revision

2.2 ChRIS DS plugin workflow: convert DICOM to jpg and invert image intensities.

Abstract

This page describes interacting with the ChRIS Ultron Back End (CUBE) using pfurl and running a 'ds' type plugin called pl-med2img. The pl-med2img plugin converts input DICOM data to JPG, and optionally can perform some simple image processing on the resultant JPG files.

In this instance, the input DICOM data will be converted to JPG and image intensities inverted.

The set of operations involves transferring the input directory on the host filesystem into the pfioh container, running the med2img plugin in the pfioh container space, and then pulling the results of that operation from the pfioh container space and back to a target location on the host filesystem.

Preconditions

Start system

In the source repo of CUBE, simply do a

*make*

Run the dircopy example

  • Make sure that the ChRIS FS plugin workflow example has been completed! This will create the source feed for the DS plugin.

HOST_IP env variable

You should set an environment variable, 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}')

Backend user

At least one user with name/password combination as

  • chris/chris1234

Containerized data/processing services:

  • pfcon
  • pfioh
  • pman

Volume mapping

Volume mapping is defined by the docker-compose.yml file.

GET list of plugins and check for pl-med2img plugin

Call

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

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

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

we can call

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

Receive

{
    "collection": {
        "links": [],
        "version": "1.0",
        "items": [
            {
                "links": [
                    {
                        "rel": "parameters",
                        "href": "http://10.17.24.163:8000/api/v1/plugins/5/parameters/"
                    },
                    {
                        "rel": "instances",
                        "href": "http://10.17.24.163:8000/api/v1/plugins/5/instances/"
                    }
                ],
                "data": [
                    {
                        "value": "med2img",
                        "name": "name"
                    },
                    {
                        "value": "fnndsc/pl-med2img",
                        "name": "dock_image"
                    },
                    {
                        "value": "ds",
                        "name": "type"
                    }
                ],
                "href": "http://10.17.24.163:8000/api/v1/plugins/5/"
            }
        ],
        "href": "http://10.17.24.163:8000/api/v1/plugins/5/"
    }
}

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}:8000/api/v1/plugins/5/parameters/ \
    --quiet --jsonpprintindent 4

Receive

{
    "collection": {
        "links": [
            {
                "href": "http://10.17.24.163:8000/api/v1/plugins/5/",
                "rel": "plugin"
            }
        ],
        "version": "1.0",
        "href": "http://10.17.24.163:8000/api/v1/plugins/5/parameters/",
        "items": [
            {
                "links": [
                    {
                        "href": "http://10.17.24.163:8000/api/v1/plugins/5/",
                        "rel": "plugin"
                    }
                ],
                "href": "http://10.17.24.163:8000/api/v1/plugins/parameters/23/",
                "data": [
                    {
                        "value": "outputFileType",
                        "name": "name"
                    },
                    {
                        "value": "string",
                        "name": "type"
                    },
                    {
                        "value": true,
                        "name": "optional"
                    },
                    {
                        "value": "jpg",
                        "name": "default"
                    },
                    {
                        "value": "output image file format",
                        "name": "help"
                    }
                ]
            },
            {
                "links": [
                    {
                        "href": "http://10.17.24.163:8000/api/v1/plugins/5/",
                        "rel": "plugin"
                    }
                ],
                "href": "http://10.17.24.163:8000/api/v1/plugins/parameters/24/",
                "data": [
                    {
                        "value": "sliceToConvert",
                        "name": "name"
                    },
                    {
                        "value": "integer",
                        "name": "type"
                    },
                    {
                        "value": true,
                        "name": "optional"
                    },
                    {
                        "value": "-1",
                        "name": "default"
                    },
                    {
                        "value": "slice to convert (for 3D data)",
                        "name": "help"
                    }
                ]
            },
            {
                "links": [
                    {
                        "href": "http://10.17.24.163:8000/api/v1/plugins/5/",
                        "rel": "plugin"
                    }
                ],
                "href": "http://10.17.24.163:8000/api/v1/plugins/parameters/25/",
                "data": [
                    {
                        "value": "func",
                        "name": "name"
                    },
                    {
                        "value": "string",
                        "name": "type"
                    },
                    {
                        "value": true,
                        "name": "optional"
                    },
                    {
                        "value": "",
                        "name": "default"
                    },
                    {
                        "value": "apply the specified transformation function before saving",
                        "name": "help"
                    }
                ]
            }
        ]
    }
}

Run an instance of the plugin

NB!

Make sure that directory to pass to the image is spec'd relative to the volume mapping for pfcon!

Call

Using httpie

http -a chris:chris1234 POST http://${HOST_IP}:8000/api/v1/plugins/5/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

pfurl --auth chris:chris1234 --verb POST --http ${HOST_IP}:8000/api/v1/plugins/5/instances/ \
--content-type application/vnd.collection+json \
--jsonwrapper 'template' --msg '
{"data":
    [
     {"name":"outputFileType",
      "value":"jpg"},
     {"name":"sliceToConvert",
      "value":"-1"},
     {"name":"func",
      "value":"invertIntensities"},
     {"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