'.' is not an internal or external command, nor is it a runnable program or batch file

4 Ansichten (letzte 30 Tage)
this below is raw2jpeg.m:
function raw2jpeg(lfp_file)
cd('lfptools') ;
sys_command = ['./lfpsplitter ../' lfp_file];
system(sys_command,'-echo') ;
cd('..') ;
[lfp_folder, lfp_path , ~] = fileparts(lfp_file) ;
lfp_path = [lfp_folder '/' lfp_path] ;
fin = fopen(strcat(lfp_path, '_imageRef0.raw'), 'r') ;
meta = fopen(strcat(lfp_path, '_metadataRef0.txt'), 'r') ;
for i = 1:3
fgets(meta);
end
fgets(meta, 12)
width = fscanf(meta, '%d') ;
fgets(meta) ;
fgets(meta, 12) ;
height = fscanf(meta, '%d') ;
I = fread(fin, width*height, 'uint16=>uint16') ;
im_in = reshape(I, height, width) ;
im_in = im_in' ;
delete([lfp_path '_imageRef0.raw'], [lfp_path '_metadataRef0.txt'], ...
[lfp_path '_privateMetadataRef1.txt'], [lfp_path '_table.txt']) ;
im_in = im_in.*1.5 ;
imwrite(im2uint8(im_in), strcat(lfp_path,'.jpg')) ;
end
The code below is an example for raw2jpeg.m:
raw2jpeg('../input/dataset/raw.lfp'); (just one row)
And the result shows like this:
'.' is not an internal or external command, nor is it a runnable program or batch file
Incorrect use of fgets
The file identifier is invalid. Generate a valid file identifier using fopen (the error exists in line 11 of raw2jpeg.m)
  2 Kommentare
Bjorn Gustavsson
Bjorn Gustavsson am 16 Sep. 2019
What happens if you give the full path to your lfpsplitter program?
Have you tried to run the code line by line? With something like dbstop in raw2jpeg set on the command-line?
Rik
Rik am 16 Sep. 2019
It looks like you're getting an error in your system call, which then breaks the assumptions of the later code.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Guillaume
Guillaume am 16 Sep. 2019
First use fullfile to build paths instead of string concatenation and adding the path separator yourself. It would be more reliable.
Ther are many potential failure points in your code and you never check that anything works as you expected, so it shouldn't be surprising that you can get obscure errors.
In the first line of your function, you change to the lfptools directory relative to the current one. If the current directory is not the one you expected or if there's no lfptools directory in the current directory, the cd will fail. Note that there is never any reason to cd anywhere. Using absolute paths guarantees you that the folder you target is the one you meant regardless of what the current directory is.
You then assume that lfpsplitter has run succesfully and created two files with a given name. You never check that it is indeed the case. If it failed or for some reason named the files differently your fopen calls will fail to open the file. As a result the fin or meta file identifier will be invalid and as soon as you try to use it, you'll get an error. This is clearly what is happening here, your meta file identifier is invalid, so the first time you try to use it with fgets you get an error. Most likely the raw_metadataRef0.txt file does not exist (or can't be open for a reason or another).
When dealing with files always check that your operation actually succeeded. After a fopen check the file id is valid (i.e. positive), after a fread check that you've read the number of bytes you expected, etc.
Also, make sure that you call fclose before attempting to delete a file you've been reading/writing to. As it is, your delete call will always fail since you've still got fin and meta open.
  11 Kommentare
Huadong Hu
Huadong Hu am 17 Sep. 2019
the Ifptools folder have files like the picture.QQ图片20190917075828.png,Is it due to the lack of the corresponding file or the code problem?
Guillaume
Guillaume am 17 Sep. 2019
Looks like you have the source code for that tool but you haven't compiled it, so of course you can't use it yet.
You'll have to find a compiled version of the tool or compile it yourself. The instructions for compiling it should be in the readme that came with it. Note that this has nothing to do with matlab so if you need help with that you'd be better off finding a support for that tool.

Melden Sie sich an, um zu kommentieren.


Walter Roberson
Walter Roberson am 16 Sep. 2019
You are trying to run Linux code on ms windows. You will need to change the / in the system() command to \
  4 Kommentare
Bjorn Gustavsson
Bjorn Gustavsson am 16 Sep. 2019
This should work - is something I ususally find to be a very optimistic aproach to my programming, see Guillaume's answer for detailed description of what to look for.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by