# pkModelling from bash and python console

**URL:** <https://discourse.slicer.org/t/pkmodelling-from-bash-and-python-console/3633>\
**Category:** Feature requests\
**Created:** [August 2, 2018, 6:54am UTC](https://discourse.slicer.org/t/pkmodelling-from-bash-and-python-console/3633 "2018-08-02T06:54:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![be2be](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@be2be](https://discourse.slicer.org/u/be2be)\
**Post date:** [August 2, 2018, 6:54am UTC](https://discourse.slicer.org/t/pkmodelling-from-bash-and-python-console/3633/1 "2018-08-02T06:54:59Z")

</div>

dear experts,

it would be great to have an example command for (mac) bash as well as python for invoking pkModelling (and associated parameter set).

thank you so much!

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [August 3, 2018, 10:00pm UTC](https://discourse.slicer.org/t/pkmodelling-from-bash-and-python-console/3633/2 "2018-08-03T22:00:53Z")

</div>

PkModeling module is a CLI (Command Line Interface) type of Slicer module. In this sense, the generic instructions for invoking it from command line or from python apply.

Can you please read the following FAQ entries, and let us know what is missing from those that you need to achieve your tasks?

- [How to call a CLI module from command-line?](https://www.slicer.org/wiki/Documentation/Nightly/Developers/FAQ#How_to_call_a_CLI_module_from_command-line.3F)
- [How to run CLI module from Python?](https://www.slicer.org/wiki/Documentation/Nightly/Developers/FAQ#How_to_run_CLI_module_from_Python.3F)

---

<div class="post-metadata">

**Author:** ![be2be](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@be2be](https://discourse.slicer.org/u/be2be)\
**Post date:** [August 4, 2018, 1:42pm UTC](https://discourse.slicer.org/t/pkmodelling-from-bash-and-python-console/3633/3 "2018-08-04T13:42:42Z")

</div>

Thanks. I’m struggling with the very basics. I can’t find a description of the command and the way to parse arguments. What I found is an example command posted back in 2015 [here](http://slicer-users-archive.65878.n3.nabble.com/multivolumeimporter-PkModeling-td4029136.html). But parameter names seem to have changed.  
So I tried this without success ( Image Exception : #22 :: ERROR: Could not open image Applications/Slicer.app/Contents/Extensions-26813/PkModeling/lib/Slicer-4.8/cli-modules/PkModeling Error in slicer input, exiting…):

Slicer --launch Applications/Slicer.app/Contents/Extensions-26813/PkModeling/lib/Slicer-4.8/cli-modules/PkModeling --T1PreBloodValue 1400 --T1PreTissueValue 911 --RelaxivityValue 0.0056 --Hematocrit 0.42 --UsePopulationAIF --InputFourDImageFileName DCE\_input.nrrd --OutputKtransFileName Ktrans.nii.gz --ConstantBAT 3 --OutputFittedDataImageFileName outFit.nii.gz

Totally off the track?

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [August 4, 2018, 2:59pm UTC](https://discourse.slicer.org/t/pkmodelling-from-bash-and-python-console/3633/4 "2018-08-04T14:59:29Z")

</div>

Did you try `--help`? It will show all of the parameters of the module.

---

<div class="post-metadata">

**Author:** ![be2be](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@be2be](https://discourse.slicer.org/u/be2be)\
**Post date:** [August 4, 2018, 7:21pm UTC](https://discourse.slicer.org/t/pkmodelling-from-bash-and-python-console/3633/5 "2018-08-04T19:21:30Z")

</div>

Yes, I tried that, but got the same error… Seems that Slicer isn’t launching pkmodeling at all…

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [August 4, 2018, 10:50pm UTC](https://discourse.slicer.org/t/pkmodelling-from-bash-and-python-console/3633/6 "2018-08-04T22:50:33Z")

</div>

Ah, sorry - I missed your error in the initial post.

I see you are on Mac - can you try running PkModeling directly? I don’t think you need the launcher. The command below works for me:

```bash
$ /Applications/Slicer.app/Contents/Extensions-27332/PkModeling/lib/Slicer-4.9/cli-modules/PkModeling --help

USAGE:

   /Applications/Slicer.app/Contents/Extensions-27332/PkModeling/lib/Slicer
                                        -4.9/cli-modules/PkModeling
                                        [--returnparameterfile
                                        <std::string>]
                                        [--processinformationaddress
                                        <std::string>] [--xml] [--echo]
                                        [--deserialize <std::string>]
                                        [--serialize <std::string>]
                                        [--outputDiagnostics <std::string>]
                                        [--fitted <std::string>]
                                        [--concentrations <std::string>]
                                        [--outputBAT <std::string>]
                                        [--outputRSquared <std::string>]

```

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 21, 2023, 3:00am UTC](https://discourse.slicer.org/t/pkmodelling-from-bash-and-python-console/3633/7 "2023-03-21T03:00:29Z")

</div>


