# Slicer Morph GPA | Interactive 3D vizualization | Cannot warp around PCs

**URL:** <https://discourse.slicer.org/t/slicer-morph-gpa-interactive-3d-vizualization-cannot-warp-around-pcs/44416>\
**Category:** Support\
**Created:** [September 9, 2025, 3:49pm UTC](https://discourse.slicer.org/t/slicer-morph-gpa-interactive-3d-vizualization-cannot-warp-around-pcs/44416 "2025-09-09T15:49:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![macorreia42](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/macorreia42/32/80835_2.png) [@macorreia42](https://discourse.slicer.org/u/macorreia42)\
**Post date:** [September 9, 2025, 3:49pm UTC](https://discourse.slicer.org/t/slicer-morph-gpa-interactive-3d-vizualization-cannot-warp-around-pcs/44416/1 "2025-09-09T15:49:01Z")

</div>

Operating system: Windows 11 Home  
Slicer version: 5.8.1 r33241 / 11eaf62  
Expected behavior: reference model warps around PCs  
Actual behavior: Critical error TypeError: unsupported operand type(s) for -: ‘str’ and ‘int’

Hello,  
My 3DSlicer and SlicerMorph are up to date. The full error log is

> Traceback (most recent call last):  
> File “C:/Users/corre/AppData/Local/slicer.org/Slicer 5.8.1/slicer.org/Extensions-33241/SlicerMorph/lib/Slicer-5.8/qt-scripted-modules/GPA.py”, line 1777, in onSelect  
> indexToRemove.append(self.LMExclusionList[i]-1)  
> TypeError: unsupported operand type(s) for -: ‘str’ and ‘int’

For context, my workflow is: place landmarks on 3Dslicer, export as .mrk.json, import into R using `SlicerMorphR::read.markups.json()`, convert into into an array 3D (code below in case that’s the source), estimate missing landmarks using `geomorph::estimate.missing()`, conduct GPA using `geomorph::gpagen()` and PCA using `geomorph::gm.prcomp()` on aligned coordinates, and export using `SlicerMorphR::geomorph2slicermorph2()`, and import into 3D slicer using the Load previous analysis. The subjects load and I can ExploreData/Results normally, and the output from `geomorph2slicermorph2()` looks “normal” to me.

I’m following this [tutorial](https://github.com/SlicerMorph/SlicerMorphR), except for the transformation to array (because mine is differently sized and I made it in a more intuitive way for me). ChatGPT suggested I mess with the Python file (`GPA.py`), by “casting the string to int before subtracting”, but I don’t know Python and I thought I’d try here first.

Very recent user of 3DSlicer and my first time posting. Thankful for any help.

My code for creating the array3d:

`json_paths ← list.files(raw_dir, pattern = “\.json$”, full.names = TRUE)`  
`specimen_ids ← tools::file_path_sans_ext(basename(json_paths))`

```auto
4) Read JSON into numeric matrices
read_lmk_matrix ← function(path) {
m ← SlicerMorphR::read.markups.json(path)
m ← as.matrix(m)
m ← apply(m, 2, as.numeric)
if (is.null(colnames(m))) colnames(m) ← c(“X”, “Y”, “Z”)
m
}
landmark_list ← purrr::map(json_paths, read_lmk_matrix) |> purrr::set_names(specimen_ids)

5) Build array3d
p ← nrow(landmark_list[[1]])
k ← 3
n ← length(landmark_list)

array3d ← array(
NA_real_,dim = c(p, k, n),
dimnames = list(
landmark = seq_len(p),
coord = c(“X”, “Y”, “Z”),
specimen = names(landmark_list)
)
)
for (i in seq_along(landmark_list)) array3d[, , i] ← landmark_list[[i]]
storage.mode(array3d) ← “double”

```

This produces an object like this

```auto
str(array3d)
 num [1:21, 1:3, 1:11] 25.4 23.3 22.6 23.1 25.5 ...
 - attr(*, "dimnames")=List of 3
  ..$ landmark: chr [1:21] "1" "2" "3" "4" ...
  ..$ coord : chr [1:3] "X" "Y" "Z"
  ..$ specimen: chr [1:11] "ILH_Zvejnieki_34.107.217.mrk" "ILH_Zvejnieki_34.115.228.mrk" "ILH_Zvejnieki_34.116.229.mrk" "ILH_Zvejnieki_34.118.328.mrk" ...

```

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [September 9, 2025, 4:43pm UTC](https://discourse.slicer.org/t/slicer-morph-gpa-interactive-3d-vizualization-cannot-warp-around-pcs/44416/2 "2025-09-09T16:43:34Z")

</div>

I can’t replicate this error with SlicerMorph SampleData. Can you:

1. Go to extension manager, click **check for updates** and see if there is a more recent SlicerMorph version and tr
2. Share your data.

---

<div class="post-metadata">

**Author:** ![macorreia42](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/macorreia42/32/80835_2.png) [@macorreia42](https://discourse.slicer.org/u/macorreia42)\
**Post date:** [September 9, 2025, 4:52pm UTC](https://discourse.slicer.org/t/slicer-morph-gpa-interactive-3d-vizualization-cannot-warp-around-pcs/44416/3 "2025-09-09T16:52:29Z")

</div>

UPDATE: If I go to the `analysis.json` file and change`“ExcludedLM”: "[]"` to `“ExcludedLM”: []`and`“SemiLandmarks”: "[]"` to `“SemiLandmarks”: []`, it works.

yes, it’s up to date, following Extensions \> Check for Updates.  
Here is a [link](https://drive.google.com/drive/folders/1ePJXx6_8vSkhaXldT9fU47sHxkxZgl1M?usp=drive_link) for my R directory backup, in the data folder, there’s some .mrk.json in raw and the geomorph2slicermorph2() output is in derived data. I’d share the GitHub, but it doesn’t have the raw data.

Thank you

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [September 10, 2025, 2:36am UTC](https://discourse.slicer.org/t/slicer-morph-gpa-interactive-3d-vizualization-cannot-warp-around-pcs/44416/4 "2025-09-10T02:36:32Z")

</div>

I am sorry, I am a bit confused. Is this error coming during the GPA of original data in SlicerMorph or when you are trying to move results from geomorph to SlicerMorph using SlicerMorphR?

---

<div class="post-metadata">

**Author:** ![macorreia42](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/macorreia42/32/80835_2.png) [@macorreia42](https://discourse.slicer.org/u/macorreia42)\
**Post date:** [September 10, 2025, 6:11am UTC](https://discourse.slicer.org/t/slicer-morph-gpa-interactive-3d-vizualization-cannot-warp-around-pcs/44416/5 "2025-09-10T06:11:21Z")

</div>

The error log is from SlicerMorph when setting up the interactive 3D visualization. So, I’ve already exported the GPA+PCA results from geomorph using SlicerMorphR, uploaded them into SlicerMorph, and I’m trying to visualise it, producing that error log.  
However, the workaround above involves editing the analysis.json file produced via SlicerMorphR, by removing the ““ around the square brackets, **before** uploading the GPA+PCA into 3DSlicer/SlicerMorph.  
It’s not ideal so you have any input, it’d be appreciated.

---

<div class="post-metadata">

**Author:** ![macorreia42](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/macorreia42/32/80835_2.png) [@macorreia42](https://discourse.slicer.org/u/macorreia42)\
**Post date:** [September 10, 2025, 8:01am UTC](https://discourse.slicer.org/t/slicer-morph-gpa-interactive-3d-vizualization-cannot-warp-around-pcs/44416/6 "2025-09-10T08:01:22Z")

</div>

Here is a [link](https://drive.google.com/drive/folders/1N_XMV7bAv9eFuZqyj9muf_UkeAKMhqlH?usp=sharing) for some .mrk.json data, and for the GitHub [repo](https://github.com/macorreia42/zvej_mandibles.git)  
(I had to break the previous link)

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [September 10, 2025, 3:20pm UTC](https://discourse.slicer.org/t/slicer-morph-gpa-interactive-3d-vizualization-cannot-warp-around-pcs/44416/7 "2025-09-10T15:20:04Z")

</div>

landmark configuration includes missing landmarks, so I can’t run them with GPA. I presume you used geomorph to estimate those. I am not sure why you are getting an extra set of ““ from the geomorph2slicermorph2 to function, as it doesn’t happen for me.

I am glad you figured out your work around.

---

<div class="post-metadata">

**Author:** ![macorreia42](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/macorreia42/32/80835_2.png) [@macorreia42](https://discourse.slicer.org/u/macorreia42)\
**Post date:** [September 12, 2025, 10:54am UTC](https://discourse.slicer.org/t/slicer-morph-gpa-interactive-3d-vizualization-cannot-warp-around-pcs/44416/8 "2025-09-12T10:54:07Z")

</div>

I deleted the files with missing landmarks, if you have time/patience to try again, but yes, it seems that the issue is on the geomorph2slicermorph2 output.
