ggseg / ggsegExtra

Repository for extra atlases for the ggseg-package
https://ggseg.github.io/ggsegExtra/
Other
47 stars 17 forks source link

sh: 1: source: not found when calling make_volumetric_ggseg() #57

Open chriskisskiss opened 1 year ago

chriskisskiss commented 1 year ago

Hello,

when calling

aseg2 <- make_volumetric_ggseg(
 label_file = file.path("freesurfer::fs_subj_dir()", "fsaverage5", "mri/aseg.mgz"),
 slices = slices,
 vertex_size_limits = c(10, NA)
)

I get

%% Preparing labels
%% Splitting atlas file into labels
sh: 1: source: not found
source '/usr/local/freesurfer/7.4.1/FreeSurferEnv.sh' || true ; mri_convert "freesurfer::fs_subj_dir()/fsaverage5/mri/aseg.mgz"   "/tmp/RtmpjyqgjX/file2bb4a9507a4.nii.gz";

sh: 1: source: not found
sh: 1: mri_convert: not found
Error in oro.nifti::readNIfTI(..., reorient = reorient) : 
  File(s) not found!

Obviously, sh doesn't know the source command - but why is sh used? in FreeSurferEnv.sh first line is #!/bin/bash -p. System: Ubuntu 22 running newest RStudio Server.

Thank you very much!

drmowinckels commented 1 year ago

Hey.

This originated in the freesurfer R package, not from this package it self. I'm not the best to answer why its sourced, but from my experience, its very much needed to make the freesurfer functions be available to your R session to call upon.

https://github.com/muschellij2/freesurfer/blob/master/R/mri_convert.R

@muschellij2 I dont know if you might have some illuminating input into why this would not work on Ubuntu?

muschellij2 commented 1 year ago

You're quoting freesurfer::fs_subj_dir() instead of using the code itself. Can you try:

aseg2 <- make_volumetric_ggseg(
 label_file = file.path(freesurfer::fs_subj_dir(), "fsaverage5", "mri/aseg.mgz"),
 vertex_size_limits = c(10, NA)
)
drmowinckels commented 1 year ago

ah @muschellij2 thanks for seeing that! I didnt notice the quotation marks.

ramroomh commented 9 months ago

Hi all,

First I want to say thanks for making this package.

Second, I am trying to create a 3d subcortical atlas used the aseg2_3d command, following instructions here

aseg2_3d <- make_volumetric_2_3datlas(
  subject = "fsaverage5",
  subjects_dir = freesurfer::fs_subj_dir(),
  template = "/home/mrspecial/Documents/atlases/tian2020/nifty/Tian_Subcortex_S2_3T.fs5.mgz",
  color_lut = "/home/mrspecial/Documents/atlases/tian2020/nifty/Tian2020ColorLUT.txt",
  output_dir = "/home/mrspecial/Documents/atlases/tian2020/3d"
)

Aslo get an sh: 1: source: not found error, using Ubuntu 22.04.3 LTS and R 4.3.2

Not using any quotations

muschellij2 commented 9 months ago

Did this run? The source not found isnt' an error necessarily.

Can you try options(freesurfer_source_function = ".") and rerun?

ramroomh commented 8 months ago

It did not run, here is the error message I get, even after adding the suggested option:

Error in 1:dim(plys)[2] : argument of length 0 In addition: Warning message: In mclapply(seq_len(n), do_one, mc.preschedule = mc.preschedule, : 33 function calls resulted in an error Looking at the output directory, surf has 66 items, a _filled.mgz + _notsmooth file for each parcel (I'm assuming), but ply and ascii are empty.

drmowinckels commented 8 months ago

I have a kind of full January already, but I'll try diving into this asap. Any chance you can provide the mgz and lut for me, so I have the same data to test on?

ramroomh commented 8 months ago

Thank you! Sure, attached. Tian.zip

FYI, here is the python code I used to make the .mgz (ANTsPy)

import ants
source = ants.image_read('Tian_Subcortex_S2_3T.nii.gz')
target = ants.image_read('/freesurfer/subjects/fsaverage5/mri/T1.mgz')
mytx = ants.registration(fixed=target, moving=source, type_of_transform = 'Rigid')
tianfsaverage5 = ants.apply_transforms(fixed=target, moving=source, transformlist=mytx['fwdtransforms'], interpolator='nearestNeighbor')
ants.image_write(tianfsaverage5, 'Tian_Subcortex_S2_3T.fs5.nii.gz')

Then using freesurfer:

mri_convert Tian_Subcortex_S2_3T.fs5.nii.gz Tian_Subcortex_S2_3T.fs5.mgz

Original atlas file can be found here.