Now trying to run FSL's brain extraction using the Container Service; can't locate the derived input

96 views
Skip to first unread message

Katie Surrence

unread,
Apr 27, 2018, 7:09:46 PM4/27/18
to xnat_discussion
Hi all,

Having run dcm2niix via the container service, the next step was to see if I could write my own command with NIFTI input.  I am trying to run FSL's bet program from a container derived from the nipype/nipype image.  

I've tried to write a command that mimics the form of dcm2niix, substituting 'NIFTI' for 'DICOM' where appropriate, but I'm getting an error that indicates that XNAT can't locate the resource.  

I am hitting this endpoint: 


Here is the generated CURL request:

curl -X POST --header 'Content-Type: application/json;charset=UTF-8' --header 'Accept: application/json' -d '{
"scan":"/data/experiments/XNAT_E00001/scans/3"
}' 'http://10.1.1.17/xapi/projects/XNAT_E00001/commands/3/wrappers/bet-nifti/launch'


Here is my command:

{
  "name": "bet",
  "label": "bet",
  "description": "FSLBrainExtractionTool",
  "version": "1.0",
  "schema-version": "1.0",
  "image": "nipype/nipype:latest",
  "type": "docker",
  "working-directory": null,
  "command-line": "bet /input /output [OPTIONS]",
  "override-entrypoint": null,
  "mounts": [
    {
      "name": "nifti-in",
      "writable": false,
      "path": "/input"
    },
    {
      "name": "extracted-nifti-out",
      "writable": true,
      "path": "/output"
    }
  ],
  "environment-variables": {
    "envName1": "envVal1",
    "envName2": "#inputReplacementKey#"
  },
  "ports": {
    "22": "52222",
    "80": "8080"
  },
  "inputs": [
    {
      "name": "options",
      "description": "Comand-line flags to pass to bet",
      "type": "string",
      "matcher": null,
      "default-value": null,
      "required": false,
      "replacement-key": "[OPTIONS]",
      "command-line-flag": null,
      "command-line-separator": null,
      "true-value": null,
      "false-value": null
    }
  ],
  "outputs": [
    {
      "name": "extracted-nifti",
      "description": "The nifti file with brain extracted from skull and CSF",
      "required": true,
      "mount": "extracted-nifti-out",
      "path": null,
      "glob": ""
    }
  ],
  "xnat": [
    {
      "name": "bet-nifti",
      "description": "Run FSL’s brain extraction on a nifti file.",
      "contexts": [
        "xnat:imageScanData"
      ],
      "external-inputs": [
        {
          "name": "scan",
          "description": "Input scan",
          "type": "Scan",
          "matcher": "'NIFTI' in @.resources[*].label",
          "default-value": null,
          "required": true,
          "replacement-key": null,
          "provides-value-for-command-input": "",
          "provides-files-for-command-mount": "",
          "via-setup-command": null,
          "user-settable": true,
          "load-children": true
        }
      ],
      "derived-inputs": [
        {
          "name": "scan-nifti-bsc",
          "description": "The NIFTI scan with skull and CSF included",
          "type": "Resource",
          "matcher": "@.label == 'NIFTI'",
          "default-value": null,
          "required": true,
          "replacement-key": null,
          "provides-value-for-command-input": null,
          "provides-files-for-command-mount": "nifti-in",
          "user-settable": true,
          "load-children": true,
          "derived-from-wrapper-input": "scan",
          "derived-from-xnat-object-property": null,
          "via-setup-command": null
        }
      ],
      "output-handlers": [
        {
          "name": "nifti-resource",
          "accepts-command-output": "extracted-nifti",
          "via-wrapup-command": null,
          "as-a-child-of-wrapper-input": "scan",
          "type": "Resource",
          "label": "NIFTI"
        }
      ]
    }
  ],
  "reserve-memory": null,
  "limit-memory": null,
  "limit-cpu": null
}

Here is the response:

{ "status": "failure", "params": { "scan": "/data/experiments/XNAT_E00001/scans/3" }, "command-id": 3, "wrapper-id": null, "message": "Missing values for required input: scan-nifti-bsc." }


Could anyone help me figure out what I'm doing wrong?

Thanks very much,
Katie

Katie Surrence

unread,
Apr 28, 2018, 7:45:16 AM4/28/18
to xnat_di...@googlegroups.com
I realized after I posted that I needed to enter `XNAT_2016` instead of `XNAT_E00001` for the project, but that doesn't affect my error.

Best,
Katie

--
You received this message because you are subscribed to the Google Groups "xnat_discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussion+unsubscribe@googlegroups.com.
To post to this group, send email to xnat_discussion@googlegroups.com.
Visit this group at https://groups.google.com/group/xnat_discussion.
For more options, visit https://groups.google.com/d/optout.

John Flavin

unread,
Apr 30, 2018, 1:22:30 PM4/30/18
to XNAT Discussion board
Based on the error you got, it looks like maybe scan 3 on session XNAT_E00001 doesn't have a resource named NIFTI. But maybe there is something else going on that is making it throw that error erroneously. Can you verify that the scan does have a NIFTI resource? 

Flavin

To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussi...@googlegroups.com.
To post to this group, send email to xnat_di...@googlegroups.com.

Katie Surrence

unread,
Apr 30, 2018, 11:05:11 PM4/30/18
to xnat_di...@googlegroups.com
Hi John,

Thanks for your response! Attached are screenshots for a couple of API queries.  I think it looks like it has a NIFTI.

I tried another approach to the command, making the external input the files and the derived input the URI (I had a theory that maybe somehow the problem was that the NIFTI matcher got the .nii and the JSON metadata, when BET expects just a file).  However, it didn't solve the problem.  But here, for the record, is how I tried to change the inputs:

"external-inputs": [
        {
          "name": "scan",
          "description": "NIFTI resource on the scan",
          "type": "Resource",
          "matcher": "'nii' in @.files[*].URI",
          "default-value": null,
          "required": true,
          "replacement-key": null,
          "provides-value-for-command-input": "",
          "provides-files-for-command-mount": "",
          "via-setup-command": null,
          "user-settable": true,
          "load-children": true
        }
      ],
      "derived-inputs": [
        {
          "name": "scan-nifti-bsc",
          "description": "The NIFTI scan with skull and CSF included",
          "type": "File",
          "matcher": "'nii' in @.URI",
          "default-value": null,
          "required": true,
          "replacement-key": null,
          "provides-value-for-command-input": null,
          "provides-files-for-command-mount": "nifti-in",
          "user-settable": true,
          "load-children": true,
          "derived-from-wrapper-input": "scan",
          "derived-from-xnat-object-property": null,
          "via-setup-command": null
        }
      ],

And I gave it `{"scan":"/data/experiments/XNAT_E00001/scans/3/resources/12"}` for the params.  

I had another notion, which was to make the command accept just one external input, and feed it the URI directly.  I haven't tried that yet.  
Screen Shot 2018-04-30 at 10.55.24 PM.png
Screen Shot 2018-04-30 at 10.54.48 PM.png

John Flavin

unread,
May 1, 2018, 7:04:30 AM5/1/18
to XNAT Discussion board
Ok, I think see what could be wrong. Try taking the "/data" off the "scan" value; i.e. just start it with "/experiments". 

Your inputs seemed correct to me before—I got the container to launch using what you had posted. (It did fail immediately, which could be related to the issue you mentioned that bet expects just the single file, but we can work on that once you get it to launch successfully.)

Flavin

To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussi...@googlegroups.com.
To post to this group, send email to xnat_di...@googlegroups.com.
<Screen Shot 2018-04-30 at 10.55.24 PM.png><Screen Shot 2018-04-30 at 10.54.48 PM.png>

Katie Surrence

unread,
May 2, 2018, 1:04:21 PM5/2/18
to xnat_discussion
Dear Flavin,

I haven't one hundred percent verified that this worked yet, but it is apparently working, so I wanted to write back before too long.  

Thank you, that helped!  I'm again having the experience that I remember using Swagger and getting some HTML back, but then not being able to reproduce that phenomenon.  Right now, taking the "/data" off my path (with the second version of my command) is still giving me the same error: "Missing values for required input: scan-nifti-bsc."

Here's what I'm now passing as a param:

{"scan":"/experiments/XNAT_E00001/scans/3/resources/NIFTI"}

However!  I tried making a version of my command that takes the URI directly, and this appears to work.  I say appears to because I was trying to look at the file to see if it seemed like a brain with no skull or CSF, and it didn't even look like a brain.  Then I noticed the file had been named IG7_Prostate, and I thought, oh, that would explain it.  So I haven't verified that the procedure is running properly, but I am getting a 200 back on my request.  

Here's the command that seems to work:

{
  "name": "bet-direct",
  "label": "bet-direct",
          "description": "URI of NIFTI",
          "type": "string",
          "matcher": "'nii' in @",
          "default-value": null,
          "required": true,
          "replacement-key": null,
          "provides-value-for-command-input": "nifti-in",
          "provides-files-for-command-mount": "",
          "via-setup-command": null,
          "user-settable": true,
          "load-children": true
        }
      ],
      "derived-inputs": [],
      "output-handlers": [
        {
          "name": "nifti-resource",
          "accepts-command-output": "extracted-nifti",
          "via-wrapup-command": null,
          "as-a-child-of-wrapper-input": "scan",
          "type": "Resource",
          "label": "NIFTI"
        }
      ]
    },
    {
      "name": "bet-direct-nifti",
      "description": "Run FSL’s brain extraction on a nifti file.",
      "contexts": [
        "xnat:imageScanData"
      ],
      "external-inputs": [
        {
          "name": "scan",
          "description": "URI of NIFTI",
          "type": "string",
          "matcher": "'nii' in @",
          "default-value": null,
          "required": true,
          "replacement-key": null,
          "provides-value-for-command-input": "nifti-in",
          "provides-files-for-command-mount": "",
          "via-setup-command": null,
          "user-settable": true,
          "load-children": true
        }
      ],
      "derived-inputs": [],
      "output-handlers": [
        {
          "name": "nifti-resource",
          "accepts-command-output": "extracted-nifti",
          "via-wrapup-command": null,
          "as-a-child-of-wrapper-input": "scan",
          "type": "Resource",
          "label": "NIFTI"
        }
      ]
    }
  ],
  "reserve-memory": null,
  "limit-memory": null,
  "limit-cpu": null
}


And here's what I give it for params:

{"scan":"/experiments/XNAT_E00001/scans/3/resources/12/files/input_AX_FRFSE-XL_T2_20080822115111_3.nii"}


Assuming I can verify that this really is extracting the brain (it's not creating another file so hopefully it's writing in place?), I'd like to understand why my first and second attempts did not work.  The point of what I'm doing right now is less about actually running bet and more about learning to use the container service.  I guess I can hypothesize that even my second attempt

, passed something like an XNAT File object to the docker container and not the actual file, but in that case, I don't understand how I can ever use these XNAT objects to interact with other programs that expect files.  

Thanks for all your help so far.  I'm looking forward to understanding this better.  If there's a section of the documentation you'd like to point me to I'd gladly look at that as well.

Best,
Katie
Flavin


To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussi...@googlegroups.com.
To post to this group, send email to xnat_di...@googlegroups.com.
Visit this group at https://groups.google.com/group/xnat_discussion.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "xnat_discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussi...@googlegroups.com.
To post to this group, send email to xnat_di...@googlegroups.com.
Visit this group at https://groups.google.com/group/xnat_discussion.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "xnat_discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussi...@googlegroups.com.
To post to this group, send email to xnat_di...@googlegroups.com.
Visit this group at https://groups.google.com/group/xnat_discussion.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages