Pyimagej not converting strings


so I am trying to run a macro + plugins from Python using PyimageJ, but at some point the latter is not converting properly the Java string into a Python string.

The following Python code

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import easygui
import imagej

ij = imagej.init("/home/my_user/Programs/", headless=False)

macro = """
run("Clear Results");

#@output Object filepath_image


filepath_image = File.openDialog("Select an Image File");
file_split = split(filepath_image, ".");

filepath_ROIs = File.openDialog("Choose a Metamorph .rgn File");

result =
path = result.getOutput("filepath_image")


gives me the following output:

<java class 'java.lang.String'>

but when I try to convert this string into a Python string it gets converted into a “xarray.core.dataarray.DataArray”, instead of a Python string.

Any idea of what can be the problem?

PS: I am fairly new to Java, so any help will be very much appreciated. Thank you!