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

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

Open
chriskisskiss opened this issue Jul 5, 2023 · 8 comments
Open
Labels
bug Something isn't working

Comments

@chriskisskiss
Copy link

chriskisskiss commented Jul 5, 2023

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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

@ramroomh
Copy link

ramroomh commented Dec 2, 2023

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
Copy link
Contributor

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

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

@ramroomh
Copy link

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 drmowinckels added the bug Something isn't working label Jan 3, 2024
@drmowinckels
Copy link
Contributor

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
Copy link

ramroomh commented Jan 8, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants