Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with createSurface.py #6

Open
uajosh1 opened this issue May 30, 2024 · 7 comments
Open

Issues with createSurface.py #6

uajosh1 opened this issue May 30, 2024 · 7 comments

Comments

@uajosh1
Copy link

uajosh1 commented May 30, 2024

The freesurfer files that I'm trying to run Hipsta on are from Freesurfer7.2 labeled: rh.hippoAmygLabels-T1.v21.CA.mgz, lh.hippoAmygLabels-T1.v21.CA.mgz

When looking at results through freeview these files are either unable to open or blank:

  • lh.labels.mgz
  • lh.mask.mgz
  • lh.cropped.mgz
  • lh.orig.mgz
  • lh.initial_mask.mgz
  • lh.close_mask.mgz
  • lh.gaussian_filter.mgz
    but lh.image.mgz seems to be fine

This is the error I'm getting:
`Smooth surface

--> VTK format ...
[file not found or not readable]

[ERROR: hipsta.py] Error Information:
[ERROR: hipsta.py] Type: <class 'AttributeError'>
[ERROR: hipsta.py] Value: ("'NoneType' object has no attribute 'rm_free_vertices_'",)
Traceback (most recent call last):
File "/Users/joshuanguyen/.pyenv/versions/3.10.11/envs/myenv/bin/run_hipsta", line 8, in
sys.exit(main())
File "/Users/joshuanguyen/.pyenv/versions/3.10.11/envs/myenv/lib/python3.10/site-packages/hipsta/cli/init.py", line 26, in main
_run_hipsta(args)
File "/Users/joshuanguyen/.pyenv/versions/3.10.11/envs/myenv/lib/python3.10/site-packages/hipsta/hipsta.py", line 840, in _run_hipsta
run_analysis(params)
File "/Users/joshuanguyen/.pyenv/versions/3.10.11/envs/myenv/lib/python3.10/site-packages/hipsta/hipsta.py", line 743, in run_analysis
params = smoothSurface(params)
File "/Users/joshuanguyen/.pyenv/versions/3.10.11/envs/myenv/lib/python3.10/site-packages/hipsta/createSurface.py", line 272, in smoothSurface
triaMesh.rm_free_vertices
()
AttributeError: 'NoneType' object has no attribute 'rm_free_vertices
'`

Please advise

@kdiers
Copy link
Collaborator

kdiers commented Jun 3, 2024

Hello, thanks for your message. I speculate that the issue may be due to using the lh.hippoAmygLabels-T1.v21.CA.mgz and rh.hippoAmygLabels-T1.v21.CA.mgz files, instead of lh.hippoAmygLabels-T1.v21.mgz and rh.hippoAmygLabels-T1.v21.mgz (i.e., no CA suffix). Would using the latter files help?

@uajosh1
Copy link
Author

uajosh1 commented Jun 3, 2024

Thank you! That got me a bit further but now I have a new error - do you know what this might be now?

Computing cube parametrization

--> VTK format ...
--> DONE ( V: 20178 , T: 61793 )

--> VTK format ...
--> DONE ( V: 20178 , T: 16905 )

TriaMesh with anisotropic Laplace-Beltrami
Solver: spsolve (LU decomposition) ...
[ERROR: hipsta.py] Error Information:
[ERROR: hipsta.py] Type: <class 'ValueError'>
[ERROR: hipsta.py] Value: ('all the input arrays must have same number of dimensions, but the array at index 0 has 1 dimension(s) and the array at index 1 has 0 dimension(s)',)
Traceback (most recent call last):
File "/Users/joshuanguyen/.pyenv/versions/3.12.3/bin/run_hipsta", line 8, in
sys.exit(main())
^^^^^^
File "/Users/joshuanguyen/.pyenv/versions/3.12.3/lib/python3.12/site-packages/hipsta/cli/init.py", line 26, in main
_run_hipsta(args)
File "/Users/joshuanguyen/.pyenv/versions/3.12.3/lib/python3.12/site-packages/hipsta/hipsta.py", line 840, in _run_hipsta
_run_analysis(params)
File "/Users/joshuanguyen/.pyenv/versions/3.12.3/lib/python3.12/site-packages/hipsta/hipsta.py", line 783, in _run_analysis
params = computeCubeParam(params)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/joshuanguyen/.pyenv/versions/3.12.3/lib/python3.12/site-packages/hipsta/computeCubeParam.py", line 800, in computeCubeParam
v4c, t4c, i4c, k4c, newVtcs, newVtcsSgn, newTetra = getSeam(
^^^^^^^^
File "/Users/joshuanguyen/.pyenv/versions/3.12.3/lib/python3.12/site-packages/hipsta/computeCubeParam.py", line 519, in getSeam
v4c, t4c, i4c, k4c, e4cBndOpen, newTetra, newVtcs, newVtcsAdj, newVtcsSgn = getSeamCase1(
^^^^^^^^^^^^^
File "/Users/joshuanguyen/.pyenv/versions/3.12.3/lib/python3.12/site-packages/hipsta/computeCubeParam.py", line 88, in getSeamCase1
i4c = np.concatenate((i4c, st.mode(i4c[t4c[i, :]])[0]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 1 dimension(s) and the array at index 1 has 0 dimension(s)
(hipsta_env) (base) joshuanguyen@dhcp-v066-140 Hipsta %

@kdiers
Copy link
Collaborator

kdiers commented Jun 4, 2024

Hm, this may be a bit more tricky. Could you maybe post the command that you used for running the software?

@uajosh1
Copy link
Author

uajosh1 commented Jun 4, 2024

Thank you!

This is the command that I gave:

(hipsta_env) (base) joshuanguyen@dhcp-v066-140 Hipsta % run_hipsta --filename /Users/joshuanguyen/Desktop/ASYM/Data/6049lh.hippoAmygLabels-T1.v21.mgz --hemi lh --lut freesurfer --outputdir /Users/joshuanguyen/Desktop/ASYM/Results

And this was the entire output

`----------------------------------------
Hippocampal shape and thickness analysis

Found output directory /Users/joshuanguyen/Desktop/ASYM/Results
[INFO: logging.py] Starting logging ...
[INFO: logging.py] Logfile: /Users/joshuanguyen/Desktop/ASYM/Results/logfile.txt
[INFO: logging.py] Version: 0.9.1
[INFO: logging.py] Date: 03/06/2024 12:47:07
[INFO: logging.py] Command: /Users/joshuanguyen/.pyenv/versions/3.12.3/bin/run_hipsta --filename /Users/joshuanguyen/Desktop/ASYM/Data/6049lh.hippoAmygLabels-T1.v21.mgz --hemi lh --lut freesurfer --outputdir /Users/joshuanguyen/Desktop/ASYM/Results
[INFO: hipsta.py] Evaluating arguments ...
[INFO: atlases.py] Found internal, modified look-up table for FreeSurfer.
[INFO: hipsta.py] Using /Users/joshuanguyen/Desktop/ASYM/Data/6049lh.hippoAmygLabels-T1.v21.mgz as input file
[INFO: hipsta.py] Using /Users/joshuanguyen/Desktop/ASYM/Results as output directory
[INFO: hipsta.py] Found /Users/joshuanguyen/Desktop/ASYM/Data/6049lh.hippoAmygLabels-T1.v21.mgz
[INFO: hipsta.py] Starting convertFormat() ...


Convert to mgz and copy to output directory

[INFO: hipsta.py] Starting cropImage() ...


Cropping

/Applications/freesurfer/7.2.0/bin/mri_mask -bb 5 /Users/joshuanguyen/Desktop/ASYM/Results/image/lh.orig.mgz /Users/joshuanguyen/Desktop/ASYM/Results/image/lh.orig.mgz /Users/joshuanguyen/Desktop/ASYM/Results/image/lh.cropped.mgz
[INFO: hipsta.py] Starting upsampleImage() ...
[INFO: hipsta.py] Starting copy_image_to_main() ...
[INFO: hipsta.py] Starting autoMask() ...
[INFO: hipsta.py] Starting createLabels() ...


Create labels

/Applications/freesurfer/7.2.0/bin/mri_binarize --i /Users/joshuanguyen/Desktop/ASYM/Results/lh.image.mgz --match 234 236 238 240 246 --o /Users/joshuanguyen/Desktop/ASYM/Results/labels/lh.initial_labels.mgz
/Applications/freesurfer/7.2.0/bin/fscalc /Users/joshuanguyen/Desktop/ASYM/Results/lh.image.mgz mul /Users/joshuanguyen/Desktop/ASYM/Results/labels/lh.initial_labels.mgz --o /Users/joshuanguyen/Desktop/ASYM/Results/labels/lh.initial_labels.mgz
[INFO: hipsta.py] Starting mergeMolecularLayer() ...


Attaching the molecular layer

[INFO: hipsta.py] Starting copy_labels_to_main() ...
[INFO: hipsta.py] Starting binarizeMask() ...
[INFO: hipsta.py] Starting gaussFilter() ...


Gaussian filtering

[INFO: hipsta.py] Starting longFilter() ...
[INFO: hipsta.py] Starting closeMask() ...


Applying closing operation to mask

[INFO: hipsta.py] Starting copy_mask_to_main() ...
[INFO: hipsta.py] Starting extractSurface() ...


Creating surface via marching cube algorithm

/Applications/freesurfer/7.2.0/bin/mri_mc /Users/joshuanguyen/Desktop/ASYM/Results/lh.mask.mgz 1 /Users/joshuanguyen/Desktop/ASYM/Results/surface/lh.initial_surf.vtk 1
[INFO: hipsta.py] Starting remeshSurface() ...
[INFO: hipsta.py] Starting smoothSurface() ...


Smooth surface

--> VTK format ...
--> DONE ( V: 10970 , T: 21936 )

[INFO: hipsta.py] Starting qcPlots() ...
--> VTK format ...
--> DONE ( V: 10970 , T: 21936 )

[INFO: hipsta.py] Starting checkSurface() ...


Check surfaces

--> VTK format ...
--> DONE ( V: 10970 , T: 21936 )

[INFO: check_surface.py] Euler number for /Users/joshuanguyen/Desktop/ASYM/Results/lh.surf.vtk is 2
[INFO: hipsta.py] Starting createTetraMesh() ...


Create tetrahedral mesh

--> VTK format ...
--> DONE ( V: 10970 , T: 21936 )

/Applications/Gmsh.app/Contents/MacOS/gmsh -3 -o /Users/joshuanguyen/Desktop/ASYM/Results/tetra-mesh/lh.tetra-gmsh.vtk /Users/joshuanguyen/Desktop/ASYM/Results/tetra-mesh/lh.tetra.geo
--> VTK format ...
--> DONE ( V: 17313 , T: 67910 )

[INFO: hipsta.py] Starting createTetraLabels() ...


Creating label files for tetrahedral meshes

/Applications/freesurfer/7.2.0/bin/mris_calc --output /Users/joshuanguyen/Desktop/ASYM/Results/tetra-labels/lh.labels-bnd.mgz /Users/joshuanguyen/Desktop/ASYM/Results/tetra-labels/lh.labels-bnd.mgz lowerlimit /Users/joshuanguyen/Desktop/ASYM/Results/tetra-labels/lh.labels-ca4.mgz
--> VTK format ...
--> DONE ( V: 17313 , T: 67910 )

Found 21936 triangles on boundary.
[INFO: hipsta.py] Starting removeBoundaryMask() ...


Removing boundary tetras from mesh

--> VTK format ...
--> DONE ( V: 17313 , T: 67910 )

Found 21936 triangles on boundary.
[INFO: hipsta.py] Starting cutTetra() ...


Cutting tetrahedral mesh

--> VTK format ...
--> DONE ( V: 17313 , T: 67910 )

TetMesh with regular Laplace
Matrix Format now: csc
Solver: spsolve (LU decomposition) ...
/Users/joshuanguyen/.pyenv/versions/3.12.3/lib/python3.12/site-packages/scipy/sparse/_index.py:108: SparseEfficiencyWarning:

Changing the sparsity structure of a csr_matrix is expensive. lil_matrix is more efficient.

Found 21696 triangles on boundary.
Searched mesh after 177 flooding iterations (0.05073904991149902 sec).
[INFO: hipsta.py] Starting checkSurface() ...


Check surfaces

--> VTK format ...
--> DONE ( V: 8787 , T: 16905 )

[INFO: check_surface.py] There are 2 boundary loops for /Users/joshuanguyen/Desktop/ASYM/Results/tetra-cut/lh.rm.open.bnd.cut.vtk
[INFO: hipsta.py] Starting computeCubeParam() ...


Computing cube parametrization

--> VTK format ...
--> DONE ( V: 20178 , T: 61793 )

--> VTK format ...
--> DONE ( V: 20178 , T: 16905 )

TriaMesh with anisotropic Laplace-Beltrami
Solver: spsolve (LU decomposition) ...
[ERROR: hipsta.py] Error Information:
[ERROR: hipsta.py] Type: <class 'ValueError'>
[ERROR: hipsta.py] Value: ('all the input arrays must have same number of dimensions, but the array at index 0 has 1 dimension(s) and the array at index 1 has 0 dimension(s)',)
Traceback (most recent call last):
File "/Users/joshuanguyen/.pyenv/versions/3.12.3/bin/run_hipsta", line 8, in
sys.exit(main())
^^^^^^
File "/Users/joshuanguyen/.pyenv/versions/3.12.3/lib/python3.12/site-packages/hipsta/cli/init.py", line 26, in main
_run_hipsta(args)
File "/Users/joshuanguyen/.pyenv/versions/3.12.3/lib/python3.12/site-packages/hipsta/hipsta.py", line 840, in _run_hipsta
_run_analysis(params)
File "/Users/joshuanguyen/.pyenv/versions/3.12.3/lib/python3.12/site-packages/hipsta/hipsta.py", line 783, in _run_analysis
params = computeCubeParam(params)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/joshuanguyen/.pyenv/versions/3.12.3/lib/python3.12/site-packages/hipsta/computeCubeParam.py", line 800, in computeCubeParam
v4c, t4c, i4c, k4c, newVtcs, newVtcsSgn, newTetra = getSeam(
^^^^^^^^
File "/Users/joshuanguyen/.pyenv/versions/3.12.3/lib/python3.12/site-packages/hipsta/computeCubeParam.py", line 519, in getSeam
v4c, t4c, i4c, k4c, e4cBndOpen, newTetra, newVtcs, newVtcsAdj, newVtcsSgn = getSeamCase1(
^^^^^^^^^^^^^
File "/Users/joshuanguyen/.pyenv/versions/3.12.3/lib/python3.12/site-packages/hipsta/computeCubeParam.py", line 88, in getSeamCase1
i4c = np.concatenate((i4c, st.mode(i4c[t4c[i, :]])[0]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 1 dimension(s) and the array at index 1 has 0 dimension(s)
`

@kdiers
Copy link
Collaborator

kdiers commented Jun 6, 2024

Thank you very much. I have to admit that I am a bit at a loss at the moment, and see no obvious reason for the processing failure. If you can share the particular segmentation file that produces the error I am happy to take a closer look while trying to replicate the issue.

@uajosh1
Copy link
Author

uajosh1 commented Jun 8, 2024 via email

@kdiers
Copy link
Collaborator

kdiers commented Jun 10, 2024

Please find my email on our lab's webpage (trying to post it not on too many different places).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants