---
# System prepended metadata

title: Using openCARP's docker container
tags: [Collaborations, Instructions]

---

# Using openCARP's docker container 

Assume you want to run `openCARP` on a file called `carpf_laplace_PA.par`, that is located on a folder `$LAPath`, then: 

**Using openCARP installed on your machine**. This is equivalent to using the AppImage, only the name changes:
```shell!
cd $LAPath 
openCARP +F carpf_laplace_PA.par --simID PA_UAC
```


**Using openCARP's docker** 
We'll display the command in multiple lines to be more understandable: 
```shell
docker run \ 
    --rm   \
    --volume=$LAPath:/shared:z --workdir=/shared \
    docker.opencarp.org/opencarp/opencarp:latest \
    openCARP \ 
    +F carpf_laplace_PA.par --simID PA_UAC 
```

> In a single line: 
```shell
docker run --rm --volume=$LAPath:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP
 +F carpf_laplace_PA.par --simID PA_UAC 
```

# Another example
Paste your code below: 
```shell 
# #!/bin/bash

# EXAMPLE 1 
echo "==== Using local meshtool ==== "
meshtool convert -imsh="$LAPath/Labelled" -ifmt=carp_txt -omsh="$LAPath/Labelled" -ofmt=carp_txt -scale=1000

echo "==== Using meshtool inside openCARP docker ===="
docker run --rm --volume=$LAPath:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest meshtool convert -imsh="Labelled" -ifmt=carp_txt -omsh="Labelled" -ofmt=carp_txt -scale=1000

# EXAMPLE 2 
echo "==== Using openCARP AppImage ===="
cd "$LAPath/"
openCARP-v13.0-x86_64.AppImage +F carpf_laplace_PV1.par -simID MV_PV1

echo "==== Using docker openCARP ===="
docker run --rm --volume=$LAPath:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_PV1.par -simID MV_PV1

```

Try it yourself!

## Additional Question
When I ran the script, Docker is not running in the background. Is this the problem?

## Directory Structure
```
root (Project root Folder)
├─UAC_code(UAC code folder)
├─Data
│  ├─CardioInsight_clipped.stl
│  ├─CardioInsight_Landmarks.txt
│  ├─CardioInsight_Regions.txt
│  ├─Ensite_clipped.stl
│  ├─Ensite_Landmarks.txt
│  └─Ensite_Regions.txt
└─umc-lav_CardioInsight.sh
```

## Changed Segment Line 64 - 74
```shell=
docker run --rm --volume=/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_PV1.par -simID MV_PV1
docker run --rm --volume=/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_PV2.par -simID MV_PV2
docker run --rm --volume=/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_PV3.par -simID MV_PV3
docker run --rm --volume=/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_PV4.par -simID MV_PV4
docker run --rm --volume=/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_LAA.par -simID MV_LAA

# openCARP-v13.0-x86_64.AppImage +F carpf_laplace_PV1.par -simID MV_PV1
# openCARP-v13.0-x86_64.AppImage +F carpf_laplace_PV2.par -simID MV_PV2
# openCARP-v13.0-x86_64.AppImage +F carpf_laplace_PV3.par -simID MV_PV3
# openCARP-v13.0-x86_64.AppImage +F carpf_laplace_PV4.par -simID MV_PV4
# openCARP-v13.0-x86_64.AppImage +F carpf_laplace_LAA.par -simID MV_LAA
```

## umc-lav_CardioInsight.sh
```shell=
#!/bin/bash

echo "Variables" # Variables
PROJECT=UAC_code # UAC project directory
DATA=Data # data directory
PYTHON_PATH2=UAC_code/carpusers-bdx-tools # carpusers-bdx-tools directory

export PYTHONPATH=$PROJECT

RA_Mesh_Name="Labelled_6"
ES_dir="$PROJECT/extra_structures"
RAendofib_dir="$PROJECT/fibre_files/ra/endo/l/"
RAepifib_dir="$PROJECT/fibre_files/ra/epi/l/"
RAbbfib_dir="$PROJECT/fibre_files/bb/ra/"
LAendofib_dir="$PROJECT/fibre_files/la/endo/l/"
LAepifib_dir="$PROJECT/fibre_files/la/epi/l/"
LAbbfib_dir="$PROJECT/fibre_files/bb/la/"

MeshName="Labelled"
LandmarksRA="CardioInsight_Landmarks.txt"
RegionRA="CardioInsight_Regions.txt"
LandmarksLA="CardioInsight_Landmarks.txt"
RegionLA="CardioInsight_Regions.txt"


index=1


pvThreshold=0.85
LAAThreshold=0.9  #Bigger number = smaller area defined From 0 to 1

# Variables
LAPath='Data/'
LAFile='CardioInsight_clipped.stl'

# Using openCARP installed on local machine
# cd $LAPath 
# openCARP +F carpf_laplace_PA.par --simID PA_UAC

# Shared folder absolute path:
# /mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/
# Create shared folder and set the working directory inside the container shared folder
# docker run --rm --volume=$LAPath:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_PA.par --simID PA_UAC 
# Combined: docker run --rm --volume=/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_PA.par --simID PA_UAC 

echo $LAPath

python $PYTHON_PATH2/trans_mod.py --from-format=stl --to-format=carp "$LAPath/$LAFile" "$LAPath/Labelled.pts"

meshtool convert -imsh="$LAPath/Labelled" -ifmt=carp_txt -omsh="$LAPath/Labelled" -ofmt=carp_txt -scale=1000


python $PROJECT/scripts/labels_la_1.py $LAPath "$PROJECT/fibre_files/la/endo/" "$PROJECT/laplace_files/" Labelled $pvThreshold $LAAThreshold $RegionLA 1000


cp "$PROJECT/laplace_files/carpf_laplace_PV1.par" "$LAPath/carpf_laplace_PV1.par"
cp "$PROJECT/laplace_files/carpf_laplace_PV2.par" "$LAPath/carpf_laplace_PV2.par"
cp "$PROJECT/laplace_files/carpf_laplace_PV3.par" "$LAPath/carpf_laplace_PV3.par"
cp "$PROJECT/laplace_files/carpf_laplace_PV4.par" "$LAPath/carpf_laplace_PV4.par"
cp "$PROJECT/laplace_files/carpf_laplace_LAA.par" "$LAPath/carpf_laplace_LAA.par"

cd "$LAPath/"

docker run --rm --volume=/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_PV1.par -simID MV_PV1
docker run --rm --volume=/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_PV2.par -simID MV_PV2
docker run --rm --volume=/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_PV3.par -simID MV_PV3
docker run --rm --volume=/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_PV4.par -simID MV_PV4
docker run --rm --volume=/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_LAA.par -simID MV_LAA

# openCARP-v13.0-x86_64.AppImage +F carpf_laplace_PV1.par -simID MV_PV1
# openCARP-v13.0-x86_64.AppImage +F carpf_laplace_PV2.par -simID MV_PV2
# openCARP-v13.0-x86_64.AppImage +F carpf_laplace_PV3.par -simID MV_PV3
# openCARP-v13.0-x86_64.AppImage +F carpf_laplace_PV4.par -simID MV_PV4
# openCARP-v13.0-x86_64.AppImage +F carpf_laplace_LAA.par -simID MV_LAA

python $PROJECT/scripts/labels_la_2.py "$LAPath/" "$PROJECT/fibre_files/la/endo/" "$PROJECT/laplace_files/" Labelled $pvThreshold $LAAThreshold $RegionLA 1000


cp "$LAPath/Labelled_Labels.elem" "$LAPath/Labelled.elem"



cp "$PROJECT/laplace_files/carpf_laplace_LS.par" "$LAPath/carpf_laplace_LS.par"
cp "$PROJECT/laplace_files/carpf_laplace_PA.par" "$LAPath/carpf_laplace_PA.par"
python $PROJECT/scripts/1_la.py "$LAPath/" "$PROJECT/fibre_files/la/endo/" "$PROJECT/laplace_files/" Labelled 11 13 21 23 25 27 $LandmarksLA 1000

echo "=====Old UAC approximation - openCARP command line ($i)====="
cd "$LAPath/"
docker run --rm --volume=/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_PA.par -simID PA_UAC_N2
docker run --rm --volume=/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_LS.par -simID LR_UAC_N2

echo "=====New UAC====="
cp "$PROJECT/laplace_files/carpf_laplace_single_LR_P.par" "$LAPath/carpf_laplace_single_LR_P.par"
cp "$PROJECT/laplace_files/carpf_laplace_single_UD_P.par" "$LAPath/carpf_laplace_single_UD_P.par"
cp "$PROJECT/laplace_files/carpf_laplace_single_LR_A.par" "$LAPath/carpf_laplace_single_LR_A.par"
cp "$PROJECT/laplace_files/carpf_laplace_single_UD_A.par" "$LAPath/carpf_laplace_single_UD_A.par"
python $PROJECT/scripts/2a_la.py "$LAPath/" "$PROJECT/fibre_files/la/endo/" "$PROJECT/laplace_files/" Labelled 11 13 21 23 25 27 $LandmarksLA 1000

docker run --rm --volume=/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_single_LR_A.par -simID LR_Ant_UAC
docker run --rm --volume=/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_single_LR_P.par -simID LR_Post_UAC
docker run --rm --volume=/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_single_UD_A.par -simID UD_Ant_UAC
docker run --rm --volume=/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/Data/:/shared:z --workdir=/shared docker.opencarp.org/opencarp/opencarp:latest openCARP +F carpf_laplace_single_UD_P.par -simID UD_Post_UAC


echo "=====New UAC part 2====="
python $PROJECT/scripts/2b_la.py "$LAPath/" "$PROJECT/fibre_files/la/endo/" "$PROJECT/laplace_files/" Labelled 11 13 21 23 25 27 1000


echo "=====Add fibres2 ====="
python $PROJECT/scripts/fibre_mapping.py "$LAPath/" "$PROJECT/fibre_files/la/endo/l/" "$PROJECT/laplace_files/" Labelled Labelled.lon Fibre_l


echo "=====Add LAT field ($i)====="
python $PROJECT/scripts/lat_field.py "$LAPath/" LAT_Spiral4_B.dat Fibre_l


echo "=====Make PV stimulus files .vtx ($i)====="
```

## Error Code 
```
(uac) zack@MSI:/mnt/c/Users/catsk$ cd OneDrive/桌面/PCAL_NonInvasiveMappingProject
(uac) zack@MSI:/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject$ sh umc-lav_CardioInsight.sh
Variables
Data/
Reading Data//CardioInsight_clipped.stl in stl format
Finished reading Data//CardioInsight_clipped.stl
<meshio mesh object>
  Number of points: 3430
  Number of cells:
    triangle: 6539
  Cell data: facet_normals

Writing Data//Labelled.pts in carp ASCII format
OpenMP thread utilization: 16 / 16 threads.
Reading mesh: Data//Labelled
Reading elements in text CARP format:                  [============] 00h:00m:00s FIN
Reading points in text CARP format:                    [============] 00h:00m:00s FIN
Reading fibers (1 directions) in text CARP format:     [============] 00h:00m:00s FIN
Done in 0.01252 sec
Processing mesh ..
Pass 1: Corrected 0 inside-out elements.
Done in 4.2e-05 sec
Writing mesh: Data//Labelled
Writing elements in text CARP format:                  [============] 00h:00m:00s FIN
Writing points in text CARP format:                    [============] 00h:00m:00s FIN
Writing fibers (1 direction) in text CARP format:      [============] 00h:00m:00s FIN
Done in 0.135395 sec
Traceback (most recent call last):
  File "UAC_code/scripts/labels_la_1.py", line 7, in <module>
    from uac import utils
  File "/mnt/c/Users/catsk/OneDrive/桌面/PCAL_NonInvasiveMappingProject/UAC_code/uac/utils.py", line 10, in <module>
    import vtk
  File "/home/zack/anaconda3/envs/uac/lib/python3.8/site-packages/vtk.py", line 30, in <module>
    all_m = importlib.import_module('vtkmodules.all')
  File "/home/zack/anaconda3/envs/uac/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/zack/anaconda3/envs/uac/lib/python3.8/site-packages/vtkmodules/all.py", line 23, in <module>
    from .vtkRenderingVtkJS import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.

For details about using Docker Desktop with WSL 2, visit:

https://docs.docker.com/go/wsl2/


The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.

For details about using Docker Desktop with WSL 2, visit:

https://docs.docker.com/go/wsl2/


The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.

For details about using Docker Desktop with WSL 2, visit:

https://docs.docker.com/go/wsl2/


The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.

For details about using Docker Desktop with WSL 2, visit:

https://docs.docker.com/go/wsl2/


The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.

For details about using Docker Desktop with WSL 2, visit:

https://docs.docker.com/go/wsl2/

python: can't open file 'UAC_code/scripts/labels_la_2.py': [Errno 2] No such file or directory
cp: cannot stat 'Data//Labelled_Labels.elem': No such file or directory
cp: cannot stat 'UAC_code/laplace_files/carpf_laplace_LS.par': No such file or directory
cp: cannot stat 'UAC_code/laplace_files/carpf_laplace_PA.par': No such file or directory
python: can't open file 'UAC_code/scripts/1_la.py': [Errno 2] No such file or directory
=====Old UAC approximation - openCARP command line ()=====
umc-lav_CardioInsight.sh: 88: cd: can't cd to Data//

The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.

For details about using Docker Desktop with WSL 2, visit:

https://docs.docker.com/go/wsl2/


The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.

For details about using Docker Desktop with WSL 2, visit:

https://docs.docker.com/go/wsl2/

=====New UAC=====
cp: cannot stat 'UAC_code/laplace_files/carpf_laplace_single_LR_P.par': No such file or directory
cp: cannot stat 'UAC_code/laplace_files/carpf_laplace_single_UD_P.par': No such file or directory
cp: cannot stat 'UAC_code/laplace_files/carpf_laplace_single_LR_A.par': No such file or directory
cp: cannot stat 'UAC_code/laplace_files/carpf_laplace_single_UD_A.par': No such file or directory
python: can't open file 'UAC_code/scripts/2a_la.py': [Errno 2] No such file or directory

The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.

For details about using Docker Desktop with WSL 2, visit:

https://docs.docker.com/go/wsl2/


The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.

For details about using Docker Desktop with WSL 2, visit:

https://docs.docker.com/go/wsl2/


The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.

For details about using Docker Desktop with WSL 2, visit:

https://docs.docker.com/go/wsl2/


The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.

For details about using Docker Desktop with WSL 2, visit:

https://docs.docker.com/go/wsl2/

=====New UAC part 2=====
python: can't open file 'UAC_code/scripts/2b_la.py': [Errno 2] No such file or directory
=====Add fibres2 =====
python: can't open file 'UAC_code/scripts/fibre_mapping.py': [Errno 2] No such file or directory
=====Add LAT field ()=====
python: can't open file 'UAC_code/scripts/lat_field.py': [Errno 2] No such file or directory
=====Make PV stimulus files .vtx ()=====
```