Below is my code. I am trying to gain write access, and am confused why all of a sudden I am not getting access, as I have saved to 'D:' just fine previously. It is not a space issue for a fact. Any help with how to gain write access would be great! I already went into properties and made sure I had admin rights and all that. I also ran Matlab as an admin as well but same error. Much thanks in advance!!
I'm operating on a Windows 10 pro and am using Matlab R2019a.
ERROR MESSAGE:
>> anovan_analysis
Error using aft_SaveAs (line 132)
Error saving file D:/SAMP/Variability_Project/Code/Creating_MDMsGLMs/3X3X3_3maps.vmp: Error moving file
'D:\SAMP\Variability_Project\Code\Creating_MDMsGLMs\Brodmann-Area-01\anova_effect.vmp.tmp' to
'D:\SAMP\Variability_Project\Code\Creating_MDMsGLMs\Brodmann-Area-01\anova_effect.vmp': Cannot write to
destination: D:\SAMP\Variability_Project\Code\Creating_MDMsGLMs\Brodmann-Area-01\anova_effect.vmp. Use
the 'f' option to override...
Error in xff/subsref (line 159)
[varargout{1}] = feval(tfm{6}, xo, fargs{:});
Error in anovan_analysis (line 152)
f_Map.SaveAs('anova_effect.vmp');
MY CODE:
%% Grab Data
%Enter the Brodmann areas you are testing here
areas = ["01","02","03","04","05","06","07","08","09","10","11","12","13","17","18","19"...
,"20","21","22","23","24","25","27","28","29","30","31","32","33","34","35"...
,"36","37","38","39","40","41","42","43","44","45","46","47"];
name = 'D:\SAMP\Variability_Project\Code\Creating_MDMsGLMs\Brodmann-Area-';
%This forloop loops through all the Brodmann area glms in their respective
%folders
for i = 1
new_name = strcat(name, areas(i));
cd (new_name)
%rps = findfiles([], pwd);
% upload MDM
glmfiles = dir('*.glm');
glm = xff(glmfiles.name);
% % I want to get this code to loop through all the Brodmann areas without me
% % having to manually input it every time
% test = xff('Brodmann_17.glm');
%These are collecting the blind and sighted maps from the PhD group. There
%are 13 blind subjects and 18 sighted subjects
num_subj_bl = 13;
num_subj_si = 18;
blind = glm.GLMData.BetaMaps(:,:,:,26:38);
sighted = glm.GLMData.BetaMaps(:,:,:,39:56);
[Dim1, Dim2, Dim3, Dim4] = size(glm.GLMData.BetaMaps);
%These are collecting the blind and sighted maps from the rainbow group.
%There are 12 blind subjects and 13 sighted subjects
num_subj_bl1 = 12;
num_subj_si1 = 13;
blind1 = glm.GLMData.BetaMaps(:,:,:,1:12);
sighted1 = glm.GLMData.BetaMaps(:,:,:,13:25);
%% Preparing for forloop
%Concatenating the blind and sighted subjects
blind_all = cat(4,blind,blind1);
sighted_all = cat(4,sighted,sighted1);
fmap_vis = zeros(58, 40, 46);
fmap_cohort = zeros(58, 40 ,46);
fmap_int = zeros(58, 40 ,46);
total_subj_bl = 25;
total_subj_si = 31;
%These are the creating the appropriate strings necessary for anovan analysis
str1 = [string('Blind')];
str2 = [string('Sighted')];
str3 = [string('Rainbow')];
str4 = [string('PhD')];
%string for factor 1, blind v sighted
vision = [repmat(str1,1,25), repmat(str2,1,31)];
g2 = [repmat(str4,1,13), repmat(str3,1,12)];
g3 = [repmat(str4,1,18), repmat(str3,1,13)];
%string for factor 2, rainbow vs PhD cohort
cohort = [g2 g3];
%% This forloop will loop through all the voxels
for a= 25
for b= 25
for c= 25
%These first 3 forloops loop through each unique voxel in the 175 x 121 X
%139 3D matrix that is generated for each subject
%These forloops loop through each individual subject in the blind and
%sighted conditions and put the corresponding voxels across all the
%subjects in a column vector. Therefore, voxel (1,1,1) across all 12 blind
%subjects will be put in the vector blind_vox and voxel (1,1,1) across all
%13 sighted subjects will be put in the vector sighted_vox.
blind_vox = [];
sighted_vox = [];
for x= 1:total_subj_bl
vox = blind_all(a,b,c,x);
blind_vox = [blind_vox; vox];
end
for y= 1:total_subj_si
vox1= sighted_all(a,b,c,y);
sighted_vox = [sighted_vox; vox1];
end
%This is creating a response vector for anovan analysis
data_all = vertcat(blind_vox, sighted_vox);
%Running a 2x2 ANOVA on the data using anovan
[p, tbl] = anovan(data_all,{vision cohort},'model','interaction','varnames',{'vision','cohort'},'display','off');
%Saving the f stats for the main effects and interaction
%This is the F stat for blind v sighted
fstat_vis = tbl(2,6);
fstat1 = cell2mat(fstat_vis);
%This is the F stat for cohort type, rainbow vs. PhD
fstat_cohort = tbl(3,6);
fstat2 = cell2mat(fstat_cohort);
%This is the F stat for the interaction
fstat_int = tbl(4,6);
fstat3 = cell2mat(fstat_int);
%Padcat takes the uneven column vectors since they both have a
%different number of subjects and turns them into even column
%vectors by padding the smaller vector with NaN values
%vect_for_BF = padcat(blind_vox, sighted_vox);
%This runs the Brown Forsythe test on the 2 column matrix
%[p,stats] = vartestn(vect_for_BF,'TestType','BrownForsythe','Display','off');
%This runs a simple 1 way ANOVA on the column vector
%[p,tbl] = anova1(vect_for_BF, [], 'off');
%fstat = tbl{2,5};
%This will contain the f values for all the tests run
fmap_vis(a,b,c) = fstat1;
fmap_cohort(a,b,c) = fstat2;
fmap_int(a,b,c) = fstat3;
end
end
end
%Saving the degrees of freedom
% df = tbl(5,3);
% Put in the data and save
cd('D:\SAMP\Variability_Project\Code\Creating_MDMsGLMs');
f_Map = xff('3X3X3_3maps.vmp');
f_Map.NrOfMaps = 3;
f_Map.Map = f_Map.Map(1:3);
f_Map.Map(1).Name = 'FMap_Vis';
f_Map.Map(1).VMPData = fmap_vis;
f_Map.Map(2).Name = 'FMap_Cohort';
f_Map.Map(2).VMPData = fmap_cohort;
f_Map.Map(3).Name = 'FMap_Int';
f_Map.Map(3).VMPData = fmap_int;
cd (new_name)
% name2 = ('Brodmann_');
% new_name2 = strcat(name2, areas(i),'.vmp');
f_Map.SaveAs('anova_effect.vmp');
end
%popUp.m
msg = 'All done!';
title = 'all done!';
answer = inputdlg(msg,title);