DigitalSlideArchive / HistomicsTK

A Python toolkit for pathology image analysis algorithms.
https://digitalslidearchive.github.io/HistomicsTK/
Apache License 2.0
391 stars 117 forks source link

Develop front-end for DSA #37

Closed cdeepakroy closed 8 years ago

cdeepakroy commented 8 years ago

The front end should have ways to:

cdeepakroy commented 8 years ago

Below is a sample POST request that runs a CLI that does ColorDeconvolution

api/v1/HistomicsTK/ColorDeconvolution/run?itemId=56279eb3a8487354347916c6&folderId=56279ecea8487354347916cd&stainColor_1=%5B0.65%2C%200.70%2C%200.29%5D&stainColor_2=%5B0.07%2C%200.99%2C%200.11%5D&stainColor_3=%5B0%2C%200%2C%200%5D

and below is the response:

{
  "_accessLevel": 2,
  "_id": "56cf65fba8487359caad8382",
  "_modelType": "job",
  "args": [],
  "async": false,
  "celeryTaskId": "f09e40be-306d-49e8-8feb-8807122f1dfc",
  "created": "2016-02-25T20:37:15.682372+00:00",
  "interval": 0,
  "kwargs": {
    "auto_convert": true,
    "cleanup": true,
    "inputs": {
      "inputImageFile": {
        "format": "string",
        "host": "localhost",
        "id": "56279eb3a8487354347916c6",
        "mode": "girder",
        "name": "A.png",
        "port": 8080,
        "resource_type": "item",
        "token": "8kFFXZqZfajQU4yuVvKnz0hgqfEG4mw4vSRe71QO6ZWselKZXnZFjRDiEZlX3HXh",
        "type": "string"
      },
      "stainColor_1": {
        "data": "[0.65, 0.70, 0.29]",
        "format": "json",
        "mode": "inline",
        "type": "number_list"
      },
      "stainColor_2": {
        "data": "[0.07, 0.99, 0.11]",
        "format": "json",
        "mode": "inline",
        "type": "number_list"
      },
      "stainColor_3": {
        "data": "[0, 0, 0]",
        "format": "json",
        "mode": "inline",
        "type": "number_list"
      }
    },
    "jobInfo": {
      "headers": {
        "Girder-Token": "CTlsh1TOxaVtOGTQgX0QyC5FLlU9KF2hPv9N5t72z44iuFw7wreGnmVesa9c4AIq"
      },
      "logPrint": true,
      "method": "PUT",
      "url": "http://localhost:8080/api/v1/job/56cf65fba8487359caad8382"
    },
    "outputs": {
      "outputStainImageFile_1": {
        "format": "string",
        "host": "localhost",
        "mode": "girder",
        "name": "A_stain_1.png",
        "parent_id": "56279ecea8487354347916cd",
        "parent_type": "folder",
        "port": 8080,
        "resource_type": "item",
        "token": "8kFFXZqZfajQU4yuVvKnz0hgqfEG4mw4vSRe71QO6ZWselKZXnZFjRDiEZlX3HXh",
        "type": "string"
      },
      "outputStainImageFile_2": {
        "format": "string",
        "host": "localhost",
        "mode": "girder",
        "name": "A_stain_2.png",
        "parent_id": "56279ecea8487354347916cd",
        "parent_type": "folder",
        "port": 8080,
        "resource_type": "item",
        "token": "8kFFXZqZfajQU4yuVvKnz0hgqfEG4mw4vSRe71QO6ZWselKZXnZFjRDiEZlX3HXh",
        "type": "string"
      },
      "outputStainImageFile_3": {
        "format": "string",
        "host": "localhost",
        "mode": "girder",
        "name": "A_stain_3.png",
        "parent_id": "56279ecea8487354347916cd",
        "parent_type": "folder",
        "port": 8080,
        "resource_type": "item",
        "token": "8kFFXZqZfajQU4yuVvKnz0hgqfEG4mw4vSRe71QO6ZWselKZXnZFjRDiEZlX3HXh",
        "type": "string"
      }
    },
    "task": {
      "inputs": [
        {
          "format": "string",
          "id": "inputImageFile",
          "target": "filepath",
          "type": "string"
        },
        {
          "format": "number_list",
          "id": "stainColor_1",
          "type": "number_list"
        },
        {
          "format": "number_list",
          "id": "stainColor_2",
          "type": "number_list"
        },
        {
          "default": {
            "data": [
              0,
              0,
              0
            ],
            "format": "number_list"
          },
          "format": "number_list",
          "id": "stainColor_3",
          "type": "number_list"
        }
      ],
      "mode": "python",
      "name": "ColorDeconvolution",
      "outputs": [
        {
          "format": "string",
          "id": "outputStainImageFile_1",
          "target": "filepath",
          "type": "string"
        },
        {
          "format": "string",
          "id": "outputStainImageFile_2",
          "target": "filepath",
          "type": "string"
        },
        {
          "format": "string",
          "id": "outputStainImageFile_3",
          "target": "filepath",
          "type": "string"
        }
      ],
      "script": "import os\nimport numpy as np\nimport skimage.io\nimport histomicstk as htk\n\n# Define Romanesco globals for the style checker\ninputImageFile = inputImageFile  # noqa\nstainColor_1 = stainColor_1      # noqa\nstainColor_2 = stainColor_2      # noqa\nstainColor_3 = stainColor_3      # noqa\n_tempdir = _tempdir              # noqa\n\n# Read Input Image\nprint('>> Reading input image')\n\nprint(inputImageFile)\n\ninputImage = skimage.io.imread(inputImageFile)\n\n# Create stain matrix\nprint('>> Creating stain matrix')\n\nW = np.array([stainColor_1, stainColor_2, stainColor_3]).T\nprint W\n\n# Perform color deconvolution\nprint('>> Performing color deconvolution')\nres = htk.ColorDeconvolution(inputImage, W)\n\n# write stain images to output\nprint('>> Outputting individual stain images')\noutFileSuffix = os.path.split(inputImageFile)[1]\n\noutputStainImageFile_1 = os.path.join(_tempdir, 'stain_1_' + outFileSuffix)\nskimage.io.imsave(outputStainImageFile_1, res.Stains[:, :, 0])\n\noutputStainImageFile_2 = os.path.join(_tempdir, 'stain_2_' + outFileSuffix)\nskimage.io.imsave(outputStainImageFile_2, res.Stains[:, :, 1])\n\noutputStainImageFile_3 = os.path.join(_tempdir, 'stain_3_' + outFileSuffix)\nskimage.io.imsave(outputStainImageFile_3, res.Stains[:, :, 2])\n"
    },
    "validate": false
  },
  "log": "",
  "meta": {},
  "progress": null,
  "public": false,
  "status": 1,
  "timestamps": [
    {
      "status": 1,
      "time": "2016-02-25T20:37:15.811107+00:00"
    }
  ],
  "title": "ColorDeconvolution",
  "type": "ColorDeconvolution",
  "updated": "2016-02-25T20:37:15.811107+00:00",
  "when": "2016-02-25T20:37:15.682372+00:00"
}
cdeepakroy commented 8 years ago

@jbeezley Here is a sample CLI folder. You can use ColorDeconvolution.xml to start your work for the front-end.