Effacer les filtres
Effacer les filtres

Error using chdir ; cannot CD to (Name is nonexistent or not a directory) / permissions error

4 vues (au cours des 30 derniers jours)
I am trying to run the code at the end of this message (obtained from http://www.runmycode.org/companion/view/2798) but cannot get it to run, any ideas woud be really great.
Initially I had a permission denied error:
Error: Permission denied
There was a problem writing to the header of
Error using nifti/create (line 26)
Unable to write header for "/FINAL0_suvr_normalized_infcereg.nii".
After running as root, it got past this but I now get the following error, and it incorrectly saves the FINAL0_suvr_normalized_infcereg.nii and FINAL0_edited_aparc+aseg.nii into the root directory.
Error using chdir
Cannot CD to (Name is nonexistent or not a direcory).
Error in TAU_PVC_RUNME_Create_ROIs_For_Rousset (line 101)
I do not have a lot of matlab experience and was hoping that this may be a simple error of mine?
Thanks in advance for any ideas.
Kind regards,
function []=TAUPVC_RUNME_Create_ROIs_For_Rousset(fname_aparc,fname_suvr,fname_c1,fname_c2,fname_c3,fname_c4,fname_c5,fname_cere,scanner_resolution)
% This function creates a file where each ROI has a different integer value.
% All image files should have the same matrix size and should be coregistered
% and resliced to each other. Inputs are:
% fname_aparc: the path to the aparc+aseg.nii output from
% freesurfer
% fname_suvr: the path to the mean av-1451 file. this does not
% have to be normalized, but data will be normalized
% by inferior cerebellar gray and written out;
% extra-cortical-hotspot threshold is in reference to
% image normalized by inferior cerebellar gray
% fname_c1: output from nu.nii segmented by spm12
% fname_c2: output from nu.nii segmented by spm12
% fname_c3: output from nu.nii segmented by spm12
% fname_c4: output from nu.nii segmented by spm12
% fname_c5: output from nu.nii segmented by spm12
% fname_cere: path to reverse normalize and resliced
% SUIT cerebellar gray template to nu.nii
% scanner_resolution: example [6.5 6.5 7.5]. we calculated this
% for our scanner using a Hoffman phantom (method used in
% Joshi, Koeppe, Fessler from Neuroimage, 2009)
% Load files and check matrix sizes
% 1: aparc 5: c3
% 2: suvr 6: c4
% 3: c1 7: c5
% 4: c2 8: cere
% assign integer values to aparc+aseg defined ROIs
[sz1 sz2 sz3]=size(aparc);
[rnewaparc roigroups]=TAU_PVC_AssignFreeSurferROIs(raparc,rsuvr);
% use SUIT cerebellar template reverse normalized to nu.nii to calculate
% inferior cerebellar gray, add that to rnewaparc such that
% inferior cerebellar gray voxels = 78
[rnewaparc suvr]=TAU_PVC_AddInferiorCereg_FromSUIT(cere,suvr,rnewaparc);
roigroups{78}.name=['inferior_cerebellar_gray']; roigroups{78}.ind=78;
% use freesurfer aparc+aseg choroid and suvr to split choroid into high and
% low values
roigroups{79}.name=['high_choroid_plexus']; roigroups{79}.ind=79;
roigroups{80}.name=['low_choroid_plexus']; roigroups{80}.ind=80;
c3=img{5}.data; c4=img{6}.data; c5=img{7}.data; aparc=img{1}.data;
% add ECH clusters to new aparc, these count up starting from 83, each ECH
% gets its own integer value
for j=1:length(uech)
ind=find(raparc==0 & rECHclusters==uech(j));
roigroups{84+j}.name=['ECH_' num2str(j)]; roigroups{84+j}.ind=84+j;
% add c3 low (81) and high (82) and c4+c5 low (83) and high (84).
% look for voxels=0 in aparc+aseg but are right next to brain ROIs, assign
% to ROIs
roigroups{81}.name=['c3_low']; roigroups{81}.ind=81;
roigroups{82}.name=['c3_high']; roigroups{82}.ind=82;
roigroups{83}.name=['c4+c5_low']; roigroups{83}.ind=83;
roigroups{84}.name=['c4+c5_high']; roigroups{84}.ind=84;
% check for ECHs in cerebellar gray. these count up from the current highest value
% in the new aparc+aseg (rnewaparc) which reflects who many ECHs there were
% in c3/c4/c5 (so if 2 ECHs in c3/c4/c5, those were assigned 83 and 84, if
% 3 ECHs are found in inferior cerebellar gray, those would be 85, 86, 87)
[rnewaparc suvr roigroups]=TAU_PVC_CheckInfCereg_for_hotspots(rnewaparc,suvr,roigroups);
% set ventricles (9999 from TAU_PVC_AssignFreesurferROIs) to 0
% done, reshape, write out new suvr (normalized by inf cerebellar gray)
% and ROIs for Rousset PVC in the directory where the original SUVR lives
[fa fb fc]=fileparts(fname_suvr);
Vsuvr.fname=[fa '/FINAL0_suvr_normalized_infcereg.nii'];
Vaparc.fname=[fa '/FINAL0_edited_aparc+aseg.nii'];
% Run Rousset PVC, save results in roigroups.mat as variable roigroups
save FINAL0_roigroups roigroups

Réponse acceptée

Ken Atwell
Ken Atwell le 24 Nov 2018
Writing to the root of your file system is a bad idea.
Looking at this code, TAUPVC_RUNME_Create_ROIs_For_Rousset takes a number of arguments. The second argument, fname_suvr, is a file name and its folder location is also the location where the FINAL0... files get written to (see the call to fileparts).
In short, make sure the filename given in the second argument is at some location that is also a reasonable place for files to be written to.

Plus de réponses (1)

Josh King-Robson
Josh King-Robson le 24 Nov 2018
I think I have fxed this now, I added
oldfolder = cd
to the beginning and then changed the final 'fa' locations to oldfolder.
Unless it messes up something else?




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by