TractSeg icon indicating copy to clipboard operation
TractSeg copied to clipboard

Plot 3D error: Could not find: " + mask_path

Open Hmc1231 opened this issue 2 years ago • 11 comments

Hi,

Thanks for all your effort with tractseg, I've really enjoyed getting to use it.

My current problem is that I cannot get the plot3D function to work. I'm almost sure I've correctly specified the locations of the tractseg_output file on line three of my subjects.txt file however I keep getting: ValueError("Could not find: " + mask_path).

Do I need to further specify the directory where my .tck files and nodif_brain_mask.nii.gz files are stored after the --tracking_dir in the command line?

Hmc1231 avatar Aug 26 '22 13:08 Hmc1231

Could you specify what your folder structure looks like and what your command to call plot_tractometry_results looks like?

wasserth avatar Aug 29 '22 09:08 wasserth

Thanks for getting back to me. I've now solved this problem by putting my nodif_brain_mask.nii.gz file in the subject13 folder rather than having it in the tractseg_output folder. unsure why it was unable to be found in the tractseg_output folder.

The command I used was: plot_tractometry_results -i /Tractseg/subject13/tractseg_output/subjects.txt -o tractometry_result.png --mc --plot3D metric --tracking_dir auto --tracking_format tck.

However, now I am getting this new error message:

/miniconda3/envs/myenv/lib/python3.9/site-packages/numpy/core/_asarray.py:102: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray. return array(a, dtype, copy=False, order=order) Segmentation fault (core dumped)

Hmc1231 avatar Aug 30 '22 13:08 Hmc1231

Could you try again with the following versions:

pip install --upgrade numpy==1.21.5
pip install --upgrade fury==0.8.0
pip install --upgrade dipy==1.5.0

wasserth avatar Aug 30 '22 13:08 wasserth

with those upgrades it now returns:

File "/miniconda3/envs/myenv/bin/plot_tractometry_results", line 20, in from tractseg.libs import plot_utils File "/miniconda3/envs/myenv/lib/python3.9/site-packages/tractseg/libs/plot_utils.py", line 22, in from tractseg.libs import fiber_utils File "/miniconda3/envs/myenv/lib/python3.9/site-packages/tractseg/libs/fiber_utils.py", line 10, in from dipy.tracking.streamline import compress_streamlines as compress_streamlines_dipy ImportError: cannot import name 'compress_streamlines' from 'dipy.tracking.streamline' (/miniconda3/envs/myenv/lib/python3.9/site-packages/dipy/tracking/streamline.py)

Hmc1231 avatar Aug 30 '22 14:08 Hmc1231

Which version of TractSeg are you using? You might have to upgrade TractSeg to the latest version.

pip install --upgrade TractSeg

wasserth avatar Aug 31 '22 10:08 wasserth

I've now managed to get it to work by running it on a node with centos8 rather than centos7 which I had been running on. It still gives the error:

/miniconda3/envs/myenv/lib/python3.9/site-packages/numpy/core/_asarray.py:102: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray. return array(a, dtype, copy=False, order=order) Segmentation fault (core dumped)

But then produces the output anyway. Unsure what it is about centos8 which makes this work. Thanks very much for your input.

Hmc1231 avatar Aug 31 '22 13:08 Hmc1231

Not sure what the problem is, but I am happy to hear that it finally works.

wasserth avatar Aug 31 '22 14:08 wasserth

Hi, having a similar issue here. First I had to place nodif_brain_mask.nii.gz at the top level of the subject folders to avoid the first error @Hmc1231 reported. But now I keep getting the same seg fault. I'm running TractSeg 2.7 in a python 3.7 conda environment.

/home/username/.conda/envs/TractSegEnv/lib/python3.7/site-packages/fury/utils.py:288: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
  cols_arr = np.asarray(colors)
Segmentation fault (core dumped)

My folder structure may be the issue, not sure:

subjectID/
  FODs/
  preproc/
  tractometry_output/
  tractseg_output/
    bundle_segmentations/
    endings_segmentations/
    TOM/
    TOM_trackings/

My command is:

plot_tractometry_results \
-i Tractometry/Design.txt \
-o Tractometry/ouput.png \
--plot3D metric \
--tracking_dir TOM_trackings

Thanks!

mrribbits avatar Sep 21 '22 18:09 mrribbits

Problem solved: I ran the above on my local Ubuntu 22 machine and while the same error message appeared (minus the seg fault line), it did generate the 3D bundle png files with the metric (_AF_left_3D.png, _AF_right_3D.png, and so on).

Previously I was trying to run it on our institutions cluster, so I suspect the seg fault was due to needing some local graphics/OpenGL capability to generate these pngs.

mrribbits avatar Sep 22 '22 18:09 mrribbits

I am happy to hear that it worked. Yes, you have to run it on a computer with a display.

wasserth avatar Sep 23 '22 08:09 wasserth

Re: the original mask_path error, I narrowed it down to the path building line 268 in plot_tractometry_results.

It joins the plot_3D path in subjects.txt (i.e., the tractseg_output folder) with ../nodif_brain_mask.nii.gz. The .. causes it to look for the nodif_brain_mask.nii.gz file in 1 folder level above what you've set as the plot_3D path - that's why it worked for @Hmc1231 when they put the file in the subject folder.

j-tseng avatar Sep 28 '22 19:09 j-tseng