No CSV file in DiffusionMessurements folder in WMA

Hi there, I am doing whitematteranalysis along with WMA tutorial: https://github.com/SlicerDMRI/whitematteranalysis/blob/master/doc/subject-specific-tractography-parcellation.md. In the last step of tutorial, " 8. Fiber tract diffusion measurements", I could not get any CSV file in the created new DiffusionMeasurements folder with error message of below:

brain@l4n:~/Desktop/WMA_tutorial_data$ wm_diffusion_measurements.py ./FiberClustering/SeparatedClusters/tracts_commissural/ ./DiffusionMeasurements/commissural_clusters.csv /home/brain/Downloads/Slicer-5.2.2-linux-amd64/NA-MIC/Extensions-31382/SlicerDMRI/lib/Slicer-5.2/cli-modules/FiberTractMeasurements
Importing whitematteranalysis package.
<wm_diffusion_measurements>. Starting scalar measurement extraction.

=====input directory======
./FiberClustering/SeparatedClusters/tracts_commissural/
=====output directory=====
./DiffusionMeasurements
=====3D Slicer====
/home/brain/Downloads/Slicer-5.2.2-linux-amd64/NA-MIC/Extensions-31382/SlicerDMRI/lib/Slicer-5.2/cli-modules/FiberTractMeasurements

/home/brain/Downloads/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: ./DiffusionMeasurements/commissural_clusters.csv

This is happened to both tutorial data and my own DTI data, and either input is SeparatedClusters or AnatomicalTracts. I think the folder structure for SlicerDMRI in my PC is correct.
Anyone who has advice on this issue?

Thank you,
Fumi

Hi,

Please try Slicer launcher to call the fiber measurement module:

wm_diffusion_measurements.py ./FiberClustering/SeparatedClusters/tracts_commissural/ ./DiffusionMeasurements/commissural_clusters.csv “/home/brain/Downloads/Slicer-5.2.2-linux-amd64/Slicer --launch FiberTractMeasurements”

Regards,
Fan

Hi Fan, thank you for a very quick reply. I tried your command, but it was error again:

wm_diffusion_measurements.py ./FiberClustering/SeparatedClusters/tracts_commissural/ ./DiffusionMeasurements/commissural_clusters.csv “/home/brain/Downloads/Slicer-5.2.2-linux-amd64/Slicer --launch FiberTractMeasurements”
Importing whitematteranalysis package.
usage: wm_diffusion_measurements.py [-h] [-v] inputDirectory outputCSV Slicer
wm_diffusion_measurements.py: error: unrecognized arguments: --launch FiberTractMeasurements”

Do you know why this is happen?

Thanks a lot!

Fumi

Hi,
experiencing the very same error using Slicer 5.2.2 on Ubuntu 22.04 and when calling the measurement module through the wm_apply_ORG_atlas_to_subject.sh WMA script:

as

wm_apply_ORG_atlas_to_subject.sh -i my_tractogram.vtk -o WMA -a /path/to/org_atlas/ORG-Atlases-1.2 -s /opt/Slicer-5.2.2-linux-amd64/Slicer -d 1 -m /opt/Slicer-5.2.2-linux-amd64/NA-MIC/Extensions-31382/SlicerDMRI/lib/Slicer-5.2/cli-modules/FiberTractMeasurements -c 2 -n 4

The library is there of course,

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

but the script/Slicer is unable to locate it.

Instead, if I try to call the Python module directly from the command line, Slicer is unable to load the tractography data:

wm_diffusion_measurements.py /path/to/AnatomicalTracts /path/to/clusters.csv /opt/Slicer-5.2.2-linux-amd64/Slicer
Importing whitematteranalysis package.
<wm_diffusion_measurements>. Starting scalar measurement extraction.

=====input directory======
 /path/to/AnatomicalTracts
=====output directory=====
 /path/to/
=====3D Slicer====
 /opt/Slicer-5.2.2-linux-amd64/Slicer
==========================
Switch to module:  "Welcome"
Ignore argument received via command-line (not a valid URL or existing local file):  "--inputtype"
Ignore argument received via command-line (not a valid URL or existing local file):  "Fibers_File_Folder"
Ignore argument received via command-line (not a valid URL or existing local file):  "--format"
Ignore argument received via command-line (not a valid URL or existing local file):  "Column_Hierarchy"
Ignore argument received via command-line (not a valid URL or existing local file):  "--separator"
Ignore argument received via command-line (not a valid URL or existing local file):  "Comma"
Ignore argument received via command-line (not a valid URL or existing local file):  "--inputdirectory"
Local filepath received via command-line:  " /path/to/AnatomicalTracts"
Ignore argument received via command-line (not a valid URL or existing local file):  "--outputfile"
Ignore argument received via command-line (not a valid URL or existing local file):  " /path/to/clusters.csv"
static void qSlicerIOManager::showLoadNodesResultDialog(bool, vtkMRMLMessageCollection*) Errors occurred while loading nodes: "Error: Loading /path/to//AnatomicalTracts -  load failed.\n"
Switch to module:  ""
Switch to module:  ""
<wm_diffusion_measurements> Measurements done at: /path/to/clusters.csv

Any suggestion to make this work one way or the other?

Hi, this issue is very similar to my problem. I tried many things on this topic, using some version of slicer, even on Mac and Windows. I noticed even I tried TractographyMeasurement on GUI, I couldn’t get any CSV file in folder like you mentioned in another topic.

Bacause I was running of time, I gave up using Slicer for my tract study.
Hope you can solve this issue!

Hi @Fumi @jhlegarreta

I looked in the the issue that you were facing.

On MacOS (mine is Ventura 13.2.1), it is working properly for me as it is. Please see the below screenshot for my setting to run the wm_diffusion_measurements script using Slicer 5.2.2 stable release:

On Ubuntu (mine is 20.04.4 LTS), I also saw the issue about missing lib files when using Slicer 5.2.2 when directly call the FiberTractMeasurements module in the CLI mode. In this case, we would need to use Slicer Launcher to call the module so the program can set all the required libs. Please see the following screenshot for how this is being set. Please be noted of the red underline part. One change to what we did before is that the full path of the FiberTractMeasurements module is needed rather than the name of the module.

Hope this will fix the issue you have here. Please let us know if you have further questions.

Thank you!

Regards,
Fan

That worked @zhangfanmark ! Thanks.

I will propose a PR to cover the Linux case in the related documentation as the only difference is the contents of the argument related to the module.

I noticed even I tried TractographyMeasurement on GUI, I couldn’t get any CSV file in folder like you mentioned in another topic.

True, the above does not solve the file not being computed using the GUI. I will open an issue in the SlicerDMRI repository.

OK, I figured out how to obtain the bundle stats using the GUI when specifying a folder (using the Fibers_File_Folder mode):

The stats are computed and written to the specified CSV file.

I could not make it work when trying to compute the stats using the Fiber_Hierarchy mode: a 0-sized file is written: @lassoan @pieper @zhangfanmark Am I correct when assuming that if I load a number of bundles (or an MRML created out of them) the Fibers_Hierarchy mode should work as fine as when using the Fibers_File_Folder option? Is there something else we should do to actually “create a hierachy”? TheFibers Hierarchy mode has the options Rename current ModelHierarchy and Delete current ModelHierarchy but when clicking no actions seems to be taken.

1 Like

I’m not sure - maybe @zhangfanmark or @ljod knows if the Fibers_Hierarchy option is still valid. My guess is that the feature was added in an older Slicer version (there used to be a Model Hierarchy concept that has been replaced by the more general Subject Hierarchy in current Slicer versions). Unless there’s a strong need and some resources to investigate updating this feature, the easiest option would be to just remove the XML and C++ code.

As a side note, this module is an example of an older style of Slicer module that tried to abstract the GUI in XML and it made certain features like this one kind of clunky. In modern Slicer we’d try to create a more convenient interface using python scripting and then call the C++ code with all the arguments managed by the python code.

1 Like

Hi @jhlegarreta

As Steve said the Fibers_Hierarchy is an old style of Slicer module. It is helpful when we created the atlas where multiple clusters form a tract. In this case, we can compute measure from not only tracts but also individual clusters. Currently, our use case is mostly Fibers_File_Folder, so you don’t need to worry about this. We want to keep this option so we can track back what we did before. To use this function, yes, you need to create a hierarchy or use an existing defined in a mrml file.

Regards,
Fan

Not sure I understand the difference: whenever I load a number of tractograms in a SW, I would tend to think that I can compute features out of these. If within the Slicer realm a hierarchy must be created in order to do this, does it make sense to create a default one (e.g. including all loaded data)? I understand that computing measurements for individual clusters or at different levels is relevant, but IMHO the same principle applies if I consider that my clusters are those files that I loaded into Slicer. I am happy to help fixing this.

Yesterday I tried loading a number of tractography data into Slicer, created what seemed to be a hierarchy by creating a subject, then saved the scene as an MRML and the CSV written had still no contents. So there is something else that must be done.

I don’t believe there is a way to create the deprecated Model Hierarchy via the GUI anymore.

There’s some discussion here:

I don’t recall that anyone worked on adding Subject Hierarchy support to the CLIs, probably because, as I mentioned, writing the CLI GUI in XML always resulted in clunky interfaces for anything other than the simplest workflows. I don’t think it would be hard to write a better GUI for the tractography measurements module (at least that’s what I’d do if I wanted to work on this).

@jhlegarreta note that with the Data Module you can right-click on a folder and choose Export to file and save all contents to a temp folder and then run the tractography analysis on them.

Not sure I understand: if trying to launch the analysis on the loaded tractography data does not work, users should be warned about it or the feature should direct/force users to choose a directory. I still think that, as it is the case with other features, one would expect any processing/analysis to be applied to the data loaded into Slicer without needing to first export it to a folder.

Yes, I agree - I was just suggesting a workraound.