Slicer FiberTractMeasurements unable to find libSlicerBaseLogic

Hi,
I am trying to run WMA on a given dataset. The process runs fine until the moment where the FiberTractMeasurements module in Slicer is called. The tool writes the following to the std output:

<wm_apply_ORG_atlas_to_subject> Report diffusion measurements of fiber clusters.
Importing whitematteranalysis package.
<wm_diffusion_measurements>. Starting scalar measurement extraction.

=====input directory======
 {my_data}/FiberClustering/SeparatedClusters/tracts_commissural
=====output directory=====
 {my_data}/FiberClustering/SeparatedClusters
=====3D Slicer====
 /opt/Slicer-5.2.2-linux-amd64/NA-MIC/Extensions-31382/SlicerDMRI/lib/Slicer-5.2/cli-modules/FiberTractMeasurements
==========================
/opt/Slicer-5.2.2-linux-amd64/NA-MIC/Extensions-31382/SlicerDMRI/lib/Slicer-5.2/cli-modules/FiberTractMeasurements:
error while loading shared libraries: libSlicerBaseLogic.so: cannot open shared object file: No such file or directory

<wm_diffusion_measurements>
Measurements done at: {my_data}/FiberClustering/SeparatedClusters/diffusion_measurements_commissural.csv

No CSV file is effectively written after the libSlicerBaseLogic library not being found. A find shows that the library is there:

$ find /opt/Slicer-5.2.2-linux-amd64/ -name libSlicerBaseLogic.so
/opt/Slicer-5.2.2-linux-amd64/lib/Slicer-5.2/libSlicerBaseLogic.so

I had a look at the CDash dashboard, including the Linux SlicerDMRI build but did not find any relevant information.

How can I investigate/debug further/fix this issue?

I have tried computing the measures from the GUI but no file is being written.

Thanks.

I’m guessing that this script was developed on Mac, where the shared library paths are baked into the executable. On linux you need to use Slicer’s launch environment. Easiest would be to run

Slicer --launch bash

to create a shell with the right environment and run the whitematteranalysis scripts in that shell.

Thanks for the answer Steve.

The script I am using calls to wm_apply_ORG_atlas_to_subject.sh, but it is not being found within Slicer’s launch environment:

wm_apply_ORG_atlas_to_subject.sh: not found

If I give it its absolute path, then the immediately next WMA script called by the former (wm_register_to_atlas_new.py) is not found. Adding the absolute path where the WMA scripts are installed to the PATH env variable does not help either.

Slicer comes with a Python 3.9 version; my default is Python 3.10, and have installed WMA following the website’s instructions. A pip show whitematteranalysis within the launch environment results in a

ModuleNotFoundError: No module named 'importlib.readers'

Do I need to install it within Slicer’s launch environment?

I haven’t used whitematteranalysis much, but yes, when I did it I used Slicer’s python environment.

Maybe @zhangfanmark or @ljod can suggest where to look for instructions?

BTW, I now realize that another discourse thread reported the same error in another discourse threadh, and that I even confirmed that I was having the issue:

Sorry for the cross-posting :upside_down_face:.

This has also been reported to the WMA repository as an ongoing issue:

Another element in the WMA folder that may play a role in all this is this one:

Not sure this is necessary, even on macOS (the INSTALLFOLDER is certainly a hard-coded macOS path); even if the parent folder says slicer, there are no paths related to Slicer in this script.

Hi I hope Fan can chime in because he wrote this part and uses it frequently @zhangfanmark

@lassoan @pieper Where can we start investigating this? I am very much willing to help fixing this. Thanks.

At one point I worked on applying the WMA pipeline to sets of data and ran the whole process out of Slicer’s python environment, including the part where it launched the FiberTractMeasurements. This code includes some odd workarounds (like calling eddy current correction on a remote machine) but it did basically work so you might be able to start from here:

Thanks Steve.

Not sure this would work, as even when I try to use the “FiberTractMeasurements” module from within the GUI no CSV/output is being written. Anyways, gave it a try with a reduced version of your script (with the paths adapted to my case):

Launched from a terminal like

$ ./Slicer --no-main-window --python–script ~/path/to/fibertractmeasurements_slicerpy.py

It fails with

qSlicerMarkupsModulePrivate::addToolBar: no main window is available, toolbar is not added
qSlicerSequencesModulePrivate::addToolBar: no main window is available, toolbar is not added
Ignore argument received via command-line (not a valid URL or existing local file):  "--pythonâ\u0080\u0093script"Local filepath received via command-line:  "/home/path/to/fibertractmeasurements_slicerpy.py"
virtual bool qSlicerFreeSurferImporterScalarOverlayReader::load(const IOProperties&)  failed: missing fileName or modelNodeId property
static void qSlicerIOManager::showLoadNodesResultDialog(bool, vtkMRMLMessageCollection*) Errors occurred while loading nodes: "Error: Loading /home/path/to/fibertractmeasurements_slicerpy.py -  load failed.\n"

The script does exist in the provided path.

If I try a simple

$ ./Slicer --no-main-window --python-code "print("Hello")"

I get an error

qSlicerMarkupsModulePrivate::addToolBar: no main window is available, toolbar is not added
qSlicerSequencesModulePrivate::addToolBar: no main window is available, toolbar is not added
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'Hello' is not defined

So what am I missing?

Hi Jon,

Please take a look at my reply in the other post, which should fix the issue you have here:

Regards,
Fan

So the solution in the other post worked for me. Thanks @zhangfanmark.