I encountered an 'invalid use of operator' error message.

51 vues (au cours des 30 derniers jours)
Shiyue
Shiyue le 11 Nov 2024 à 14:57
Commenté : Harald le 12 Nov 2024 à 10:43
I encountered an 'invalid use of operator' error message when excuted this below.
load(fullfile(E:\charite\Data\EGCG_Round3\MRE\MouseAtlasReg\ProcessedShort\20241024_sl_MRE_Day18_Cage1_3505_MRE\mreCubes1,'ventricles.mat'));

Réponse acceptée

Harald
Harald le 11 Nov 2024 à 15:06
Hi,
you need to place single or double quotes around the path. With single quotes:
load(fullfile('E:\charite\Data\EGCG_Round3\MRE\MouseAtlasReg\ProcessedShort\20241024_sl_MRE_Day18_Cage1_3505_MRE\mreCubes1','ventricles.mat'));
If you are just getting started with MATLAB, you may find the MATLAB Onramp helpful.
Best wishes,
Harald
  6 commentaires
Shiyue
Shiyue le 12 Nov 2024 à 9:04
Here is the full text
pathDefault = 'E:\charite\Data\EGCG_Round3\MRE\MouseAtlasReg\ProcessedShort\20241024_170015_20241024_sl_MRE_Day18_Cage1_3505_MRE_1_1\mreCubes1';
listing = dir(pathDefault);
listing(1:2) = [];
for iFolder = 1 : length(listing)
currentPath = fullfile(listing(iFolder).folder, listing(iFolder).name);
path = fullfile(currentPath,'rois'); %change back to rois
disp(path);
if strcmp(listing(iFolder).name,'results')%doesnt run the loop for this folder
continue;
end
load(fullfile('E:\mreCubes1', 'ventricles.mat'));
ventricles_dilated1pix=imdilate(ventricles,strel('disk', 1));
save(fullfile ('E:\mreCubes1', 'ventricles_dilated1pix'),'ventricles_dilated1pix');
load(fullfile('E:\mreCubes1','ventricles.mat'));
load(fullfile('E:\mreCubes1\rois','WholeBrain_115cut.mat'));
WholeBrain_115cut_noVentricle = and(WholeBrain_115cut.mat, ~ventricles.mat);
save(fullfile ('E:\mreCubes1', 'WholeBrain_115cut_noVentricle'),'WholeBrain_115cut_noVentricle')
Harald
Harald le 12 Nov 2024 à 10:43
Hi,
you should not work with the .mat files in that line, but with the variables that you have imported from them:
If the variables are named the same as the .mat files, this would be
WholeBrain_115cut_noVentricle = and(WholeBrain_115cut, ~ventricles);
like you have shown in an earlier version.
In general, it will be
varC = and(varA, ~varB);
Best wishes,
Harald

Connectez-vous pour commenter.

Plus de réponses (2)

dpb
dpb le 11 Nov 2024 à 15:06
load(fullfile('E:\charite\Data\EGCG_Round3\MRE\MouseAtlasReg\ProcessedShort\20241024_sl_MRE_Day18_Cage1_3505_MRE\mreCubes1','ventricles.mat'));
You forgot the tic marks around the folder string; MATLAB tried to evaluate the \ as the ldivide, .\ operator.
  1 commentaire
Harald
Harald le 11 Nov 2024 à 15:18
Strictly speaking, mldivide (\) rather than ldivide (.\).

Connectez-vous pour commenter.


Image Analyst
Image Analyst le 11 Nov 2024 à 15:07
You forgot quotes. Corrected:
load(fullfile('E:\charite\Data\EGCG_Round3\MRE\MouseAtlasReg\ProcessedShort\20241024_sl_MRE_Day18_Cage1_3505_MRE\mreCubes1','ventricles.mat'));
or simply don't use fullfile(), unless you need to change the folder or basefilename and are using variables for that:
load('E:\charite\Data\EGCG_Round3\MRE\MouseAtlasReg\ProcessedShort\20241024_sl_MRE_Day18_Cage1_3505_MRE\mreCubes1\ventricles.mat');
  1 commentaire
Shiyue
Shiyue le 11 Nov 2024 à 15:39
Thanks for your answer; it worked!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Entering Commands dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by